最近研究了prometheus+grafana的系统监控,使用grafana的报警功能,grafana支持很多种通知渠道,下文记录使用到的几种notification channels,分别是email,kafka和webhook

官网文档 http://docs.grafana.org/alerting/notifications/

  • 发送邮件

  修改smtp,找到%GRAFANA_HOME%/conf/defaults.ini(注windows环境)

[smtp]
enabled = true #开户email发送配置
host = smtp.xxx.com:25 #此处需要加上端口号
user =username@xxx.com #邮箱账号
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password =1234567890 #邮箱密码
cert_file =
key_file =
skip_verify = true #跳过校验
from_address = admin@grafana.localhost
from_name = Grafana
ehlo_identity =

  • kafka

向kafka发送消息,需要kafka REST proxy,我使用的中间件是confluent,安装过程没什么特别之外,配置(confluent_home/etc/kafka-rest/kafka-rest.properties)如下

#id=kafka-rest-test-server
#schema.registry.url=http://localhost:8081
#zookeeper.connect=localhost:2181
#bootstrap.servers=PLAINTEXT://localhost:9092
zookeeper.connect=xx.xx.xx.xx:2181
bootstrap.servers=PLAINTEXT://xx.xx.xx.xx:9092

启用kafka-rest服务

bin/kafka-rest-start ../etc/kafka-rest/kafka-rest.properties

添加notification channels

点击 “send test”按钮,浏览kafka-rest服务,alert-gateway-test-1已经在kafka topic里了,开发者可消费kafka的消息,进行后续(自定义)处理

  • webhook(推荐)

回调参数

{
"title": "My alert",
"ruleId": 1,
"ruleName": "Load peaking!",
"ruleUrl": "http://url.to.grafana/db/dashboard/my_dashboard?panelId=2",
"state": "alerting",
"imageUrl": "http://s3.image.url",
"message": "Load is peaking. Make sure the traffic is real and spin up more webfronts",
"evalMatches": [
{
"metric": "requests",
"tags": {},
"value": 122
}
]
}

更详细说明,可以参考官网http://docs.grafana.org/alerting/notifications/

最新文章

  1. java中与数据库的连接
  2. 在Win2008上运行ASP.NET 1.1程序
  3. 部署应用程序QQ
  4. [Practical Git] Switching between current branch and last checkout branch
  5. IOS分类(Category)
  6. xss框架(二)基础框架实现
  7. Day4:T1小技巧(类似于指针操作)T2搜索+小细节
  8. 查看Tomcat版本
  9. Laravel 5 框架性能优化技巧
  10. c语言基础学习03
  11. thinphp验证码的简单实现
  12. Git常用简介
  13. 【BZOJ5499】[2019省队联测]春节十二响(贪心)
  14. webpack学习记录 - 学习webpack-dev-server(三)
  15. 【转】SpringBoot——web项目下读取classpath下的文件心得
  16. 1、Shiro 安全框架与Spring 整合详解
  17. 一个简单的通讯服务框架(大家发表意见一起研究)JAVA版本
  18. css初探
  19. IntellJ IDEA 对于 Spring Boot2.0.2 配置文件application.properties 配置
  20. 距离LCA离线算法Tarjan + dfs + 并查集

热门文章

  1. layer.open弹出窗口后在子页面修改弹窗的title
  2. 解决spyder、Jupyter Notebook 打不开
  3. 单例模式实例&多线程应用
  4. Spring3基础原理解析
  5. listener.starting()源码探究
  6. python with as的用法
  7. LeetCode【101. 对称二叉树】
  8. linux centos 中访问linux 共享文件方法
  9. Linq to SQL -- Union All、Union、Intersect和Top、Bottom和Paging和SqlMethods
  10. Hexo NexT主题/cnblog等博客增加点击出现红心的特效