You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 03:25:00