telemetry: only emit leader cert expiry metrics on the servers

This commit is contained in:
Daniel Nephin 2021-10-19 16:49:23 -04:00
parent 7fe60e5989
commit 7948720bbb
2 changed files with 8 additions and 3 deletions

View File

@ -22,7 +22,7 @@ import (
var metricsKeyMeshRootCAExpiry = []string{"mesh", "active-root-ca", "expiry"} var metricsKeyMeshRootCAExpiry = []string{"mesh", "active-root-ca", "expiry"}
var metricsKeyMeshActiveSigningCAExpiry = []string{"mesh", "active-signing-ca", "expiry"} var metricsKeyMeshActiveSigningCAExpiry = []string{"mesh", "active-signing-ca", "expiry"}
var CertExpirationGauges = []prometheus.GaugeDefinition{ var LeaderCertExpirationGauges = []prometheus.GaugeDefinition{
{ {
Name: metricsKeyMeshRootCAExpiry, Name: metricsKeyMeshRootCAExpiry,
Help: "Seconds until the service mesh root certificate expires. Updated every hour", Help: "Seconds until the service mesh root certificate expires. Updated every hour",
@ -31,6 +31,9 @@ var CertExpirationGauges = []prometheus.GaugeDefinition{
Name: metricsKeyMeshActiveSigningCAExpiry, Name: metricsKeyMeshActiveSigningCAExpiry,
Help: "Seconds until the service mesh signing certificate expires. Updated every hour", Help: "Seconds until the service mesh signing certificate expires. Updated every hour",
}, },
}
var AgentCertExpirationGauges = []prometheus.GaugeDefinition{
{ {
Name: metricsKeyAgentTLSCertExpiry, Name: metricsKeyAgentTLSCertExpiry,
Help: "Seconds until the agent tls certificate expires. Updated every hour", Help: "Seconds until the agent tls certificate expires. Updated every hour",

View File

@ -211,14 +211,16 @@ func getPrometheusDefs(cfg lib.TelemetryConfig, isServer bool) ([]prometheus.Gau
xds.StatsGauges, xds.StatsGauges,
usagemetrics.Gauges, usagemetrics.Gauges,
consul.ReplicationGauges, consul.ReplicationGauges,
consul.CertExpirationGauges, consul.AgentCertExpirationGauges,
Gauges, Gauges,
raftGauges, raftGauges,
} }
// TODO(ffmmm): conditionally add only leader specific metrics to gauges, counters, summaries, etc // TODO(ffmmm): conditionally add only leader specific metrics to gauges, counters, summaries, etc
if isServer { if isServer {
gauges = append(gauges, consul.AutopilotGauges) gauges = append(gauges,
consul.AutopilotGauges,
consul.LeaderCertExpirationGauges)
} }
// Flatten definitions // Flatten definitions