Caddy.Metrics.Poller (Caddy v2.3.1)
View SourcePeriodic metrics collection from Caddy's Prometheus endpoint.
This GenServer periodically fetches metrics from Caddy and emits telemetry events with the collected data.
Configuration
config :caddy,
metrics_enabled: true,
metrics_interval: 15_000 # millisecondsStarting the Poller
# Manual start
Caddy.Metrics.Poller.start_link(interval: 15_000)
# Check if running
Caddy.Metrics.Poller.running?()
# Stop the poller
Caddy.Metrics.Poller.stop()Telemetry Events
When metrics are collected, the following event is emitted:
[:caddy, :metrics, :collected]With measurements containing all parsed metric values.
Summary
Functions
Returns a specification to start this module under a supervisor.
Get the current interval setting.
Get the last collected metrics.
Trigger an immediate metrics collection.
Check if the poller is running.
Update the polling interval.
Start the metrics poller.
Stop the metrics poller.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec interval(GenServer.server()) :: pos_integer()
Get the current interval setting.
@spec last_metrics(GenServer.server()) :: Caddy.Metrics.t() | nil
Get the last collected metrics.
@spec poll_now(GenServer.server()) :: :ok
Trigger an immediate metrics collection.
@spec running?(GenServer.server()) :: boolean()
Check if the poller is running.
@spec set_interval(pos_integer(), GenServer.server()) :: :ok
Update the polling interval.
@spec start_link(keyword()) :: GenServer.on_start()
Start the metrics poller.
Options
:interval- Polling interval in milliseconds (default: 15000):name- Process name (default:Caddy.Metrics.Poller)
@spec stop(GenServer.server()) :: :ok
Stop the metrics poller.