複習
事件(Event)與告警(Alert)
事件是條件符合時的原始紀錄集合,而告警則是基於事件執行的動作集合,例如發送通知、呼叫 Webhook 或執行自動化程式。
Notification
什麼是 Notification?
Notification 是告警通知的傳送方式,當事件定義的條件達成時,系統會透過已設定的通知管道發送警報訊息。常見的通知類型包含 Email、HTTP Webhook、Slack 等。
建立 Notification
建立 Email 通知
-
前置準備:SMTP 設定
在建立 Email 通知前,需先在 Graylog 伺服器設定檔中配置 SMTP:
編輯 /etc/graylog/server/server.conf
:
# Email transport
transport_email_enabled = true
transport_email_hostname = smtp.gmail.com
transport_email_port = 587
transport_email_use_auth = true
transport_email_use_tls = true
transport_email_auth_username = your-email@gmail.com
transport_email_auth_password = your-app-password
transport_email_subject_prefix = [Graylog Alert]
transport_email_from_email = graylog-alerts@yourdomain.com
設定完成後重啟 Graylog 服務。
-
建立 Email 通知設定
- 進入 Alerts & Events → Notifications,點選「Create Notification」
- 基本設定:
- Title:SSH Login Alert Email
- Description:Email notification for SSH login failures
- Notification Type:選擇「Email Notification」
- 設定內容:
- Subject:[Security Alert] SSH Login Failures - ${event_definition_title}
- Sender:留空(使用預設)
- Email Recipients:輸入收件人信箱
建立 Slack 通知
- Notification Type:選擇「Slack Notification」
- 設定內容:
- Webhook URL:<https://hooks.slack.com/services/YOUR/WEBHOOK/URL>
- Channel:#security-alerts
- Username:Graylog
- Icon URL:可選填圖示 URL
- Configuration Color:選擇顏色(如 danger 紅色)
建立 HTTP Webhook 通知
適用於其他第三方系統整合
- Notification Type:選擇「HTTP Notification」
- 設定內容:
- URL:<https://your-webhook-endpoint.com/alerts>
- HTTP Method:POST
- Content Type:application/json
創建第一個事件定義 (下半部)
-
Fields:可選擇新增自訂欄位以便在告警中顯示更多資訊,例如新增 username 欄位。
-
Notifications:選擇已建立的通知設定(Email 或 Webhook)。
-
Share:設定此事件定義的共享權限,可選擇與特定使用者或群組共享。
-
Summary:檢查所有設定內容無誤後,點選「Create event definition」完成建立。
基礎故障排除
- SMTP 無法發送:檢查防火牆、帳密是否正確,並查看 Graylog 日誌 (server.log)。
- 告警不觸發:確認 Filter 語法正確、時間範圍是否覆蓋。
- 測試通知:可透過「Execute Test Notification」按鈕,驗證所有設定。
總結
本篇介紹了 Graylog 告警系統的基礎配置流程,包含事件定義建立、通知設定與實戰應用。透過 SSH 登入失敗檢測的實例,學習了如何設定過濾條件、聚合規則與閾值觸發,並完成 Email、Slack 及 HTTP Webhook 等多種通知方式的配置。