Join our Newsletter — 33% off our NHI Course
Home› Guides› How to Monitor Certificate Expiry with Prometheus and…
Guide Secrets Management

How to Monitor Certificate Expiry with Prometheus and Blackbox Exporter: Probes, Alerts and Coverage Checks

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 28 November 2026 14 min read
On this page

Most certificate outages are not caused by a missing renewal tool but by nobody noticing that a renewal failed until clients started rejecting the connection. Prometheus with the Blackbox Exporter gives SRE and platform teams a low-cost way to watch every TLS endpoint from the outside, the way a client sees it, and to alert days or weeks before a certificate lapses. This guide covers the exporter's TLS metrics and what each one actually measures, a working scrape and module configuration, alert rules with sensible thresholds, coverage for STARTTLS and internal services, and how to prove the monitoring itself is complete. It is written for engineers who already run Prometheus and want expiry monitoring they can trust, not a dashboard that goes quiet at the worst moment.

Key takeaways

  • Probe what clients see. The Blackbox Exporter connects to the endpoint and reads the certificate actually served, which catches a renewed certificate that was never deployed or reloaded.
  • Know which expiry metric you alert on. probe_ssl_earliest_cert_expiry is the earliest expiry of any certificate the server presented; probe_ssl_last_chain_expiry_timestamp_seconds reflects the verified chains. They answer different questions.
  • An expired certificate makes the expiry metric disappear. With verification on, a failed handshake means no TLS metrics at all, so pair the days-left alert with a probe_success alert.
  • Thresholds follow renewal cadence. With public TLS validity falling towards 47 days by March 2029, a fixed 30-day warning will soon fire on every healthy certificate. Alert on a missed renewal window instead.
  • Coverage is the real metric. Monitoring is only as good as its target list: reconcile probe targets against the certificate inventory and Certificate Transparency logs.

Where external probing fits among expiry signals

There are three places to read a certificate's expiry date, and mature setups use more than one. The Blackbox Exporter covers the first. See the How to build a TLS certificate inventory guide for building the list of what should be watched.

Signal sourceExample metricWhat it seesBlind spot
External TLS probe (Blackbox Exporter)probe_ssl_earliest_cert_expiryThe certificate a client actually receives, after load balancers, CDNs and reloadsOnly endpoints in its target list; nothing for certificates not served on a port
Issuer or controller metrics (cert-manager)certmanager_certificate_expiration_timestamp_seconds, certmanager_certificate_ready_statusWhat the controller issued and whether the Certificate resource is ReadyCannot tell whether the workload loaded the new Secret
File and secret scanning (for example the x509-certificate-exporter)Per-file or per-Secret expiry seriesCertificates at rest: TLS Secrets, ConfigMaps, PKCS#12 and JKS stores, kubeconfigs, node PKIA file on disk may not be the certificate in use

The probe is the closest to user impact, which is why it should carry the paging alert. Controller metrics are an earlier warning: cert-manager also exports certmanager_certificate_renewal_timestamp_seconds, the time renewal should happen, so a renewal that has not happened past that time is visible before the probe shows anything. See the cert-manager security guide for securing the controller itself.

The TLS metrics the Blackbox Exporter exposes

The metric names and behaviour below are taken from the exporter's source (prober/prober.go, prober/tls.go, prober/http.go and prober/crl.go) as of release 0.29.1, October 2026.

MetricType and valueHow it is calculatedUse it for
probe_ssl_earliest_cert_expiryGauge, Unix secondsThe earliest NotAfter across every certificate the server presented, leaf and intermediatesPrimary days-left alert; catches an expiring intermediate the server still sends
probe_ssl_last_chain_expiry_timestamp_secondsGauge, Unix secondsFor each verified chain, the earliest expiry in that chain; the metric is the latest of thoseCross-signed or multi-path chains where one path expires but another stays valid
probe_ssl_last_chain_infoInfo gauge (value 1) with labelsLeaf certificate labels: fingerprint_sha256, subject, issuer, subjectalternative, serialnumberDetecting a certificate change, wrong certificate served, unexpected issuer
probe_tls_version_infoInfo gauge with version labelNegotiated TLS versionSpotting endpoints still negotiating TLS 1.0 or 1.1
probe_tls_cipher_infoInfo gaugeNegotiated cipher suiteCipher policy drift
probe_http_sslGauge, 0 or 1Whether the final HTTP request used TLSCatching a redirect chain that ends on plain HTTP
probe_ssl_crl_revoked, probe_ssl_crl_stale, probe_ssl_crl_availableGauges, 0 or 1Emitted only when check_revoked: true; reports whether a certificate in the chain appears on its CRLRevocation awareness; the setting never fails the probe on its own

