From fdfb6450b9ed73a5f52410ae5bf0b7e87a770e33 Mon Sep 17 00:00:00 2001 From: mattb18 Date: Mon, 23 Dec 2024 16:34:27 +0000 Subject: [PATCH] only register grpc TLS metrics on success Signed-off-by: mattb18 --- prober/grpc.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/prober/grpc.go b/prober/grpc.go index 64c54dec7..cd43c7118 100644 --- a/prober/grpc.go +++ b/prober/grpc.go @@ -121,9 +121,6 @@ func ProbeGRPC(ctx context.Context, target string, module config.Module, registr registry.MustRegister(isSSLGauge) registry.MustRegister(statusCodeGauge) registry.MustRegister(healthCheckResponseGaugeVec) - registry.MustRegister(probeSSLEarliestCertExpiryGauge) - registry.MustRegister(probeTLSVersion) - registry.MustRegister(probeSSLLastInformation) if !strings.HasPrefix(target, "http://") && !strings.HasPrefix(target, "https://") { target = "http://" + target @@ -203,6 +200,7 @@ func ProbeGRPC(ctx context.Context, target string, module config.Module, registr if serverPeer != nil { tlsInfo, tlsOk := serverPeer.AuthInfo.(credentials.TLSInfo) if tlsOk { + registry.MustRegister(probeSSLEarliestCertExpiryGauge, probeTLSVersion, probeSSLLastInformation) isSSLGauge.Set(float64(1)) probeSSLEarliestCertExpiryGauge.Set(float64(getEarliestCertExpiry(&tlsInfo.State).Unix())) probeTLSVersion.WithLabelValues(getTLSVersion(&tlsInfo.State)).Set(1)