1. Grafana 通知架構
在 Grafana 裡,警示分成三個步驟:
(1) Contact Point → 定義要通知的管道(Email、Slack、Webhook…)
(2) Notification Policy → 什麼樣的警示要送去哪裡
(3) Alert Rule → 觸發條件(AFP > 400、ALT > 70)
2. 設定 Email 通知
(1) 進入 Grafana → Alerting → Contact points
(2) 建立新的 Contact point → 選擇 Email
(3) 填入你的 Email 位址(例如 Gmail)
(4) 需要在 grafana.ini 裡設定 SMTP,例如:
[smtp]
enabled = true
host = smtp.gmail.com:587
user = your_email@gmail.com
password = your_app_password
from_address = your_email@gmail.com
(5) 重啟 Grafana:
docker compose restart grafana
這樣警示觸發時,就會寄信到Email。
3. 設定 Slack 通知
(1) 在 Slack 建立一個 App → Incoming Webhook
(2) 拿到 Webhook URL(例如 https://hooks.slack.com/services/...)
(3) 在 Grafana → Contact points → New → Slack
(4) 貼上 Webhook URL
(5) 測試通知,應該會在指定的 Slack 頻道收到訊息。
4.設定 Line Bot 通知(進階選項)
(1) 在 LINE Developers建立 Messaging API Channel
(2) 取得 Channel Access Token
(3) 寫一個簡單的 Webhook 轉發程式(例如用 Node.js 或 Python)
● Grafana → 發送到 Webhook(你的伺服器)
● Webhook → 轉發訊息給 Line Bot
● 這樣 AFP/ALT 異常時,LINE 就會跳通知。
5. 測試警示
在 patient.log 增加:
2025-09-05 patient_id=001 AFP=600 ALT=85
重啟服務:
docker compose down
docker compose up -d
幾分鐘後,你應該會在 Email / Slack / Line 收到警示訊息。
6. 成果
● 已能把 AFP/ALT 的異常狀況,主動通知到外部平台。
● 系統不只是「顯示數據」,而是具備「自動提醒」功能。
● 更貼近臨床應用,模擬醫師的即時監控。