Giter VIP home page Giter VIP logo

alertmanager-webhook-wechat's Introduction

Alertmanager-Webhook-Wechat

Promethues alertmanager webhook wechat 实现

Usage

编译得到可执行二进制文件,即daemon-systemd下的二进制文件,创建服务器的systemd进程服务。

测试运行可使用:./alertmanager-webhook-wechat-linux --RobotKey="xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxx

RobotKey即为企业微信生成机器人的key值,也是项目初始化设置的default key。

编辑alertmanager config或者prometheus config

alertmanager config

sudo vim /etc/alertmanager/alertmanager.yml
global:
  resolve_timeout: 5m #处理超时时间,默认为5min
route:
  group_by: ['alertname']
  group_wait: 3s
  group_interval: 5s
  repeat_interval: 5m
  receiver: 'web.hook'
receivers:
  - name: 'web.hook'
    webhook_configs:
    - url: 'http://localhost:6666/webhook?key=xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxx'

prometheus config

sudo vim /etc/prometheus/alert.rules.yml
groups:
- name: alert.rules
  rules:
    - alert: HostOutOfDiskSpace
      expr: (node_filesystem_avail{mountpoint="/"}  * 100) / node_filesystem_size{mountpoint="/"} < 50
      for: 1s
      labels:
        severity: warning
     annotations:
       summary: "Host out of disk space (instance {{ $labels.instance }})"
       description: "Disk is almost full (< 50% left)\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"
       wechatRobot: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9a81393c-a141-4920-9e19-169a445db908"

test

  {
    "receiver": "web.hook",
    "status": "firing",
    "alerts": [
      {
        "status": "firing",
        "labels": {
          "alertname": "HostOutOfDiskSpace",
          "instance": "localhost:9200",
          "severity": "warning"
        },
        "annotations": {
          "info": "Test message,ignore",
          "description": "Disk is almost full (< 50% left)
VALUE = 18.87424590841387
LABELS: map[mountpoint:/ device:/dev/mapper/ubuntu--vg-ubuntu--lv fstype:ext4 instance:localhost:9200 job:node_exporter_metrics]",
          "summary": "Host out of disk space (instance localhost:9200)"
        },
        "startsAt": "2021-04-14T11:33:33.6639785927Z",
        "endsAt": "0001-01-01T00:00:00Z",
        "generatorURL": "warning"
      }
    ],
    "groupLabels": {
      "alertname": "HostOutOfDiskSpace"
    },
    "commonLabels": {
      "alertname": "HostOutOfDiskSpace",
      "instance": "localhost:9200"
    },
    "commonAnnotations": {
      "info": "Test message,ignore",
      "summary": "Host out of disk space (instance localhost:9200)"
    },
    "externalURL": "http://localhost:9093",
    "version": "4",
    "groupKey": "{}/{alertname=~\"^(?:HostOutOfDiskSpace.*)$\"}:{alertname=\"HostOutOfDiskSpace\"}"
  }'

alertmanager-webhook-wechat's People

Contributors

pzryesht avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.