Add lifetime to certificates monitored
This commit is contained in:
@@ -37,6 +37,13 @@ var (
|
||||
Help: "Error checking the certificate.",
|
||||
}, []string{"address"})
|
||||
|
||||
gaugeCertLifetime = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: "labmon",
|
||||
Subsystem: "tlsconmon",
|
||||
Name: "certificate_lifetime_seconds",
|
||||
Help: "How long the certificate is valid in seconds.",
|
||||
}, []string{"address"})
|
||||
|
||||
// OTEL tracing
|
||||
tracer = otel.Tracer(name)
|
||||
)
|
||||
@@ -104,6 +111,8 @@ func (tm *TLSConnectionMonitor) Start(ctx context.Context) {
|
||||
if err := tm.fetchCert(ctx); err != nil {
|
||||
gaugeCertError.WithLabelValues(tm.Address).Set(1)
|
||||
gaugeCertTimeLeft.WithLabelValues(tm.Address).Set(0)
|
||||
lifetime := tm.cert.NotAfter.Sub(tm.cert.NotBefore).Seconds()
|
||||
gaugeCertLifetime.WithLabelValues(tm.Address).Set(lifetime)
|
||||
} else {
|
||||
gaugeCertError.WithLabelValues(tm.Address).Set(0)
|
||||
timeLeft := time.Until(tm.cert.NotAfter).Seconds()
|
||||
|
Reference in New Issue
Block a user