Monitoring Domain Expiration with Prometheus, black_exporter, and Grafana
This guide demonstrates how to use Docker, Prometheus, black_exporter, and Grafana to monitor website status codes, response times, and especially certificate expiration dates by configuring exporters, Prometheus scrape jobs, and alerting rules for domain health.
Web monitoring involves tracking specific URLs or interfaces, and this article focuses on practical monitoring of certificate expiration using Docker, Prometheus, black_exporter, and Grafana.
1. Docker installation [root@hd03]# docker run -d --restart=always --name domain_exporter -p 9222:9222 caarlos0/domain_exporter
2. Prometheus configuration Append the following job definition to prometheus.yml :
- job_name: domain
scrape_interval: 1h
metrics_path: /probe
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 192.168.18.69:9222
static_configs:
- targets:
- qq.com
- baidu.cnAfter saving, reload Prometheus configuration:
[root@hd03]# curl -X POST http://localhost:9090/-/reload3. Add domain alert rules Create prometheus/rules/domain.yml with the following alerts:
groups:
- name: domain
rules:
- alert: 域名检测失败
expr: domain_probe_success == 0
for: 2h
labels:
severity: warning
annotations:
summary: '{{ $labels.instance }}'
description: '{{ $labels.domain }}域名检测失败'
- alert: 域名过期
expr: domain_expiry_days < 30
for: 2h
labels:
severity: warning
annotations:
summary: '{{ $labels.instance }}'
description: '{{ $labels.domain }}将在30天后过期'
- alert: 域名过期
expr: domain_expiry_days < 5
for: 2h
labels:
severity: page
annotations:
summary: '{{ $labels.instance }}'
description: '{{ $labels.domain }}将在5天后过期'Reload Prometheus again to apply the new rules. With these configurations, Grafana can visualize the metrics and trigger alerts when a domain becomes unreachable or its certificate is about to expire.
The article concludes with a reminder to like, share, and follow for more technical content.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.