Two behaviours matter for alert design. First, the TLS metrics are registered only when the probe completes a TLS connection. With the default insecure_skip_verify: false, an expired or untrusted certificate fails the handshake, probe_success drops to 0, and probe_ssl_earliest_cert_expiry is simply absent from that scrape. A days-left alert alone therefore goes silent at the exact moment the certificate expires. Second, the verified-chain metric depends on verification: if you set insecure_skip_verify: true there are no verified chains to measure.

Configuring the exporter and the scrape job

The Blackbox Exporter follows the multi-target exporter pattern: Prometheus scrapes the exporter's /probe endpoint (default port 9115) and passes the real target as the target URL parameter through relabelling. A minimal module file for TLS expiry looks like this (sample values):

1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.

Sample 1
modules:
  https_cert:
    prober: http
    timeout: 10s
    http:
      method: GET
      fail_if_not_ssl: true
      preferred_ip_protocol: ip4
      tls_config:
        insecure_skip_verify: false
  tls_connect:
    prober: tcp
    timeout: 5s
    tcp:
      tls: true
  internal_tls:
    prober: tcp
    timeout: 5s
    tcp:
      tls: true
      tls_config:
        ca_file: /etc/blackbox_exporter/internal-root-ca.pem

The matching Prometheus job, adapted from the exporter's README:

Sample 1
scrape_configs:
  - job_name: blackbox_tls
    metrics_path: /probe
    params:
      module: [https_cert]
    file_sd_configs:
      - files: [/etc/prometheus/targets/tls_*.yml]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115
  - job_name: blackbox_exporter
    static_configs:
      - targets: [blackbox-exporter:9115]
  • Targets from files, not the job: file_sd_configs lets the certificate inventory or a CI job write the target list, so adding an endpoint does not need a Prometheus change. http_sd_configs and kubernetes_sd_configs are alternatives.
  • Owner labels on every target: put team, service and env labels in the target file so alerts route to the owner without a lookup.
  • SNI and virtual hosts: when probing by IP address or through DNS service discovery, the HTTP prober accepts a hostname parameter (set via __param_hostname) that sets the Host header and TLS SNI. For TCP probes use tls_config.server_name. Without the right SNI a shared front end may serve its default certificate, and you will monitor the wrong one.
  • IPv4 and IPv6: preferred_ip_protocol defaults to ip6 with fallback enabled. If a host serves different certificates on each address family, probe both explicitly with two modules.
  • Debugging: /probe?target=example.com&module=https_cert&debug=true returns the probe log, including resolved address and TLS timings.

Covering non-HTTP and internal endpoints

Expiring certificates on mail relays, LDAPS, databases and message brokers cause outages just as often as web front ends, and they are less likely to be watched.

Endpoint typeProber and settingNotes
HTTPS sites and APIshttp with fail_if_not_ssl: trueFollows redirects by default; the metrics describe the final hop
Implicit TLS services (LDAPS 636, IMAPS 993, SMTPS 465, Kafka or AMQP over TLS)tcp with tls: trueUse server_name where the certificate name differs from the target
STARTTLS services (SMTP 25 and 587, IMAP 143)tcp with a query_response sequence ending in starttls: trueThe exporter's example file includes smtp_starttls and imap_starttls modules
gRPC over TLSgrpc with tls: trueSame tls_config block
Private PKI servicesAny prober with tls_config.ca_fileTrust the internal root explicitly instead of disabling verification
Mutual TLS endpointstls_config.cert_file and key_fileThe probe client certificate is itself a credential that expires: monitor it too

