Skip to content

Commit

Permalink
Metrics: Fix namespace in `nginx_ingress_controller_ssl_expire_time_s…
Browse files Browse the repository at this point in the history
…econds`. (#10274)
  • Loading branch information
alexey-gavrilov-flant authored Sep 17, 2024
1 parent 2cbe9b0 commit 9e6c406
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/ingress/metric/collectors/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ func (cm *Controller) SetSSLExpireTime(servers []*ingress.Server) {
}
labels["host"] = s.Hostname
labels["secret_name"] = s.SSLCert.Name
labels["namespace"] = s.SSLCert.Namespace
labels["identifier"] = s.SSLCert.Identifier()

cm.sslExpireTime.With(labels).Set(float64(s.SSLCert.ExpireTime.Unix()))
Expand Down
4 changes: 3 additions & 1 deletion internal/ingress/metric/collectors/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func TestControllerCounters(t *testing.T) {
Hostname: "demo",
SSLCert: &ingress.SSLCert{
ExpireTime: t1,
Name: "secret-name",
Namespace: "secret-namespace",
Certificate: &x509.Certificate{
PublicKeyAlgorithm: x509.ECDSA,
Issuer: pkix.Name{
Expand All @@ -111,7 +113,7 @@ func TestControllerCounters(t *testing.T) {
want: `
# HELP nginx_ingress_controller_ssl_expire_time_seconds Number of seconds since 1970 to the SSL Certificate expire.\n An example to check if this certificate will expire in 10 days is: "nginx_ingress_controller_ssl_expire_time_seconds < (time() + (10 * 24 * 3600))"
# TYPE nginx_ingress_controller_ssl_expire_time_seconds gauge
nginx_ingress_controller_ssl_expire_time_seconds{class="nginx",host="demo",identifier="abcd1234-100",namespace="default",secret_name=""} 1.351807721e+09
nginx_ingress_controller_ssl_expire_time_seconds{class="nginx",host="demo",identifier="abcd1234-100",namespace="secret-namespace",secret_name="secret-name"} 1.351807721e+09
`,
metrics: []string{"nginx_ingress_controller_ssl_expire_time_seconds"},
},
Expand Down

0 comments on commit 9e6c406

Please sign in to comment.