Skip to content

Commit

Permalink
only register grpc TLS metrics on success
Browse files Browse the repository at this point in the history
Signed-off-by: mattb18 <revoked>
  • Loading branch information
mattb18 committed Dec 23, 2024
1 parent 7e25c6f commit a73f810
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions prober/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a73f810

Please sign in to comment.