The metrics_collector plugin counts DNS queries and accumulates latency information. When built with the metrics feature it also provides a Prometheus-backed collector (prom_metrics_collector) that registers metrics in a Prometheus Registry.
This page documents the in-process collector and the optional Prometheus integration.
MetricsCollectorPlugin that maintains a shared counter and accumulated latency.metrics feature is enabled, a PromMetricsCollectorPlugin (it’s little weird that metrics enable prometheus, but oh well) registers Prometheus metrics (counters, gauge, histogram) and exposes more detailed telemetry.query_latency_ms metadata is present (f64), the collector aggregates latency (sums) and exposes average latency via helper methods.The basic collector does not require configuration beyond construction. For runtime quick-setup the exec prefix metrics_collector is recognized.
YAML example (exec quick setup):
plugins:
- exec: metrics_collector:
Prometheus-backed collector (requires metrics feature and a way to expose /metrics):
plugins:
- exec: prom_metrics_collector:name=my_dns_server
The prom_metrics_collector quick-setup accepts name=<metric_name> to scope/register metrics under a unique name.
metrics feature, PromMetricsCollectorPlugin registers metrics with a prometheus::Registry and provides the same execution behavior while exporting Prometheus metrics.name=<metric_name> quick-setup to namespace metrics and avoid collisions.query_latency_ms (f64) metadata to observe latency.query_error (bool) metadata to increment an error counter.execute() is being called.metrics feature is enabled, the collector is registered with the correct registry, and the /metrics exposure endpoint is configured.name to avoid metric name collisions.