diff --git a/collector/timex.go b/collector/timex.go index 6494726ef7..109b6be719 100644 --- a/collector/timex.go +++ b/collector/timex.go @@ -185,8 +185,15 @@ func (c *timexCollector) Update(ch chan<- prometheus.Metric) error { divisor = microSeconds } + offsetSec := float64(timex.Offset) / divisor + if offsetSec > 1.0 || offsetSec < -1.0 { + c.logger.Warn("Discarding unreasonable timex offset value", + "offset_seconds", offsetSec, "status", status) + offsetSec = 0 + } + ch <- c.syncStatus.mustNewConstMetric(syncStatus) - ch <- c.offset.mustNewConstMetric(float64(timex.Offset) / divisor) + ch <- c.offset.mustNewConstMetric(offsetSec) ch <- c.freq.mustNewConstMetric(1 + float64(timex.Freq)/ppm16frac) ch <- c.maxerror.mustNewConstMetric(float64(timex.Maxerror) / microSeconds) ch <- c.esterror.mustNewConstMetric(float64(timex.Esterror) / microSeconds) diff --git a/docs/node-mixin/alerts/alerts.libsonnet b/docs/node-mixin/alerts/alerts.libsonnet index 29c934f57b..01d04c7f8d 100644 --- a/docs/node-mixin/alerts/alerts.libsonnet +++ b/docs/node-mixin/alerts/alerts.libsonnet @@ -215,12 +215,16 @@ expr: ||| ( node_timex_offset_seconds{%(nodeExporterSelector)s} > 0.05 + and + node_timex_offset_seconds{%(nodeExporterSelector)s} < 1.0 and deriv(node_timex_offset_seconds{%(nodeExporterSelector)s}[5m]) >= 0 ) or ( node_timex_offset_seconds{%(nodeExporterSelector)s} < -0.05 + and + node_timex_offset_seconds{%(nodeExporterSelector)s} > -1.0 and deriv(node_timex_offset_seconds{%(nodeExporterSelector)s}[5m]) <= 0 )