Run one exporter per network zone that holds private endpoints, so the probe path matches the client path. For devices that cannot automate renewal, see Certificates for Devices That Cannot Automate.

Alert rules that stay useful as validity shrinks

The CA/Browser Forum's Ballot SC-081v3 reduces the maximum public TLS certificate validity from 398 days to 47 days in steps between March 2026 and March 2029. A static "30 days left" warning was fine for one-year certificates; on 47-day certificates renewed around day 30 it would fire for most of every certificate's life. See the Certificate Expiry Outages and 47-Day TLS Certificates Guide for the schedule and its operational effect. Let's Encrypt also ended its expiry notification emails on 4 June 2025, so teams that relied on those emails need their own signal.

Sample 1
groups:
  - name: tls-expiry
    rules:
      - record: tls:cert_days_left
        expr: (probe_ssl_earliest_cert_expiry - time()) / 86400

      - alert: TLSCertRenewalOverdue
        expr: tls:cert_days_left < 14
        for: 1h
        labels:
          severity: ticket
        annotations:
          summary: "Certificate on {{ $labels.instance }} expires in {{ $value | humanize }} days"
          runbook_url: "https://runbooks.example.internal/tls-renewal"

      - alert: TLSCertExpiryImminent
        expr: tls:cert_days_left < 3
        for: 10m
        labels:
          severity: page

      - alert: TLSProbeFailing
        expr: probe_success{job="blackbox_tls"} == 0
        for: 5m
        labels:
          severity: page
        annotations:
          summary: "TLS probe failing for {{ $labels.instance }} (expired, untrusted or unreachable)"

      - alert: TLSCertChanged
        expr: changes(probe_ssl_earliest_cert_expiry[1h]) > 0
        labels:
          severity: info
  • Set the warning just after the expected renewal point: if automation renews when about one third of the validity period remains, a certificate with clearly less than that left (for example under a quarter) has missed its renewal window. For 90-day certificates renewed at 30 days left, 14 to 20 days is a reasonable ticket threshold; review it as validity shortens. These are sample thresholds, not a standard.
  • Use for to absorb flaps: a single failed probe should not page. The for clause holds the alert pending until the condition persists; keep_firing_for stops it resolving on one good scrape.
  • Treat "changed" as informational: a fingerprint or expiry change confirms a renewal deployed. An unexpected change, such as a new issuer, deserves a look.
  • Test rules before shipping: promtool test rules runs alert rules against synthetic series, which is the cheapest way to prove the expired-certificate case pages.

Phased rollout

  1. Inventory first: export known endpoints from the certificate inventory, load balancer configuration and DNS into a target file with owner labels.
  2. Deploy one exporter and probe in debug: check a handful of targets with debug=true to confirm SNI, address family and trust are right before scaling.
  3. Record, do not alert, for a week: ship the recording rule and a dashboard, sort by days left, and fix the endpoints that are already close to expiry or failing.
  4. Enable ticket alerts, then paging: route the overdue alert to the owning team's queue first; add the paging rules once false positives are understood.
  5. Add non-HTTP and private zones: STARTTLS, LDAPS, brokers and internal CAs, each with its own exporter where the network requires it.
  6. Close the loop with coverage checks: compare targets with the inventory and with Certificate Transparency results each week.

Rollback: alert rules and target files live in version control; reverting a rule file and reloading Prometheus (SIGHUP or /-/reload when the lifecycle API is enabled) restores the previous state. Keep the probe job running while alert changes are reverted, so history is not lost.

Small and large deployments

  • Small team, tens of endpoints: a single exporter next to Prometheus, a static target file and the four rules above are enough. The main risk is the target list going stale, so put the file next to the service definitions.
  • Large estate, thousands of endpoints: generate targets from inventory or service discovery, shard probing by zone, and watch the exporter's own load (probe duration and scrape timeouts). The exporter resolves DNS on every probe without caching, so a local caching resolver reduces query volume at scale, as the README advises.
  • Probe interval: expiry changes slowly, so a 5 to 15 minute scrape interval for the TLS job is usually adequate and keeps load on the targets low; uptime probing can stay on its own faster job.
  • When probing is not enough: certificates used only by clients (mTLS client certificates, signing certificates, workload identity certificates) are never served on a port. Use issuer metrics or file and secret scanning for those, and see the Machine Identity PKI Certificate Lifecycle Guide.

