Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more certificate information into prometheus metrics #7040

Open
gbassinello opened this issue May 20, 2024 · 1 comment · May be fixed by #7042
Open

Add more certificate information into prometheus metrics #7040

gbassinello opened this issue May 20, 2024 · 1 comment · May be fixed by #7042
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@gbassinello
Copy link

gbassinello commented May 20, 2024

Is your feature request related to a problem? Please describe.

Almost all certificates we have are managed by cert-manager and I want to build a Grafana dashboard using the Prometheus data source to list all ingresses that aren't managed by cert-manager.

Describe alternatives you've considered

List all ingresses using the kube_state_metrics kube_ingress_annotations metric that don't have a cert-manager annotation.

Describe the solution you'd like

Since the Certificate CRD resources are managed by cert-manager, I think a good way to provide more useful information for this type of monitoring would be to expose some new data about the Certificate CRD's (dnsNames, issuerRefName, secretName, etc) either by:

  • Exporting a new metric (something like certmanager_certificate_info) with this data
  • Adding this data into already existing metrics certmanager_certificate_expiration_timestamp_seconds, certmanager_certificate_renewal_timestamp_seconds, certmanager_certificate_ready_status

Additional context

If I had the secret name of the Certificate CRD into the cert-manager metrics, I could compare the kube_state_metrics kube_ingress_tls metric with the cert-manager metric and find out all the secrets that are referenced by a ingress and are NOT referenced by cert-manager (thus finding out all certificates that aren't managed by cert-manager).

I think exposing this data would be a great addition to the metrics exported by cert-manager and would be very useful to a lot of people.

Environment details (remove if not applicable):

  • Kubernetes version: v1.27.10
  • Cloud-provider/provisioner: Bare Metal
  • cert-manager version: v1.13.3
  • Install method: e.g. helm/static manifests: idk

/kind feature

@cert-manager-prow cert-manager-prow bot added the kind/feature Categorizes issue or PR as related to a new feature. label May 20, 2024
@1mamute 1mamute linked a pull request May 21, 2024 that will close this issue
@wallrj
Copy link
Member

wallrj commented May 23, 2024

Thanks @gbassinello

I want to build a Grafana dashboard using the Prometheus data source to list all ingresses that aren't managed by cert-manager.

Given that problem, I prefer your alternative suggestion, but I'm happy to change my mind if that turns out not to be viable.

List all ingresses using the kube_state_metrics kube_ingress_annotations metric that don't have a cert-manager annotation.

I tried it out locally

EDITOR=vi kubectl edit -n prometheus deployments.apps default-kube-state-metrics
    spec:
      containers:
      - args:
        - --metric-annotations-allowlist=ingresses=[cert-manager.io/issuer,cert-manager.io/cluster-issuer],secrets=[cert-manager.io/certificate-name]
kubectl get --raw /api/v1/namespaces/prometheus/services/default-kube-state-metrics:8080/proxy/metrics | grep annotation_cert_manager_io
kube_ingress_annotations{namespace="default",ingress="example-1",annotation_cert_manager_io_cluster_issuer="issuer-1"} 1
kube_secret_annotations{namespace="default",secret="example-1-tls",annotation_cert_manager_io_certificate_name="example-1-tls"} 1
kube_secret_annotations{namespace="samplewebhook",secret="samplewebhook-example-webhook-webhook-tls",annotation_cert_manager_io_certificate_name="samplewebhook-example-webhook-webhook-tls"} 1
kube_secret_annotations{namespace="samplewebhook",secret="samplewebhook-example-webhook-ca",annotation_cert_manager_io_certificate_name="samplewebhook-example-webhook-ca"} 1

It should be possible to construct the report from those metrics, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants