第 19 章
合規、儲存與維運
管理:
#pAlerts
營運儀表板、警示與即時遙測
營運儀表板 (#pOps) 以即時和 24 小時歷史方式顯示:每分鐘入站和出站郵件數、延遲和退回的郵件、垃圾郵件率、失敗的登入、佇列大小與最早郵件的等待時間、各協定的活動連線、CPU、記憶體、可用磁碟空間、資料庫大小、憑證到期時間與叢集節點。警示 (#pAlerts) 透過電子郵件、webhook、簡訊、Telegram、Signal 或 WhatsApp 報告超限情況。外部工具透過 /metrics (Prometheus)、OpenTelemetry 或即時事件流 (Server-Sent Events) 讀取相同的資料。
營運提示與架構說明
首次啟動時,nextxch 會建立五條沒有目標的規則(佇列阻塞、磁碟即將寫滿、憑證即將到期、大量登入失敗、大量退信)。它們會顯示在歷史記錄中;如需接收通知,請在「目標」下新增電子郵件地址或 webhook,並在規則中勾選。歷史記錄在重新啟動後保留(設定 Ops:PersistHistory = false 可關閉此功能)。
面向監控工具的即時事件串流
驗證方式與管理 API 相同(管理員的 API 金鑰透過 X-Api-Key、Bearer 或 Basic)。租戶管理員只能看到自己的租戶。篩選條件:types、direction、status、q;maxRate 限制每秒事件數(預設 20,最高 200);超出部分會以 dropped 事件回報。
curl -N -H "X-Api-Key: $NEXTXCH_KEY" \
"https://mail.company.com/api/admin/telemetry/stream?types=delivery,rejection,auth-failure&maxRate=50"
event: delivery
data: {"at":"2026-11-02T08:15:01Z","direction":"Outbound","status":"Delivered","from":"billing@company.com","to":"customer@example.com","code":250,...}
event: auth-failure
data: {"account":"info@company.com","protocol":"IMAP","remoteIp":"203.0.113.7","reason":"invalid password"}
# Types: delivery, rejection, auth-failure, filter, alert, queue
通訊協定記錄:檔案與設定
資料目錄中每個類別每天一個檔案,以定位字元分隔;SMTP AUTH LOGIN 的使用者名稱與密碼記錄為 [REDACTED]。設定位於 logging-settings.json 中,或透過 GET/PUT /api/admin/protocol-log/settings 進行。
{DataDirectory}/logs/protocol/mapi-2026-11-11.log
{DataDirectory}/logs/protocol/jmap-2026-11-11.log
# columns (tab): UTC time (yyyy-MM-ddTHH:mm:ss.fffZ), session, IP, direction, text
# {DataDirectory}/logging-settings.json
{
"Enabled": true,
"RetentionDays": 30,
"Categories": { "application": true, "smtp": true, "smtp-out": true, "delivery": true, "auth": true,
"imap": false, "mapi": true, "jmap": true, "webdav": false }
}
# Categories: application, smtp, smtp-out, delivery, auth, imap, pop3, activesync, ews, mapi, jmap, webdav
設定、預設值與最佳實務
| 設定 / 位置 | 說明 | 預設值 | 生產環境最佳實務 |
|---|---|---|---|
Alarmregel |
指標、條件(>、>=、<、<=)、閾值與持續時間(分鐘)。告警僅在條件持續該時間且未中斷時觸發。 | 5 min |
忽略短時尖峰:速率類(每分鐘)至少 5 分鐘,憑證到期為 0 分鐘。 |
Abklingzeit, Wiederholung, Entwarnung |
冷卻時間是同一規則兩則訊息之間的最小時間;重複提醒在警示保持作用中時提醒;復原回報結束。 | 60 min / aus / an |
將冷卻時間保持在 30 分鐘或以上,以免波動的數值不斷發出呼叫。 |
Ziele |
電子郵件(寄件者為儲存設定的管理員)、webhook(類型為 nextxch.alert 的 JSON,使用 X-Nextxch-Signature: sha256=... 簽章)、簡訊、Telegram、Signal、WhatsApp,透過「通知」下的管道傳送。 | - |
請至少新增一個位於您郵件伺服器外部的目標(簡訊、即時通訊或 Webhook):若投遞服務中斷,警示郵件將無法送達。 |
Messwerte in Prometheus und OpenTelemetry |
儀表板上的每個數值均可在 /metrics 取得:nextxch_mail_inbound_total、nextxch_mail_outbound_total、nextxch_mail_deferred_total、nextxch_mail_bounced_total、nextxch_mail_rejected_total、nextxch_mail_spam_total、nextxch_auth_failures_total、nextxch_mail_spam_rate_percent、nextxch_queue_messages、nextxch_queue_deferred_messages、nextxch_queue_oldest_age_minutes、nextxch_connections_active{protocol}、nextxch_process_cpu_percent、nextxch_process_working_set_bytes、nextxch_disk_free_percent、nextxch_disk_free_bytes、nextxch_database_size_bytes、nextxch_tls_certificate_min_expiry_days、nextxch_tls_certificate_expiry_days{domain}、nextxch_cluster_nodes_active、nextxch_alerts_firing、nextxch_smtp_filter_verdicts_total{type,verdict}、nextxch_smtp_filter_failures_total。 | aktiv |
透過 OTLP 傳輸時,各指標名稱相同,僅以點號取代底線(nextxch.mail.inbound);轉換為 Prometheus 後再次得出相同的名稱。 |
Protokoll-Logs (#/proto-log) |
在「協定記錄與分析」下提供類似 hMailServer 的持久協定記錄:帶按類別、時間範圍、文字、IP 與會話篩選的即時記錄(最多 1500 行,每 3 秒重新整理)、分析與解除列入黑名單,以及帶下載功能的設定與檔案。 | Logging aktiv · 30 Tage |
請根據您的刪除期限調整保留天數(1 至 3650 天);較舊的檔案將自動遭到刪除。 |
Protokoll-Kategorien |
application、smtp、smtp-out、delivery 與 auth 預設開啟;imap、pop3、activesync、ews、mapi(用於 Outlook 的 MAPI over HTTP,包括通訊錄)、jmap(僅方法名稱、錯誤數、大小與時長,絕不記錄參數或內容)與 webdav 可逐個開啟。 | 5 von 12 an |
僅在排查故障時(例如 Outlook 問題)開啟 MAPI 與 JMAP,之後請再次關閉,因為這些協定會產生大量記錄檔行。 |