跳至內容

通知

Composia 為任務結果、備份事件、映像檔更新和節點狀態變更發送通知。支援三種通知管道:Alertmanager、SMTP 與 Telegram。

設定

所有管道都在控制器設定的 notifications 下設定:

controller:
  notifications:
    alertmanager:
      enabled: true
      listen_path: "/api/v1/alerts"
    smtp:
      enabled: true
      host: "smtp.example.com"
      port: 587
      encryption: starttls
      username: "alerts@example.com"
      password: "REPLACE"
      from: "alerts@example.com"
      to:
        - "admin@example.com"
      on:
        - task_failed
        - backup_failed
      task_sources:
        - web
        - cli
    telegram:
      enabled: true
      bot_token: "REPLACE"
      chat_id: "REPLACE"
      on:
        - task_completed

事件型別

提供以下通知事件型別:

事件觸發條件
task_failed任何任務以 failed 狀態結束。
task_cancelled任務在完成前被取消。
task_completed任務成功完成。
task_awaiting_confirmation遷移任務到達確認步驟。
backup_completed備份任務或排程備份成功完成。
backup_failed備份任務或步驟失敗。
image_update_available映像檔檢查發現新版本。
image_update_applied映像檔更新已套用。
node_offline節點停止發送心跳。
node_online先前離線的節點恢復心跳。
alertmanager_alert當控制器設定為 Alertmanager webhook 接收器時收到 Alertmanager 警報。

每個管道可以使用 on 清單過濾應處理的事件型別。空的 on 清單會發送所有事件型別。

任務來源過濾器

SMTP 和 Telegram 管道支援按觸發任務的來源進行過濾:

來源說明
web透過 Web UI 觸發的操作。
cli透過 CLI 觸發的操作。
others其他來源。
schedule排程任務(備份、維護)。
system系統產生的任務。
auto_deploy自動部署觸發器產生的任務。

task_sources 為空白時,所有來源型別都會發送通知。

Alertmanager

控制器執行一個內嵌的 Alertmanager webhook 接收器。啟用後,接收器在設定的路徑上監聽:

alertmanager:
  enabled: true
  listen_path: "/api/v1/alerts"
型別說明
enabledbool當區段存在時預設啟用。
listen_pathstring接收 Alertmanager webhook 的 HTTP 路徑。預設為 /api/v1/alerts。必須以 / 開頭且不含空白字元。

將您的 Alertmanager 執行實例指向控制器的位址及此 webhook URL。警報會根據其事件過濾器轉發到已設定的通知管道。

SMTP

SMTP 透過電子郵件發送通知:

型別啟用時必要說明
enabledbool當區段存在時預設啟用。
hoststringSMTP 伺服器主機名稱。
portintSMTP 連接埠,必須在 1 到 65535 之間。
encryptionstringnonestarttlsssl_tls。預設為 starttls
usernamestringSMTP 驗證使用者名稱。
passwordstringSMTP 密碼。
password_filestring從檔案讀取密碼。
fromstring寄件者地址。
to[]string收件者地址。
on[]string要通知的事件型別。
task_sources[]string任務來源過濾器。

Telegram

Telegram 透過機器人向聊天室發送通知:

型別啟用時必要說明
enabledbool當區段存在時預設啟用。
bot_tokenstring來自 BotFather 的 Telegram 機器人權杖。
bot_token_filestring從檔案讀取機器人權杖。
chat_idstring目標聊天室 ID。
on[]string要通知的事件型別。
task_sources[]string任務來源過濾器。
最後更新於 • Renovate Bot