如何在Prometheus SSL过期告警规则中排除指定主机并保留监控
解决SSL证书过期告警排除指定目标的问题
只需修改alert_rules.yml中的告警表达式,通过标签过滤排除google.com即可,无需改动prometheus.yml中的监控目标配置:
修改后的alert_rules.yml内容:
groups: - name: http_alerts rules: - alert: ssl expire in 30 days expr: probe_ssl_earliest_cert_expiry - time() < 86400 * 30 and instance != "https://google.com" for: 5m labels: severity: warning annotations: summary: "SSL certificate will expire soon on (instance {{ $labels.instance }})" description: "SSL certificate expires in 30 days\n VALUE = {{ $value }}\n LABELS: {{ $labels }}"
说明
从prometheus.yml的relabel_configs配置可以看到,instance标签的值对应监控目标的地址(即https://google.com)。在告警表达式中添加and instance != "https://google.com",就能让Prometheus在评估SSL过期告警时自动排除该目标,同时不影响该目标的其他监控指标采集。
内容的提问来源于stack exchange,提问作者Shubham Gupta
相关产品推荐
相关产品推荐

