prometheus + alertmanager + PrometheusAlert
要达到的效果 , 短信告警 + 解除告警 (可以自定义内容)

一、阿里云短信签名及模板设置



有4个信息
AccessKey : ALY_DX_AccessKeyId=xxxxxxxxxxx
Secret : ALY_DX_AccessSecret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
签名: : ALY_DX_SignName=XXXXX
模板ID : ALY_DX_Template=SMS_2XXXXXXXX

二、prometheus + alertmanager 前期环境

见之前文档
prometheus 邮件告警
https://blog.csdn.net/oToyix/article/details/120160633

prometheus process-export进程监控
https://blog.csdn.net/oToyix/article/details/120176825

三、短信告警

1、alertmanager配置,调用PrometheusAlert

global:resolve_timeout: 5mroute:group_by: ['laertname','severity','namespace']group_wait: 10sgroup_interval: 10srepeat_interval: 10sreceiver: 'prometheusalert-phone'routes:- receiver: 'prometheusalert-phone'group_wait: 10smatch:level: '1'group_interval: 15srepeat_interval: 1m
receivers:
- name: 'prometheusalert-phone'webhook_configs:- url: 'http://192.168.0.59:8080/prometheusalert?type=alydx&tpl=ali-phone&phone=18627967213'
#  - url: 'http://192.168.0.59:8080/prometheus/alert'send_resolved: true

2、PrometheusAlert规则
下载安装PrometheusAlert

wget -c https://github.com/feiyu563/PrometheusAlert/releases/download/v4.4.0/linux.zip
unzip linux.zip
mv linux PrometheusAlert
cd conf/
cp app.conf{,.bak}
vim app.conf
chmod a+x PrometheusAlert
nohup ./PrometheusAlert &
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload

PrometheusAlert配置文件
app.conf

#---------------------↓全局配置-----------------------
appname = PrometheusAlert
#登录用户名
login_user=prometheusalert
#登录密码
login_password=prometheusalert
#监听地址
httpaddr = "0.0.0.0"
#监听端口
httpport = 8080
runmode = dev
#设置代理 proxy = http://123.123.123.123:8080
proxy =
#开启JSON请求
copyrequestbody = true
#告警消息标题
title=PrometheusAlert
#链接到告警平台地址
GraylogAlerturl=http://graylog.org
#钉钉告警 告警logo图标地址
logourl=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png
#钉钉告警 恢复logo图标地址
rlogourl=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png
#短信告警级别(等于3就进行短信告警) 告警级别定义 0 信息,1 警告,2 一般严重,3 严重,4 灾难
messagelevel=1
#电话告警级别(等于4就进行语音告警) 告警级别定义 0 信息,1 警告,2 一般严重,3 严重,4 灾难
phonecalllevel=4
#默认拨打号码(页面测试短信和电话功能需要配置此项)
defaultphone=18627967217#---------------------↓阿里云接口-----------------------
#是否开启阿里云短信告警通道,可同时开始多个通道0为关闭,1为开启
open-alydx=1
#阿里云短信主账号AccessKey的ID
ALY_DX_AccessKeyId=xxxxxxxxxxx
#阿里云短信接口密钥
ALY_DX_AccessSecret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ALY_DX_AccessSecret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#阿里云短信签名名称
ALY_DX_SignName=otoyix
#阿里云短信模板ID
ALY_DX_Template=SMS_224350085

PrometheusAlert添加阿里云模板

http://192.168.0.59:8080/

{{ range $k,$v:=.alerts }}{{if eq $v.status "resolved"}}
云服务器-恢复通知
名称:{{$v.labels.alertname}}
组:{{$v.labels.app}}
实例:{{$v.labels.instance}}
服务:{{$v.labels.groupname}}
时间:{{$v.endsAt}}(时间 +8小时)
注:{{$v.annotations.description}}
{{else}}
云服务器-故障告警通知
名称:{{$v.labels.alertname}}
组:{{$v.labels.app}}
实例:{{$v.labels.instance}}
服务:{{$v.labels.groupname}}
时间:{{$v.endsAt}}(时间 +8小时)
注:{{$v.annotations.description}}
{{end}}
{{ end }}

json内容

{"receiver":"prometheusalert-phone","status":"resolved","alerts":[{"status":"resolved","labels":{"alertname":"InproessDown","app":"node-process","groupname":"map[:mysqld]","instance":"192.168.0.63:9256","job":"process","severity":"critical"},"annotations":{"description":"process has been down for more than 1 m .","title":"process down"},"startsAt":"2021-09-15T08:09:48.853Z","endsAt":"2021-09-15T08:10:18.853Z","generatorURL":"http://localhost.localdomain:9090/graph?g0.expr=namedprocess_namegroup_num_procs+%3C+1\u0026g0.tab=1","fingerprint":"02d5be47b4cad419"}],"groupLabels":{"severity":"critical"},"commonLabels":{"alertname":"InproessDown","app":"node-process","groupname":"map[:mysqld]","instance":"192.168.0.63:9256","job":"process","severity":"critical"},"commonAnnotations":{"description":"process has been down for more than 1 m .","title":"process down"},"externalURL":"http://localhost.localdomain:9093","version":"4","groupKey":"{}:{severity=\"critical\"}","truncatedAlerts":0}

