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_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 容器記錄進行偵錯。