Skip to content

nginx_ingress_controller_ssl_expire_time_seconds Prometheus metrics giving duplicate results for same domain #13529

@Laveshsp

Description

@Laveshsp

What happened:

I have an ingress domain that's using tls cert pointing to k8s secret named tls-ingress-secret. It started giving me the cert expiry alert set via prometheus query as below and this was expected.
0 <= floor((avg(nginx_ingress_controller_ssl_expire_time_seconds{cluster='{{ $k }}'}) by (host secret_name, namespace) - time()) / 86400)

Action: I went ahead and deleted the old cert having name tls-ingress-secret. With this my ingress domain started pointing to nginx's default-cert (in ingress namespace) which is expected again. Later I created the k8s secret with same name tls-ingress-secret (in prometheus namespace) having renewed creds. I later also confirmed on browser too that it has picked new certs with new export date that is around 1year from now.

Issue: After completing the above action too, the prometheus query is giving two results for same domain one with default-cert and one more with tls-ingress-secret as shown in below ScreenShot

Image

What you expected to happen:

As soon as the new secret was created, prometheus query should not give results containing the default-cert details and be able to only pick the new cert details and omit the default-cert detail.

NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version):

Image

Kubernetes version (use kubectl version): 1.30

Environment: AWS EKS Cluster

  • Cloud provider or hardware configuration: AWS EKS Cluster

How to reproduce this issue:

  • Install ingress nginx controller from helm chart V1.12.1 on ingress namespace having a custom default-cert configured on same ns
  • Create one more k8s tls secret with name tls-ingress-secret on app ns to reference it in below test ingress
  • Create any test k8s ingress conf say for eg: test.prom.com by pointing the tls section to tls-ingress-secret
  • Run the prometheus query to get one entry for test.prom.com domain pointing to secret tls-ingress-secret (Expected behavior)
  • Delete the k8s secret tls-ingress-secret
  • Run the prometheus query to get one entry for test.prom.com domain pointing to secret default-cert (Expected behavior)
  • Recreate the tls-ingress-secret again on app ns.
  • Run the prometheus query again. Here you will get two entries, one with default-cert secret and one more with tls-ingress-secret o same domain(Not expected behavior behavior)

Anything else we need to know:
Request to please assist as this is creating a lot of false alerts wrt tls cert expiry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions