Google Distributed Cloud (GDC) 實體隔離設備中的簡易郵件傳輸通訊協定 (SMTP) 通知管道,可讓您透過 ObservabilityPipeline 自訂資源,將觸發的 Prometheus 警告直接傳送至團隊的電子郵件。即使選擇不設定電子郵件通知,您仍可在 Grafana 資訊主頁中查看 infra-obs 和 platform-obs 命名空間的快訊。
事前準備
設定通知管道
請按照下列步驟設定 Slack 或電子郵件通知管道:
如要建立自訂快訊通知管道,請在網路中託管 SMTP 伺服器,並準備好 SMTP 設定詳細資料 (IP、使用者名稱、密碼、接收者電子郵件),以便建立 alertmanager 設定。您可以從 bm03 執行連線偵測 (ping),驗證 SMTP 主機 IP 是否正確。
建立
cm.yml檔案,並加入以下內容:smtp_smarthost必須包含客戶託管的 SMTP 伺服器 IP 位址。apiVersion: v1 kind: ConfigMap metadata: # The name must match the ConfigMap name specified in the ObservabilityPipeline custom resource. name: appl-alert-notification # The namespace must match the project namespace namespace: PROJECT_NAMESPACE data: # The file name must be alertmanager.yml alertmanager.yml: | global: smtp_smarthost: SMTP HOST IP ADDRESS smtp_from: FROM_EMAIL_ADDRESS # Give empty string for unsecured smtp server in username and password and false in smtp_require_tls. smtp_auth_username: USERNAME smtp_auth_password: PASSWORD smtp_require_tls: true route: group_by: ['alertname', 'cluster', 'service'] group_wait: 30s group_interval: 5m repeat_interval: 3h receiver: team-X-mails receivers: - name: 'team-X-mails' email_configs: - to: **RECIEVER_EMAIL_ID**在必填欄位中輸入正確內容。
執行
kubectl apply -f cm.yaml。使用下列指令建立
ObservabilityPipeline自訂資源:# Configure observability pipeline apiVersion: observability.gdc.goog/v1 kind: ObservabilityPipeline metadata: # Choose namespace that matches the project's namespace namespace: PROJECT_NAMESPACE name: observability-config spec: # Configure Alertmanager alerting: # Permission: PA and AO # The alerts configuration must be in the key "alertmanager.yml" of the configMap alertmanagerConfig: CUSTOMIZED_CONFIGMAP_NAME ...更改下列內容:
- PROJECT_NAMESPACE:專案的命名空間。
CUSTOMIZED_CONFIGMAP_NAME:您在
ConfigMap物件中使用的設定檔名稱,必須與ConfigMap物件的名稱完全一致。舉例來說,如果您在步驟 2 中使用appl-alert-notification做為ConfigMap名稱,請在ObservabilityPipeline物件中為設定檔使用相同名稱。
將命名空間更新為上一步使用的值。
執行
kubectl apply -f ob.yaml.如果 GDC 的 Grafana 資訊主頁上顯示的所有快訊處於
firing狀態,就會觸發電子郵件。為您在先前步驟中使用的命名空間啟動 Grafana,並檢查處於firing狀態的快訊。快訊會傳送至你的電子郵件地址。