From 210a85035303e2be8fb44a2899b9391c662f080f Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 4 Aug 2021 14:18:59 -0400 Subject: [PATCH] telemetry: add log message when certs are about to expire --- agent/consul/leader_metrics.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/agent/consul/leader_metrics.go b/agent/consul/leader_metrics.go index 42ac50c37..77cde7183 100644 --- a/agent/consul/leader_metrics.go +++ b/agent/consul/leader_metrics.go @@ -140,6 +140,12 @@ func (m CertExpirationMonitor) Monitor(ctx context.Context) error { logger.Warn("failed to emit certificate expiry metric", "error", err) continue } + + if d < 24*time.Hour { + logger.Warn("certificate will expire soon", + "time_to_expiry", d, "expiration", time.Now().Add(d)) + } + expiry := d / time.Second metrics.SetGaugeWithLabels(m.Key, float32(expiry), m.Labels) }