Comments (12)
@dellnoantechnp 是最新的分支代码吗?
用新版本容器镜像 feiyu563/prometheus-alert:master 测试通过。🎉🎉
这个版本完全可以打一个 v4.9.1
的镜像 tag,如果按照 Github 上 Release 的4.9版本去 dockerhub 找容器,不管tag 是 v4.9
还是 latest
都是有问题的版本,容易造成误导。
....
[ag-demo]
wxurl=wxurl1,wxurl2
ddurl=ddurl1,ddurl1,
fsurl=fsurl1
email=email1,
phone=phone1,phone2
groupid=groupid1
[ag-alert]
ddurl=ddurl
.....
ps: 如果使用
alertgroup
告警组方式进行接口调用,配置文件如上,那么在接口调用这里应该使用 ag-alert
中的alert
名称。
例如curl -v 'http://xxxx:8080/prometheusalert?type=dd&tpl=prometheus-dd&alertgroup=alert'
from prometheusalert.
仅自定义模板有问题,默认模板正常。
from prometheusalert.
我测试了一下,自定义模板传过来的 ddurl
上没有 secret
参数,所以程序判断为空了。
看下自定义钉钉模板传过来的 secret
参数为什么消失了?
from prometheusalert.
ddurl=xxx&secret=xxx
在 beego 的 input.Get()
是两个参数了,所以并不能取到 &secret=xxx
的值。
from prometheusalert.
临时解决方法有,这两个方法对传递多个钉钉地址、有加签和不加签名都不会有影响。
1,使用告警组来配置地址,在参数上使用 alertgroup=告警组
这种方式
2,或者,将 &
符号替换为 %26
编码,如 ddurl=xxx%26secret=xxx
让程序判断它们是一起的来处理它。
# 1 使用方法
http://xxx:8080/prometheusalert?type=dd&tpl=prometheus-dd&alertgroup=告警组&at=xxx
# 2 使用方法
http://xxx:8080/prometheusalert?type=dd&tpl=prometheus-dd&ddurl=xxx%26secret=xxx
from prometheusalert.
所以在自定义模板的参数中,需要对 ddurl 和 secret 分别取值,然后组装成一个字符串,再将值给 ddurl。
ddurl := beego.Input().Get("ddurl")
secret := beego.Input().Get("secret")
if len(secret) != 0 {
ddurl = ddurl + "&secret=" secret
}
from prometheusalert.
但是这样又有一个问题,在自定义模板 URL 参数的 ddurl 里面有多个地址,有的加签,有的不加签名。上面的处理又会有问题。
上面的示例只适合单个地址,处理多个地址还是有问题,因此暂时不提修改代码,仅更新文档。
from prometheusalert.
建议先使用上面的临时方法。
from prometheusalert.
@feiyu563 看作者有啥好的想法没有。
from prometheusalert.
临时解决方法有,这两个方法对传递多个钉钉地址、有加签和不加签名都不会有影响。
1,使用告警组来配置地址,在参数上使用
alertgroup=告警组
这种方式 2,或者,将&
符号替换为%26
编码,如ddurl=xxx%26secret=xxx
让程序判断它们是一起的来处理它。# 1 使用方法 http://xxx:8080/prometheusalert?type=dd&tpl=prometheus-dd&alertgroup=告警组&at=xxx # 2 使用方法 http://xxx:8080/prometheusalert?type=dd&tpl=prometheus-dd&ddurl=xxx%26secret=xxx
webhook_configs“:
目前这样可以了,不过这操作有点* 太鬼畜了
同时,谢谢你!
from prometheusalert.
在 url 中指定 alertgroup 发送不成功:
curl -v 'http://10.103.41.159:8080/prometheusalert?type=dd&tpl=prometheus-dd&alertgroup=ag-alert' -H 'Content-type: application/json' -X POST -d '{"receiver":"sms","status":"firing","alerts":[{"status":"firing","labels":{"alertname":"ProbeFailure","instance":"https://server.example.org","job":"http_checks","monitor":"master","severity":"critical"},"annotations":{"description":"Instance https://server.example.org has been down for over 5m. Job: http_checks","summary":"BlackBox Probe Failure: https://server.example.org"},"startsAt":"2023-02-06T13:08:45.828Z","endsAt":"0001-01-01T00:00:00Z","generatorURL":"http://prometheus.example.org:9090/graph?g0.expr=probe_success+%3D%3D+0\\u0026g0.tab=1ArgoCD","fingerprint":"1a30ba71cca2921f"}],"groupLabels":{"alertname":"ProbeFailure"},"commonLabels":{"alertname":"ProbeFailure","instance":"https://server.example.org","job":"http_checks","monitor":"master","severity":"critical"},"commonAnnotations":{"description":"Instance https://server.example.org has been down for over 5m. Job: http_checks","summary":"BlackBox Probe Failure: https://server.example.org"},"externalURL":"http://prometheus.example.org:9093","version":"4","groupKey":"{}/{severity=\"critical\"}:{alertname=\"ProbeFailure\"}","truncatedAlerts":0}'
返回:
{\"errcode\":310000,\"errmsg\":\"description:机器人发送签名不匹配;solution:请确认签名和生成签名的时间戳必须都放在调用的网址中,请确认机器人的密钥加密和填写正确
使用第二种方式,替换 &
为 %26
字符:
curl -v 'http://10.103.41.159:8080/prometheusalert?type=dd&tpl=prometheus-dd&ddurl=https://oapi.dingtalk.com/robot/send?access_token=9e67xxxxxx%26secret=SECxxxxxxxxx' -H 'Content-type: application/json' -X POST -d '{"receiver":"sms","status":"firing","alerts":[{"status":"firing","labels":{"alertname":"ProbeFailure","instance":"https://server.example.org","job":"http_checks","monitor":"master","severity":"critical"},"annotations":{"description":"Instance https://server.example.org has been down for over 5m. Job: http_checks","summary":"BlackBox Probe Failure: https://server.example.org"},"startsAt":"2024-02-22T13:48:45.828Z","endsAt":"0001-01-01T00:00:00Z","generatorURL":"http://prometheus.example.org:9090/graph?g0.expr=probe_success+%3D%3D+0\\u0026g0.tab=1ArgoCD","fingerprint":"1a30ba71cca2921f"}],"groupLabels":{"alertname":"ProbeFailure"},"commonLabels":{"alertname":"ProbeFailure","instance":"https://server.example.org","job":"http_checks","monitor":"master","severity":"critical"},"commonAnnotations":{"description":"Instance https://server.example.org has been down for over 5m. Job: http_checks","summary":"BlackBox Probe Failure: https://server.example.org"},"externalURL":"http://prometheus.example.org:9093","version":"4","groupKey":"{}/{severity=\"critical\"}:{alertname=\"ProbeFailure\"}","truncatedAlerts":0}'
返回:
{\"errcode\":310000,\"errmsg\":\"description:机器人发送签名不匹配;solution:请确认签名和生成签名的时间戳必须都放在调用的网址中,请确认机器人的密钥加密和填写正确;link:请参考本接口对应文档获得具体要求 .....
from prometheusalert.
@dellnoantechnp 是最新的分支代码吗?
from prometheusalert.
Related Issues (20)
- 飞书告警模板能测试成功,但告警测试中的飞书告警测试有问题,请求帮助 HOT 1
- PrometheusAlert支持发送图片吗?
- Docker容器环境变量配置不生效
- prometheusalert可以代替alertmanager嘛 HOT 1
- 飞书v2告警无法通过飞书用户邮箱 @某人 无法显示 HOT 1
- 如何将同类型的告警整合成一个消息发出来呢 HOT 2
- 请问是否支持飞书机器人@某人或@全员 HOT 2
- 阿里云云监控告警接收空消息问题 HOT 2
- 请问是否支持飞书机器人动态的@某人
- PrometheusAlert发送告警到飞书/钉钉等, 如何自定义标题信息?
- response不是json格式的数据
- 钉钉修改配置&为%26加签也不成功 HOT 1
- GetTimeDuration持续时间计算不对
- 发送阿里云短信告警提示错误
- 模板中变量的值在哪里能修改吗? HOT 3
- Feishu 报警无法@用户
- prometheusAlert Grafana报警记录面板 HOT 2
- 多条告警不能汇聚,导致webhook被限流 HOT 2
- 转换Prometheus,graylog告警消息的时区为CST时区,没有生效 HOT 1
- 微信应用需要增添代理设置
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prometheusalert.