How can I exclude any hosts in prometheus alerting rules

37 views Asked by At

Here is my alert_rules.yml file

groups:
- name: http_alerts
  rules:
  - alert: ssl 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: "SSL certificate expires in 30 days\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"

and here is my prometheus.yml file

global:
  scrape_interval:     15s
  evaluation_interval: 15s

rule_files:
  - 'alert.rules'

alerting:
  alertmanagers:
  - scheme: http
    static_configs:
    - targets: 
      - 'alertmanager:9093'

scrape_configs:
  - job_name: 'blackbox_http'
    scrape_timeout: 30s
    scrape_interval: 30s
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - https://google.com
        - https://github.com

    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: blackbox:9115

I want to exclude target google.com from alert_rules.yml for the certificate expiry checks. I want to keep google.com target in prometheus.yml as this target needs to be monitored for other use cases.

0

There are 0 answers