Where identity fits

Every TLS server certificate is a machine credential, and an expired one is an availability failure of that identity. The monitoring stack also holds credentials of its own: client certificates and keys in tls_config for mTLS probes, and basic auth or OAuth settings in HTTP modules. Store these as files mounted from a secrets manager (cert_file, key_file, password_file) rather than inline strings in the module file, restrict who can read the exporter configuration, and remember that the exporter's /probe endpoint will connect to any target it is given, so keep it off untrusted networks. The Prometheus Security guide covers hardening the server and exporters.

Detection and measurement

  • Coverage ratio: probed endpoints divided by inventoried TLS endpoints. Target 100% for production; track the gap list by owner.
  • Minimum days left across the estate: min(tls:cert_days_left). It should stay above your renewal-overdue threshold.
  • Overdue renewals open: count of firing TLSCertRenewalOverdue alerts and their age. Each one is a failed automation.
  • Probe health: share of TLS targets with probe_success == 0, and scrape duration close to the timeout, which hides results.
  • Expiry incidents: customer-visible outages caused by expired certificates per quarter; the target is zero.
  • Legacy protocol endpoints: count by (version) (probe_tls_version_info) to find TLS 1.0 and 1.1 still negotiated.

Common failure patterns

  • Days-left alert with no failure alert: the expiry metric vanishes when the handshake fails, so the dashboard shows a gap instead of a red row. Always alert on probe_success for the TLS job.
  • Verification turned off to "make probes work": insecure_skip_verify: true hides untrusted chains and removes the verified-chain metric. Trust the internal root with ca_file instead.
  • Wrong certificate monitored: probing an IP or shared front end without SNI returns a default certificate that may be valid while the real one expires.
  • Intermediate expiry missed: alerting on leaf-only data from another tool while the server still sends an expiring intermediate. The earliest-expiry metric covers every presented certificate.
  • Stale target list: new hostnames go live without being added. The fix is generated targets plus a weekly comparison with Certificate Transparency; see the Certificate Transparency Monitoring Guide for Web Teams.
  • Treating a CRL hit as a probe failure: check_revoked only reports; alert on probe_ssl_crl_revoked == 1 explicitly if revocation matters.

Framework mapping

FrameworkReferenceHow this monitoring supports it
NIST SP 800-53 Rev 5SC-17 Public Key Infrastructure CertificatesEvidence that issued certificates are tracked through their validity period
NIST SP 800-53 Rev 5SI-4 System Monitoring; CA-7 Continuous MonitoringAutomated, continuous checking of a security-relevant state with alerting
NIST SP 800-53 Rev 5CM-8 System Component InventoryTarget lists reconciled with the component and certificate inventory
NIST CSF 2.0ID.AM-08; DE.CM-09Lifecycle management of certificates as assets; monitoring of runtime environments

Practitioner checklist

  • Generate probe targets from the certificate inventory, with team, service and environment labels.
  • Keep insecure_skip_verify: false; trust private roots with ca_file.
  • Set SNI correctly with the hostname parameter or server_name for every shared front end.
  • Record days left from probe_ssl_earliest_cert_expiry and alert on a missed renewal window, not a fixed 30 days.
  • Alert on probe_success == 0 for the TLS job so an expired certificate still pages.
  • Add STARTTLS, LDAPS, broker and gRPC endpoints with TCP or gRPC modules.
  • Monitor the probe's own client certificates and store all probe credentials as mounted files.
  • Unit-test alert rules with promtool test rules, including the expired case.
  • Compare targets with Certificate Transparency results and the inventory every week.

Standards and references

Related NHI Mgmt Group resources: Expired Certificate Outage Troubleshooting Guide · Certificate Expiry Outage Tabletop Scenario · ACME and Automated Certificate Management Guide · Certificate Inventory Register Template

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.