monitoring-compose.yml
文件中配置 SMTP 设置。
services: ... grafana: ... environment: GF_SECURITY_ADMIN_PASSWORD: ${GF_SECURITY_ADMIN_PASSWORD:?Missing env GF_SECURITY_ADMIN_PASSWORD for Grafana admin password} WA_PROMETHEUS_ENDPOINT: ${WA_PROMETHEUS_ENDPOINT:-http://prometheus:9090} GF_SERVER_ROOT_URL: your-grafana-public-endpoint #(ex. https://foo.bar.com:3000) GF_SMTP_ENABLED: 1 GF_SMTP_HOST: your-smtp-host #(ex. smtp.gmail.com:465) GF_SMTP_USER: your-smtp-auth-user #(ex. you@email.com) GF_SMTP_PASSWORD: your-smtp-auth-password GF_SMTP_SKIP_VERIFY: 1 depends_on: - 'prometheus'
docker-compose -f monitoring-compose.yml up -d
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
),在 Grafana 中设置 Slack 通知。通过点击发送测试按钮测试您的设置。如果配置正确,您应该会收到如下关于已配置渠道的消息:
de7439f367354513b9e1ba4042f0e3b8
),在 Grafana 中设置 PagerDuty 通知。通过点击发送测试按钮测试您的设置。如果配置正确,您应该会在 PagerDuty 提醒主页上收到如下提醒:
您还可以通过设置 Webhook 服务器来接收提醒。
{ "evalMatches": [ { "metric": "High value", "tags": null, "value": 100 }, { "metric": "Higher Value", "tags": null, "value": 200 } ], "message": "Someone is testing the alert notification within grafana.", "ruleId": 0, "ruleName": "Test notification", "ruleUrl": "http://localhost:3000/", "state": "alerting", "title": "[Alerting] Test notification" }若非如此,请检查您的 Grafana 容器日志进行调试。