案例
监控https证书有效期
依赖
Blackbox Exporter
1️⃣ blackbox-exporter 配置
modules:
https_tls:
prober: http
timeout: 5s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2"]
tls_config:
insecure_skip_verify: false
- job_name: 'blackbox-https'
metrics_path: /probe
params:
module: [https_tls]
static_configs:
- targets:
- https://example.com
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115
probe_ssl_earliest_cert_expiry
(probe_ssl_earliest_cert_expiry - time()) / 86400
groups:
- name: tls证书监控
rules:
- alert: TLS证书即将过期
expr: (probe_ssl_earliest_cert_expiry{instance="https://catpd.cn"} - time()) / 86400 < 90
for: 10s
labels:
severity: warning
annotations:
summary: "HTTPS 证书即将过期"
description: |
域名:https://catpd.cn
证书剩余有效期:{{ printf "%.1f" $value }} 天