通過配置特定的Webhook的通知模板, ARMS在發送Webhook請求時將警示內容通過開源AlertManager的格式進行發送。
使用限制
通過Webhook自訂警示通知時,存在以下使用限制。
Content-Type類型必須是application/json。
不能和
$content
欄位混用,使用$alertmanager_content
後$content
不生效。ARMS控制台測試Webhook功能無法對
$alertmanager_content
進行替換測試。
通過Webhook自訂警示通知的操作,請參見通過Webhook自訂警示通知對象。
投遞的警示格式
向Webhook投遞開源AlertManager格式如下。更多資訊,請參見Prometheus官方文檔。
{
"alerts": [
{
"annotations": {
"_aliyun_arms_alert_value": "15.521240234375",
"_aliyun_arms_alert_message": "null\n訊息ID: ac10c42a16124966960554200d2450-7996494\n",
"_aliyun_arms_alert_now_value": "15.521240234375",
"message": "警示:命名空間: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / 容器: {{$labels.container}} 記憶體使用量率超>過80%, 當前值{{ printf \"%.2f\" $value }}%",
"value": "15.521240234375",
"_aliyun_arms_alert_past_value": "15.521240234375"
},
"endsAt": "2021-02-22T07:27:15.404000000Z",
"fingerprint": "bec72890cc2c7b4a027e008df0cd1013",
"labels": {
"container": "kube-state-metrics",
"severity": "warning",
"_aliyun_arms_alert_level": "ERROR",
"instance": "10.0.80.186:10255",
"clustername": "klyz1688-kubernetes-1",
"_aliyun_arms_alert_type": "101",
"_aliyun_arms_integration_name": "測試整合-prometheus",
"alertname": "容器記憶體使用量率大於80%",
"_aliyun_arms_userid": "1131971649496228",
"_aliyun_arms_involvedObject_name": "klyz1688-kubernetes-1",
"pod_name": "kube-state-metrics-ccb59dbff-jljg4",
"_aliyun_arms_involvedObject_id": "cb36dcafb9b9340498fad2e1f40b9a254",
"_aliyun_arms_region_id": "cn-hangzhou",
"_aliyun_arms_involvedObject_kind": "cluster",
"_aliyun_arms_product_type": "PROMETHEUS",
"name": "k8s_kube-state-metrics_kube-state-metrics-ccb59dbff-jljg4_arms-prom_359508f3-7e76-4740-b915-41ea48849641_0",
"namespace": "arms-prom",
"_aliyun_arms_integration_id": "80",
"_aliyun_arms_involvedObject_type": "ManagedKubernetes",
"_aliyun_arms_alert_rule_id": "3927051"
},
"startsAt": "2021-02-22T07:18:15.578000000Z",
"status": "firing"
}
],
"commonAnnotations": {
"_aliyun_arms_alert_value": "15.521240234375",
"_aliyun_arms_alert_message": "null\n訊息ID: ac10c42a16124966960554200d2450-7996494\n",
"_aliyun_arms_alert_now_value": "15.521240234375",
"message": "警示:命名空間: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / 容器: {{$labels.container}} 記憶體使用量率超過80%, 當前值{{ printf \"%.2f\" $value }}%",
"value": "15.521240234375",
"_aliyun_arms_alert_past_value": "15.521240234375"
},
"commonLabels": {
"container": "kube-state-metrics",
"severity": "warning",
"_aliyun_arms_alert_level": "ERROR",
"instance": "10.0.80.186:10255",
"clustername": "klyz1688-kubernetes-1",
"_aliyun_arms_alert_type": "101",
"_aliyun_arms_integration_name": "測試整合-prometheus",
"alertname": "容器記憶體使用量率大於80%",
"_aliyun_arms_userid": "1131971649496228",
"_aliyun_arms_involvedObject_name": "klyz1688-kubernetes-1",
"pod_name": "kube-state-metrics-ccb59dbff-jljg4",
"_aliyun_arms_involvedObject_id": "cb36dcafb9b9340498fad2e1f40b9a254",
"_aliyun_arms_region_id": "cn-hangzhou",
"_aliyun_arms_involvedObject_kind": "cluster",
"_aliyun_arms_product_type": "PROMETHEUS",
"name": "k8s_kube-state-metrics_kube-state-metrics-ccb59dbff-jljg4_arms-prom_359508f3-7e76-4740-b915-41ea48849641_0",
"namespace": "arms-prom",
"_aliyun_arms_integration_id": "80",
"_aliyun_arms_involvedObject_type": "ManagedKubernetes",
"_aliyun_arms_alert_rule_id": "3927051"
},
"externalURL": "https://alerts.console.aliyun.com/#/alarm/alert/detail/2848",
"groupLabels": {
"alertname": "容器記憶體使用量率大於80%"
},
"receiver": "testjiubian",
"status": "firing"
}
在Webhook中擷取開源AlertManager格式
- 登入ARMS控制台,在左側導覽列選擇 。
單擊Webhook整合頁簽,然後單擊建立Webhook。
在彈出的對話方塊中輸入以下配置資訊。更多詳情,請參見步驟二:建立Webhook連絡人。