Monitorex.Storage.Backend behaviour (monitorex v0.6.0)

Copy Markdown

Behaviour for Monitorex storage backends.

Implementations handle both writing telemetry events and reading/querying stored data. The Collector writes events through the backend; the Storage module reads through it.

Configuring the backend

config :monitorex, :storage_backend, Monitorex.Storage.ETS

Or for SQLite:

config :monitorex, :storage_backend, Monitorex.Storage.SQLite
config :monitorex, :sqlite_path, "/var/lib/monitorex/data.db"

Summary

Callbacks

Count recent inbound events matching filters.

Count recent outbound events matching filters.

Fetch a specific event by timestamp.

List consumer aggregates, sorted by requests descending.

List consumer breakdown for a route key.

List endpoint aggregates for a given host.

List all host aggregates, sorted by requests descending.

List recent inbound events with optional filtering.

List recent outbound events with optional filtering.

List route aggregates, sorted by requests descending.

List slow inbound events.

List slow outbound events.

Prune old data (called during Collector cleanup cycle).

Record a single telemetry event.

Callbacks

count_recent_inbound(keyword)

@callback count_recent_inbound(keyword()) :: non_neg_integer()

Count recent inbound events matching filters.

count_recent_outbound(keyword)

@callback count_recent_outbound(keyword()) :: non_neg_integer()

Count recent outbound events matching filters.

get_event(integer)

@callback get_event(integer()) :: Monitorex.Event.t() | nil

Fetch a specific event by timestamp.

list_consumers()

@callback list_consumers() :: [map()]

List consumer aggregates, sorted by requests descending.

list_consumers_for_route(t)

@callback list_consumers_for_route(String.t()) :: [map()]

List consumer breakdown for a route key.

list_endpoints_for_host(t)

@callback list_endpoints_for_host(String.t()) :: [map()]

List endpoint aggregates for a given host.

list_hosts()

@callback list_hosts() :: [map()]

List all host aggregates, sorted by requests descending.

list_recent_inbound(keyword)

@callback list_recent_inbound(keyword()) :: [Monitorex.Event.t()]

List recent inbound events with optional filtering.

list_recent_outbound(keyword)

@callback list_recent_outbound(keyword()) :: [Monitorex.Event.t()]

List recent outbound events with optional filtering.

list_routes()

@callback list_routes() :: [map()]

List route aggregates, sorted by requests descending.

list_slow_inbound(keyword)

@callback list_slow_inbound(keyword()) :: [Monitorex.Event.t()]

List slow inbound events.

list_slow_outbound(keyword)

@callback list_slow_outbound(keyword()) :: [Monitorex.Event.t()]

List slow outbound events.

prune()

@callback prune() :: :ok

Prune old data (called during Collector cleanup cycle).

record_event(t)

@callback record_event(Monitorex.Event.t()) :: :ok

Record a single telemetry event.