四、告警测试

如,停止mysql服务后 再 重启

注:
模板这里可以加上时间

开始时间: {{$v.startsAt}}
结束时间: {{$v.endsAt}}

------------------------end

prometheus 阿里云短信告警相关推荐

  1. Prometheus和Grafana告警服务创建与对接腾讯云短信告警平台(prometheus_alert)

    前言 在一个监控系统中,如果说数据链路是她的骨架,那么告警通知服务就是他的灵魂!所有的监控服务都是为了能够及时通知出来,减少人工查询状态,及时发现问题,避免不必要的大规模故障,为企业政府省钱,和保证安 ...

  2. Zabbix 3.4.3 使用阿里云短信服务进行报警

    一.阿里云短信服务 有时候微信报警或者邮寄报警我们可能会有遗忘,今天我主要介绍使用阿里云的短信服务进行短信报警. 1.1.首先开通阿里云短信服务 1.2 创建签名 签名用途选择:公众号或小程序的全称或 ...

  3. 阿里云 短信服务——开启验证码防盗刷监控

    阿里云 短信服务--短信发送频率限制 前言 系列博客 开启验证码防盗刷监控 操作步骤 添加联系人 补充(发送总量阈值和套餐包预警值) 如果博主的文章对您有所帮助,可以评论.点赞.收藏,支持一下博主!! ...

  4. 微信小程序云开发,使用阿里云短信服务,搜索员工生日定期发送短信。

    相关API文档地址: 阿里云短信服务API文档地址 小程序云开发云函数正则匹配API文档地址 小程序云开发云函数定时触发器 1.登录阿里云,购买短信服务并添加签名和模板 2., 登录阿里云,鼠标放在右 ...

  5. 阿里云短信验证解决方案(java版)(redis存储)

    阿里云短信验证解决方案(java版)(redis存储) 参考文章: (1)阿里云短信验证解决方案(java版)(redis存储) (2)https://www.cnblogs.com/Amos-Tur ...

  6. 阿里云短信发送触发天级流量及解决办法

    前言 今天小项目里引入了阿里云短信.调试过程中,突然不发短信了.发现接口返回信息,触发天级流量限制.以下是原因和解决办法. 原因 短信发送有默认的频率限制 限制如下: 短信验证码 :使用同一个签名,对 ...

  7. legend3---PHP使用阿里云短信服务

    legend3---PHP使用阿里云短信服务 一.总结 一句话总结: 使用步骤照官方文档,代码拷贝即可 1.php使用阿里云短信服务的步骤? 入驻阿里云->开通短信服务->获取Access ...

  8. 阿里云短信官方的java示例是错误的

    阿里云短信前身是大鱼,现在移入了阿里云短信. 下载了官方sdk发现一大坨.我不需要啊. 下面自己精简一下,写一个. 谁知道一直提示签名不正确. 看了官网的示例然后对比了一下官方的php sdk 这,j ...

  9. python 阿里云短信接口_阿里云短信PythonSDK的用法

    阿里云知识 阿里云短信PythonSDK的用法 阿里云短信PythonSDK的用法示例代码 # coding=utf-8 from jdcloud_sdk.core.credential import ...

最新文章

  1. 在 BT5 下对 Red Hat Enterprise Linux 5.4 的一次***测试
  2. 微软提出第一个端到端的Video Captioning方法:SWIN BERT,涨点显著!
  3. jQuery first()和last()函数示例
  4. 嫌学校 App烂,极客父母做了开源版本
  5. QUIC协议学习记录
  6. 我们不知道我们不知道:用同化项目做网络安全
  7. 用Python实现温度转换程序
  8. Hacker(15)----嗅探原理
  9. Url Rewrite Filter 使用全攻略
  10. 新办的卡为什么显示无服务器,为什么插入卡后显示无服务,有时有有时又没有?...
  11. cpu、socket、core、thread 等术语之间的关系
  12. 简要分析网络三层架构(核心层、汇聚层、接入层)
  13. 嵌入式电路中的BUCK VS LDO【转】
  14. 使用Pandas绘制股票均线
  15. 苹果闪退解决方法_逃离塔科夫游戏闪退解决方法
  16. 【读书笔记】万物原理——打开客观世界与主观情感的大门
  17. Java项目源代码S2SH校园BBS论坛系统
  18. 关于windeployqt 打包程序诸多问题总结(经验之谈)
  19. cad字体 草体_50种免费的草书和手写字体,丰富您的设计
  20. android wifi 文件共享,如何在Windows和Android之间无线共享文件 | MOS86

热门文章

  1. 斐波那契数列+pyton
  2. 用 Telegram bot 搭个消息提醒服务
  3. Aurelia历险记:创建自定义PDF查看器
  4. D. Serval and Rooted Tree
  5. 团队协作方法之:高效使用任务故事墙
  6. JAVA 实现《坦克大战》游戏|CSDN创作打卡
  7. 中国魔芋胶行业研究与投资前景预测报告(2022版)
  8. 阿里云储道深度解析存储系统设计——NVMe SSD性能影响因素一探究竟
  9. 影响利率风险结构的因素_利率风险结构是什么意思 影响利率的因素
  10. 服装家纺生产制造执行系统——MES