「Alertmanager」- 发送测试通知

  CREATE BY JENKINSBOT

问题描述

当进行 Alertmanager 设置之后,我们希望可以进行测试,以验证配置已生效。

该笔记将记录:在 Shell 中,调用 Alertmanager 服务,并发送通知的方法。

解决方法

#!/usr/bin/env bash

alerts_message='[
  {
    "labels": {
       "alertname": "DiskRunningFull",
       "dev": "sda1",
       "instance": "example1"
     },
     "annotations": {
        "info": "The disk sda1 is running full",
        "summary": "please check the instance example1"
      }
  },
  {
    "labels": {
       "alertname": "DiskRunningFull",
       "dev": "sda2",
       "instance": "example1"
     },
     "annotations": {
        "info": "The disk sda2 is running full",
        "summary": "please check the instance example1",
        "runbook": "the following link http://test-url should be clickable"
      }
  }
]'

curl -XPOST -d"$alerts_message" http://127.0.0.1:9093/api/v1/alerts

参考文献

send a dummy alert to prometheus-alertmanager · GitHub
alertmanager/send_alerts.sh at master · prometheus/alertmanager · GitHub