Monitorex.Storage
(monitorex v0.3.0)
Copy Markdown
Pure read/query layer over the Collector's ETS tables.
All functions read directly from named ETS tables — no GenServer calls,
no casts, no side effects. Designed for read-only access to telemetry data
collected by Monitorex.Collector.
Summary
Functions
Returns count of recent inbound events matching optional filters.
Returns count of recent outbound events matching optional filters.
Fetches a specific event from the recent tables by timestamp key.
Returns consumer aggregates from :monitorex_inbound_consumers,
sorted by requests descending.
Returns consumer breakdown for a given route key ("Method:path").
Returns list of endpoint aggregates for a given host.
Returns list of host aggregates from :monitorex_outbound_hosts,
sorted by requests descending.
Returns most recent inbound Events with optional filtering.
Returns most recent outbound Events with optional filtering.
Returns route aggregates from :monitorex_inbound_routes, sorted by requests
descending.
Functions
@spec count_recent_inbound(keyword()) :: non_neg_integer()
Returns count of recent inbound events matching optional filters.
Same filtering as list_recent_inbound/1 but returns count instead of events.
@spec count_recent_outbound(keyword()) :: non_neg_integer()
Returns count of recent outbound events matching optional filters.
Same filtering as list_recent_outbound/1 but returns count instead of events.
@spec get_event(integer()) :: Monitorex.Event.t() | nil
Fetches a specific event from the recent tables by timestamp key.
Searches both outbound and inbound recent tables and returns the first
match, or nil if no event is found.
@spec list_consumers() :: [map()]
Returns consumer aggregates from :monitorex_inbound_consumers,
sorted by requests descending.
Returns consumer breakdown for a given route key ("Method:path").
Queries :monitorex_inbound_recent, groups events by consumer, and
computes aggregate stats (requests, errors, total_duration, avg_latency,
last_seen) for each consumer on that route.
Returns list of endpoint aggregates for a given host.
Queries :monitorex_outbound_endpoints for entries whose key matches
the given host (key is {host, path}).
@spec list_hosts() :: [map()]
Returns list of host aggregates from :monitorex_outbound_hosts,
sorted by requests descending.
Each entry includes computed p50, p95, p99 from duration samples and the error rate.
@spec list_recent_inbound(keyword()) :: [Monitorex.Event.t()]
Returns most recent inbound Events with optional filtering.
Options
:limit— maximum number of events to return (default: 50, must be positive):offset— number of events to skip (default: 0):status_class— filter by status class atom (e.g.:error,:success).nilor omission means no filter.:consumer— filter by exact consumer match.:route— filter by route key ("Method:path").
@spec list_recent_outbound(keyword()) :: [Monitorex.Event.t()]
Returns most recent outbound Events with optional filtering.
Options
:limit— maximum number of events to return (default: 50, must be positive):offset— number of events to skip (default: 0):status_class— filter by status class atom (e.g.:error,:success).nilor omission means no filter.:host— filter by exact host match.nilor omission means no filter.
@spec list_routes() :: [map()]
Returns route aggregates from :monitorex_inbound_routes, sorted by requests
descending.
Parses the "Method:path" key into separate :method and :path fields.
Each entry includes computed p50, p95, p99 from duration samples and error rate.