Monitorex.Storage (monitorex v0.6.0)

Copy Markdown

Read/query layer over the configured storage backend.

All functions delegate to the active backend (ETS by default, SQLite when configured). This module is the single entry-point for dashboard pages, API, and exports.

Configuration

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

Or:

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

Summary

Functions

Returns count of recent inbound events matching optional filters.

Returns count of recent outbound events matching optional filters.

Fetches a specific event by timestamp from either outbound or inbound tables.

Returns consumer aggregates sorted by requests descending.

Returns consumer breakdown for a given route key.

Returns list of endpoint aggregates for a given host.

Returns list of host aggregates sorted by requests descending.

Returns most recent inbound Events with optional filtering.

Returns most recent outbound Events with optional filtering.

Returns route aggregates sorted by requests descending.

Returns slow inbound events, newest first.

Returns slow outbound events, newest first.

Functions

count_recent_inbound(opts \\ [])

@spec count_recent_inbound(keyword()) :: non_neg_integer()

Returns count of recent inbound events matching optional filters.

count_recent_outbound(opts \\ [])

@spec count_recent_outbound(keyword()) :: non_neg_integer()

Returns count of recent outbound events matching optional filters.

get_event(timestamp)

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

Fetches a specific event by timestamp from either outbound or inbound tables.

list_consumers()

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

Returns consumer aggregates sorted by requests descending.

list_consumers_for_route(route_key)

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

Returns consumer breakdown for a given route key.

list_endpoints_for_host(host)

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

Returns list of endpoint aggregates for a given host.

list_hosts()

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

Returns list of host aggregates sorted by requests descending.

list_recent_inbound(opts \\ [])

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

Returns most recent inbound Events with optional filtering.

Options

  • :limit — maximum events (default: 50)
  • :offset — events to skip (default: 0)
  • :status_class — filter by status class atom
  • :consumer — filter by exact consumer match
  • :route — filter by route key ("Method:path")

list_recent_outbound(opts \\ [])

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

Returns most recent outbound Events with optional filtering.

Options

  • :limit — maximum events (default: 50)
  • :offset — events to skip (default: 0)
  • :status_class — filter by status class atom
  • :host — filter by exact host match

list_routes()

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

Returns route aggregates sorted by requests descending.

list_slow_inbound(opts \\ [])

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

Returns slow inbound events, newest first.

Options

  • :limit — max events (default: 50)

list_slow_outbound(opts \\ [])

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

Returns slow outbound events, newest first.

Options

  • :limit — max events (default: 50)