cert-manager renews certificates on its own, so most teams stop thinking about them. That works until a renewal fails quietly. An expired DNS API token, a deleted ClusterIssuer or a rate limit can all leave a Certificate stuck, and the first sign is often a browser warning on a production hostname.
The controller already knows which certificates are healthy and when each one expires. It publishes that as Prometheus metrics. This guide shows how to scrape those metrics with the Prometheus Operator, what each certificate metric means, and how to write alert rules that give you days of warning instead of minutes.
The examples assume cert-manager v1.21 installed with the Helm chart in the cert-manager namespace, and Prometheus installed with the kube-prometheus-stack chart under the release name kube-prometheus-stack. Adjust the names if your setup differs.
How cert-manager exposes metrics
The controller, webhook and cainjector each serve metrics at /metrics on port 9402 of their pod. The container port is named http-metrics. By default the endpoint uses plain HTTP, though you can turn on TLS with static or dynamically generated certificates.
The certificate metrics come from the controller only. It does not keep counters that update when something happens. Instead, on every scrape it lists all Certificate resources from its informer cache and builds a fresh set of gauges from their spec and status. That design has a useful side effect: if a Certificate is deleted, its series disappear on the next scrape, so you don't get stale alerts for certificates that no longer exist.
Step 1: create a PodMonitor with the Helm chart
The cert-manager chart can create a PodMonitor or a ServiceMonitor for you. They are mutually exclusive. If you set both prometheus.podmonitor.enabled and prometheus.servicemonitor.enabled to true, the chart refuses to render and Helm fails with an error. Both select the controller, webhook and cainjector pods. This guide uses a PodMonitor, which scrapes the pods directly and matches the example in the cert-manager docs.
kube-prometheus-stack configures Prometheus to pick up only the PodMonitors that carry a release label matching its own Helm release name. That is controlled by podMonitorSelectorNilUsesHelmValues, which defaults to true. If you skip the label, the PodMonitor exists but Prometheus never scrapes it. Save these values to a file:
# monitoring-values.yaml
prometheus:
enabled: true
podmonitor:
enabled: true
interval: 60s
labels:
release: kube-prometheus-stack
Apply them to your existing release. --reuse-values keeps every value you set at install time and merges the new file on top:
helm upgrade cert-manager oci://quay.io/jetstack/charts/cert-manager \
--namespace cert-manager \
--version v1.21.3 \
--reuse-values \
-f monitoring-values.yaml
The PodMonitor sets jobLabel: app.kubernetes.io/name, so Prometheus takes the job label from that pod label. With default naming, controller metrics get job="cert-manager", and the webhook and cainjector get job="webhook" and job="cainjector".
If you are upgrading from cert-manager 1.20 or older, check your values first. Version 1.21 removed prometheus.servicemonitor.targetPort, prometheus.servicemonitor.path and prometheus.podmonitor.path, and renamed the controller Service port from tcp-prometheus-servicemonitor to http-metrics. The chart schema rejects unknown keys, so a values file that still sets any of them fails validation on upgrade.
Step 2: check the metrics endpoint
Before you write any alerts, confirm the controller serves the metrics you expect. Port-forward to the controller Deployment and fetch the endpoint:
kubectl -n cert-manager port-forward deployment/cert-manager 9402:9402
In a second terminal, filter the output down to the certificate metrics:
curl -s http://localhost:9402/metrics | grep '^certmanager_certificate_'
You should see a few lines per Certificate in the cluster. Then open the Prometheus UI, go to Status and then Targets, and look for targets from the cert-manager/cert-manager PodMonitor. All of them should show as up. If none appear, the release label from step 1 is the first thing to check.
Step 3: understand the certificate metrics
The controller exports these gauges for every Certificate. All of them carry name, namespace, issuer_name, issuer_kind and issuer_group labels, so you can group alerts by team namespace or by issuer.
| Metric | Value |
|---|---|
certmanager_certificate_expiration_timestamp_seconds | Unix time of status.notAfter |
certmanager_certificate_not_after_timestamp_seconds | Unix time of status.notAfter |
certmanager_certificate_not_before_timestamp_seconds | Unix time of status.notBefore |
certmanager_certificate_renewal_timestamp_seconds | Unix time of status.renewalTime |
certmanager_certificate_ready_status | 1 or 0, with a condition label |
The expiration and not-after metrics hold the same value. The not-before and not-after pair arrived in cert-manager 1.18, while the expiration metric is older, which is why many existing dashboards use it.
Watch out for one detail. When a Certificate has never been issued, its status.notAfter is empty and the controller reports the timestamp as 0. A naive "expires in less than 14 days" rule would treat that as a certificate that expired in 1970 and fire at once. Every expiry rule below filters out zero values for that reason.
The ready metric works differently. For each Certificate the controller emits three series, one each for condition="True", condition="False" and condition="Unknown". The series that matches the current Ready condition has the value 1 and the other two have 0. If the Certificate has no Ready condition yet, the Unknown series is set to 1.
The renewal timestamp comes from status.renewalTime. By default cert-manager renews two thirds of the way through a certificate's lifetime, or earlier if you set renewBefore or renewBeforePercentage. For a 90 day Let's Encrypt certificate that means renewal starts about 30 days before expiry, which gives you a wide window to catch problems.
Issuers have their own gauges, certmanager_issuer_ready_status and certmanager_clusterissuer_ready_status. They use the same three-series pattern with a condition label.
Step 4: write the alert rules
kube-prometheus-stack loads PrometheusRule resources with the same release label rule as PodMonitors, controlled by ruleSelectorNilUsesHelmValues. The rules below cover four failure modes. Each one has a for clause so a brief blip during a normal renewal does not page anyone.
# cert-manager-alerts.yaml
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: cert-manager-alerts
namespace: cert-manager
labels:
release: kube-prometheus-stack
spec:
groups:
- name: cert-manager
rules:
- alert: CertManagerAbsent
expr: absent(up{job="cert-manager"} == 1)
for: 10m
labels:
severity: critical
annotations:
summary: "No cert-manager controller is being scraped, so certificate alerts cannot fire."
- alert: CertManagerCertificateExpiringSoon
expr: |
(certmanager_certificate_expiration_timestamp_seconds > 0) - time() < 14 * 86400
for: 1h
labels:
severity: warning
annotations:
summary: "Certificate {{ $labels.namespace }}/{{ $labels.name }} expires in {{ $value | humanizeDuration }}."
- alert: CertManagerRenewalOverdue
expr: |
(certmanager_certificate_renewal_timestamp_seconds > 0) < time() - 3600
for: 1h
labels:
severity: warning
annotations:
summary: "Certificate {{ $labels.namespace }}/{{ $labels.name }} passed its renewal time more than an hour ago."
- alert: CertManagerCertificateNotReady
expr: |
max by (namespace, name, issuer_name, issuer_kind) (certmanager_certificate_ready_status{condition!="True"}) == 1
for: 15m
labels:
severity: warning
annotations:
summary: "Certificate {{ $labels.namespace }}/{{ $labels.name }} is not Ready."
- alert: CertManagerIssuerNotReady
expr: |
max by (namespace, name) (certmanager_issuer_ready_status{condition!="True"}) == 1
or
max by (name) (certmanager_clusterissuer_ready_status{condition!="True"}) == 1
for: 15m
labels:
severity: warning
annotations:
summary: "Issuer {{ $labels.name }} is not Ready."
Apply it:
kubectl apply -f cert-manager-alerts.yaml
Here is why each rule looks the way it does.
CertManagerAbsent guards the other rules. If the controller is down or Prometheus loses the target, the certificate metrics vanish, and an alert that depends on a metric cannot fire on its own. absent() returns a value only when no matching series exists, which turns silence into an alert.
CertManagerCertificateExpiringSoon subtracts the current time from the expiry timestamp and compares the result to 14 days. The > 0 filter drops never-issued certificates. Because the default renewal window for a 90 day certificate is about 30 days, a healthy certificate should never get within 14 days of expiry. If one does, renewal has been failing for more than two weeks.
CertManagerRenewalOverdue catches the same problem earlier. Once time() passes status.renewalTime, cert-manager should have issued a new certificate and moved the renewal time forward. A renewal time that stays in the past for more than an hour means the controller tried and did not succeed. This rule usually fires weeks before the expiry rule does.
CertManagerCertificateNotReady fires when the False or Unknown series is 1 for 15 minutes. The max by drops the condition label, so a Certificate that moves from Unknown to False keeps the same alert instead of resolving one and opening another. A new Certificate is not Ready while it is first issued, so the 15 minute for clause gives ACME challenges time to complete.
CertManagerIssuerNotReady points you at the cause when many certificates fail together. A ClusterIssuer whose ACME account key Secret was deleted, for example, breaks every Certificate that uses it.
Step 5: test the alerts
An alert you have never seen fire is an alert you can't trust. The quickest test is a Certificate that points at an issuer that does not exist. cert-manager creates it, finds no Secret, and sets Ready to False with the reason DoesNotExist:
# broken-certificate.yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: alert-test
namespace: default
spec:
secretName: alert-test-tls
dnsNames:
- alert-test.example.com
issuerRef:
name: does-not-exist
kind: Issuer
kubectl apply -f broken-certificate.yaml
kubectl get certificate alert-test -n default
The READY column shows False. In the Prometheus UI, query certmanager_certificate_ready_status{name="alert-test"} and you should see the False series at 1. After 15 minutes CertManagerCertificateNotReady moves from pending to firing, and Alertmanager routes it like any other alert. The expiry rule stays quiet because the certificate was never issued and its timestamp is 0.
Delete the test Certificate when you are done. Its series disappear on the next scrape and the alert resolves:
kubectl delete certificate alert-test -n default
Where to go from here
The same metrics make a good dashboard. A table of (certmanager_certificate_expiration_timestamp_seconds > 0) - time() sorted ascending shows the certificates closest to expiry, and grouping by issuer_name shows which issuer they depend on.
The controller also exports certmanager_controller_sync_error_count and certmanager_http_acme_client_request_count. The ACME request counter has a status label, so a jump in responses with status 429 points to Let's Encrypt rate limits before any certificate is close to expiring. Once these alerts fire in a test, a stuck renewal shows up in Alertmanager weeks before the certificate expires.