Alertmanager簡介及機制_告警抑制


測試目標:客戶端node_explore停止,抑制了blackbox探測郵件告警功能。

 

客戶端安裝blackbox_exporter服務

[root@promethus blackbox_exporter]# ll

-rwxr-xr-x 1 3434 3434 14925964 3月  15 21:32 blackbox_exporter

-rw-r--r-- 1 3434 3434      629 3月  15 21:42 blackbox.yml

配置好blackbox.yml文件

[root@promethus blackbox_exporter]# vim blackbox.yml

modules:

  http_2xx:

    prober: http

  http_post_2xx:

    prober: http

    http:

      method: POST

  tcp_connect:

    prober: tcp

  pop3s_banner:

    prober: tcp

    tcp:

      query_response:

      - expect: "^+OK"

      tls: true

      tls_config:

        insecure_skip_verify: false

  icmp:

    prober: icmp

 

服務端主配置文件。

  - job_name: 'promeclient'

    scrape_interval: 15s

    file_sd_configs:

    - files:

      - /usr/local/prometheus/files/client.json

    relabel_configs:

      - source_labels: [__address__]

        target_label: host_ip

 

  - job_name: 'HTTP/TCP Health Check'

    scrape_interval: 15s

    metrics_path: /probe

    params:

      module: [http_2xx]

    file_sd_configs:

    - files:

      - /usr/local/prometheus/files/service_blackbox.json

    relabel_configs:

      - source_labels: [__param_target]

        target_label: instance

      - target_label: scraper

        replacement: blackbox-exporter

      - target_label: __address__

        replacement: 192.168.19.128:9115

      - target_label: env

        replacement: prod

 

rule_files:

  - "/usr/local/prometheus/host.rule"

  - "/usr/local/prometheus/blackbox.rules"

 

配置文件

[root@promethus files]# vim client.json

[

    {

        "targets": [

            "hongk:9100"

        ],

        "labels": {

            "project": "HK測試服務器",

            "app": "HK test",

            "scraper": "telegraf",

            "region": "SZD"

        }

    }

]

 

[root@promethus files]# vim service_blackbox.json

[

    {

        "targets": [

            "http://192.168.19.128:9093",

            "http://192.168.19.128:3000"

        ],

        "labels": {

            "app": "grafana_server/alertmanager",

            "project": "pass-regisrty",

            "scraper": "blackbox-export",

            "region": "SZD",

            "module": "http_2xx"

        }

    }

]

測試方式,正常情況下運行,先使得blackbox掛掉,然后node_explore掛掉。測試結果:當blackbox掛掉,正常顯示blackbox相關url異常,當node_explore掛掉后,郵件只顯示node_explore掛掉。達到了預期效果。

 

告警部分配置。

inhibit_rules:

  - source_match:

      job: 'promeclient'

    target_match:

      job: 'HTTP/TCP Health Check'

    equal: ['region']

 

 如上截圖顯示。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM