TimelessMetricsDashboard (timeless_metrics_dashboard v0.4.3)

Copy Markdown View Source

Telemetry reporter and LiveDashboard page for TimelessMetrics.

Captures Telemetry.Metrics events into a Timeless store, giving you persistent historical metrics that survive restarts — unlike the built-in LiveDashboard charts which reset on every page load.

Reporter (standalone — no Phoenix required)

children = [
  {Timeless, name: :metrics, data_dir: "/var/lib/metrics"},
  {TimelessMetricsDashboard,
    store: :metrics,
    metrics:
      TimelessMetricsDashboard.DefaultMetrics.vm_metrics() ++
      TimelessMetricsDashboard.DefaultMetrics.phoenix_metrics()}
]

LiveDashboard Page

# In your router:
live_dashboard "/dashboard",
  additional_pages: [timeless: {TimelessMetricsDashboard.Page, store: :metrics}]

Summary

Functions

Returns a child spec that starts the TimelessMetrics store + telemetry reporter.

Callback for LiveDashboard's metrics_history option.

Functions

child_spec(opts)

Returns a child spec that starts the TimelessMetrics store + telemetry reporter.

Options

  • :name — store name (default: :timeless_metrics)
  • :data_dir — data directory (default: "priv/timeless_metrics")
  • :metricsTelemetry.Metrics list (default: DefaultMetrics.all())
  • :reporter — extra opts forwarded to Reporter (:flush_interval, :prefix)

metrics_history(metric, store, opts \\ [])

@spec metrics_history(Telemetry.Metrics.t(), atom(), keyword()) :: [map()]

Callback for LiveDashboard's metrics_history option.

Queries the Timeless store for recent data points matching the given Telemetry.Metrics struct and returns them in the format LiveDashboard expects.

Router Configuration

live_dashboard "/dashboard",
  metrics: MyAppWeb.Telemetry,
  metrics_history: {TimelessMetricsDashboard, :metrics_history, [:my_store]}

The store atom is appended by your MFA config; LiveDashboard prepends the metric struct, so the call becomes:

TimelessMetricsDashboard.metrics_history(metric, :my_store)

Options

A keyword list can be passed as a third element for additional config:

metrics_history: {TimelessMetricsDashboard, :metrics_history, [:my_store, [prefix: "app"]]}

Supported options:

  • :prefix — metric name prefix (default: "telemetry", must match your Reporter prefix)
  • :history — seconds of history to return (default: 3600)