grafana alert报警功能介绍

点点圈 提交于 2019-11-29 07:37:08

Grafana从4.0开始新增预警功能,下面简单介绍一下。Grafana告警设置分为两部分:

  1. Notification配置
  2. Alert配置
1、Notification配置:其实就是配置告警途径,Grafana支持多种方式的告警:Email、webhook等。由于webhook比较通用,我们重点说下如何配置webhook。


之后点击New Channel进入配置页面: 



保存后即可。
2、alert配置:
1)进入dashboards,选择一个pannel,然后edit,进入alert选项卡,添加alert配置。


在alert config页面设置报警阈值,和报警条件等。
2)设置notification:

然后再notification页面设置上一步配置的notification,以及报警信息。

3、编写webhook接口:
1)grafana发送的数据结构如下:
{
    "ruleName": "webhooktest",
    "state": "alerting",
    "message": "This is my webhook send test ,my target is to get the alert data.",
    "ruleId": 4,
    "title": "[Alerting] webhooktest",
    "ruleUrl": "http://localhost:3000/dashboard/db/webhookdatatest?fullscreen&edit&tab=alert&panelId=1&orgId=1",
    "evalMatches": [
        {
            "metric": "mytest.age { myName: pangkun2 }",
            "value": 27,
            "tags": null
        },
        {
            "metric": "mytest.age { myName: pangkun3 }",
            "value": 26,
            "tags": null
        }
    ]
}
2)在接口中,可以通过request.getparamater("key")来获取上面结构中的数据





易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!