监控ssl证书到期时间
[root@iZbp1a16m3y5y71tdh7isyZ config]# cat prometheus.yml
····
- job_name: 'blackbox_http_2xx'
scrape_interval: 30s
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- https://xxxxxxxxxxxx
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115
[root@iZbp1a16m3y5y71tdh7isyZ rules]# cat blackbox_rules.yaml
groups:
- name: ssl_expiry
rules:
- alert: Ssl Cert Will Expire in 30 days
expr: probe_ssl_earliest_cert_expiry - time() < 86400 * 30
for: 5m
labels:
severity: warning
annotations:
summary: "SSL certificate will expire soon on (instance {{ $labels.instance }})"
description: "https 证书还剩 30 days\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"