metrics¶
OpenMetrics (Prometheus) exporter for ntpstats monitor and ntpstats watch.
ntpstats monitor pool.ntp.org --metrics-port 9123 serves /metrics
(bound to 127.0.0.1 unless --metrics-host says otherwise). Besides the
latest measurement it exports what dashboards usually lack: an error bound
and rolling stability statistics computed from a window of recent samples.
Metrics (label source = server name, or chrony/ntpd for watch):
========================================= ===========================================
ntpstats_offset_seconds last offset, reference - local
ntpstats_delay_seconds last round-trip delay (monitor)
ntpstats_offset_bound_seconds |offset| + delay/2 + root_delay/2 + root_dispersion:
how far the local clock can be from the
source's reference, given this sample
ntpstats_root_delay_seconds source's root delay
ntpstats_root_dispersion_seconds source's root dispersion
ntpstats_stratum source's stratum
ntpstats_frequency_ppm local frequency correction (watch)
ntpstats_authenticated 1 when the sample was NTS-authenticated
ntpstats_last_sample_timestamp_seconds POSIX time of the last sample
ntpstats_offset_stddev_seconds standard deviation of the offset over the window
ntpstats_tdev_seconds{tau="..."} TDEV over the window at 1, 4 and 16 sample intervals
ntpstats_samples_total samples received (counter)
ntpstats_errors_total{kind="..."} errors by kind, e.g. timeout, kod_rate (counter)
========================================= ===========================================
Registry
¶
Thread-safe store of the latest values and a rolling window per source.
observe(source, t, offset, **values)
¶
Record one sample. values may hold delay, root_delay,
root_dispersion, stratum, frequency_ppm and authenticated.
observe_ntp(r)
¶
Record an :class:ntpstats.sntp.NTPResult.
observe_watch(daemon, d)
¶
Record a :class:ntpstats.sources.LocalWatch sample dict.
snapshot()
¶
Consistent copy of everything exported: gauges, rolling statistics, counters.
values()
¶
Gauge rows (name, help, source, value) as exported (seconds unless the name says otherwise).
error_kind(exc)
¶
Short, stable label for an exception (used as the kind label).
serve(registry, host='127.0.0.1', port=9123)
¶
Serve /metrics in a daemon thread; returns the server (call shutdown() to stop).