From 68e1c6bde7cf8cacad69cc70038d203362792796 Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Wed, 31 May 2023 14:19:28 -0400 Subject: [PATCH] Don't update the notAfter Gauge with zeros (#6924) I think ideally we'd only ever call exportMetrics with a valid time, but that's a bit bigger of a refactor of this code. This was the fix we lightly decided on in the discussion of #6635 Fixes #6635 --- observer/probers/tls/tls.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/observer/probers/tls/tls.go b/observer/probers/tls/tls.go index 0ff161245..d2d1f06d7 100644 --- a/observer/probers/tls/tls.go +++ b/observer/probers/tls/tls.go @@ -98,7 +98,9 @@ func (p TLSProbe) checkRoot(rootOrg, rootCN string) error { // Export expiration timestamp and reason to Prometheus. func (p TLSProbe) exportMetrics(notAfter time.Time, reason reason) { - p.notAfter.WithLabelValues(p.hostname).Set(float64(notAfter.Unix())) + if !notAfter.IsZero() { + p.notAfter.WithLabelValues(p.hostname).Set(float64(notAfter.Unix())) + } p.reason.WithLabelValues(p.hostname, reasonToString[reason]).Inc() }