关联博客:
Grafana配置告警
prom相关
prom这台机器,/data/alermanager
cat debug.json
[{“labels”:{“alertname”:”TestAlert3”,”severity”:”testtg”}}]
http -v POST http://localhost:9093/api/v2/alerts < debug.json
cat debugopenobserver.json
1 2 3 4 5 6 7 8 9 10 11 12 13
| [{ "labels": { "alertname": "testing", "stream": "hello", "organization": "myteam", "alerttype": "warning", "severity": "page" }, "annotations": { "summary": "testing testing" } }]
|
http -v POST http://172.22.0.89:9093/api/v2/alerts < debug.json
cat debug.json
1 2 3 4 5 6 7 8 9 10 11 12 13
| [{ "labels": { "alertname": "testing4", "stream": "hello", "alerttype": "warning", "severity": "page", "business": "team2" }, "annotations": { "summary": "sending for xxx" } }]
|
ubuntu@prometheus-01:/data/alermanager$ cat alertmanager.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| global: resolve_timeout: 5m smtp_smarthost: 'smtp.163.com:465' smtp_from: 'xxxxx@163.com' smtp_auth_username: 'xxxx@163.com' smtp_auth_password: 'xxxxxx' smtp_require_tls: false smtp_hello: '163.com' wechat_api_url: 'https://qyapi.weixin.qq.com/cgi-bin/' wechat_api_secret: 'YpZ-xxxxx' wechat_api_corp_id: 'xxxxx'
route: group_by: ['alertname'] group_wait: 0s group_interval: 1m repeat_interval: 15m receiver: 'default-receiver' routes: - receiver: 'xxxonly' match: business: team2 continue: false - receiver: 'k8smail' continue: true - receiver: 'slack' continue: true - receiver: 'wechat' continue: true - receiver: 'telegram' continue: true
- receiver: 'critical-notifications' continue: true match: severity_level: critical
receivers: - name: 'default-receiver' email_configs: - to: 'xxxx@xxx.io' send_resolved: true
- name: 'critical-notifications' email_configs: - to: 'xxx@xxx.io' send_resolved: true - to: 'xxx@163.com' send_resolved: true - name: 'k8smail' email_configs: - to: 'xxxxx@163.com' send_resolved: true - to: 'xxxx@outlook.com' send_resolved: true - name: 'slack' slack_configs: - send_resolved: true api_url: https://hooks.slack.com/services/xxxxx channel: '#monitoring' text: "{{ range .Alerts }} {{ .Annotations.description}}\n {{end}} @{{ .CommonAnnotations.username}} <{{.CommonAnnotations.link}}| click here>" title: "{{.CommonAnnotations.summary}}" title_link: "{{.CommonAnnotations.link}}" - name: 'cjonly' slack_configs: - send_resolved: true api_url: https://hooks.slack.com/servicesxxxx channel: '#alert-notice' text: "{{ range .Alerts }} {{ .Annotations.description}}\n {{end}} @{{ .CommonAnnotations.username}} <{{.CommonAnnotations.link}}| click here>" title: "{{.CommonAnnotations.summary}}" title_link: "{{.CommonAnnotations.link}}" - name: 'wechat' wechat_configs: - send_resolved: true corp_id: 'xxxx' to_user: '@all' message: '{{ template "wechat.default.message" . }}' agent_id: '1000002' api_secret: 'YpZ-xxxxxx'
- name: "pagerduty" pagerduty_configs: - service_key: "xxxx" - name: 'telegram' telegram_configs: - bot_token: xxx:xxxx api_url: https://api.telegram.org chat_id: -xxxx parse_mode: 'HTML' message: '{{ template "telegram.message". }}'
inhibit_rules: - source_match: severity: 'critical' target_match: severity: 'warning' equal: ['alertname', 'dev', 'instance']
templates: - 'template/telegram.tmpl'
|
这个名字没法编辑,创建后改不了…
https://cloud.tencent.com/document/product/1263/74219?cps_key=1d358d18a7a17b4a6df8d67a62fd3d3d
参考这篇,再来一遍
20250814
暴露一个公网能访问的地址
1 2 3
| [program:alertmanager2] directory = /data/alermanager command = ./alertmanager --web.external-url=https://alert.your-domain.app
|
即启动命令加一个 –web.external-url=https://alert.your-domain.app
原文链接: https://dashen.tech/2025/04/01/Alertmanager的使用/
版权声明: 转载请注明出处.