Monitorex.AlertHistory (monitorex v0.6.0)

Copy Markdown

GenServer that manages an append-only ETS log of fired alerts.

Provides query, acknowledge, snooze, and active-alert-count functions used by the dashboard UI and the alert evaluation engine.

Summary

Functions

Acknowledge an alert by its timestamp key.

Returns a specification to start this module under a supervisor.

Re-evaluate snoozed alerts: any whose snooze has expired become :firing again. Called automatically by the AlertHistory cleanup cycle.

Count of currently firing (unacknowledged, non-snoozed) alerts.

List alert history entries, newest first.

Record a fired alert into the history table.

Snooze an alert by its timestamp key.

Start the AlertHistory GenServer.

Clear old entries beyond :max_alert_history (default 1_000).

Functions

acknowledge(timestamp)

@spec acknowledge(integer()) :: :ok | :not_found

Acknowledge an alert by its timestamp key.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

expire_snoozes()

@spec expire_snoozes() :: :ok

Re-evaluate snoozed alerts: any whose snooze has expired become :firing again. Called automatically by the AlertHistory cleanup cycle.

firing_count()

@spec firing_count() :: non_neg_integer()

Count of currently firing (unacknowledged, non-snoozed) alerts.

list_history(opts \\ [])

@spec list_history(keyword()) :: [map()]

List alert history entries, newest first.

Options

  • :limit — max entries (default: 100)
  • :status — filter by :firing, :acknowledged, :snoozed, or :all
  • :metric — filter by metric atom

record_alert(alert)

@spec record_alert(map()) :: :ok

Record a fired alert into the history table.

snooze(timestamp, snooze_seconds)

@spec snooze(integer(), snooze_seconds :: pos_integer()) :: :ok | :not_found

Snooze an alert by its timestamp key.

start_link(opts)

Start the AlertHistory GenServer.

trim()

@spec trim() :: :ok

Clear old entries beyond :max_alert_history (default 1_000).