本文档展示了用于自定义提醒通知内容的提醒政策示例。
准备工作
熟悉如何为 Personalized Service Health 设置提醒。
如需了解您可以在提醒通知和条件中设置的字段,请参阅 Service Health 日志架构参考文档。
提醒条件示例
以下部分显示了可用于 Cloud Logging 或 Terraform 的精细提醒条件示例。
针对特定 Google Cloud 产品的新突发事件发出提醒
将 ALERT_CONDITION
设置为以下内容:
labels."servicehealth.googleapis.com/new_event"=true AND jsonPayload.detailedCategory = \"CONFIRMED_INCIDENT\" AND jsonPayload.impactedProductIds =~ \"hV87iK5DcEXKgWU2kDri\" AND jsonPayload.@type = \"type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog\"
产品名称采用常见的 Google Cloud 格式。如需查看格式示例,请参阅 Google Cloud Service Health。
针对特定区域的新突发事件发出提醒
将 ALERT_CONDITION
设置为以下内容:
labels."servicehealth.googleapis.com/new_event"=true AND jsonPayload.detailedCategory = \"CONFIRMED_INCIDENT\" AND jsonPayload.impactedLocations =~ \"us-central1\" AND jsonPayload.@type = \"type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog\"
位置名称采用常见的 Google Cloud 格式。如需查看格式示例,请参阅 Google Cloud Service Health。
针对特定产品出现的新突发事件发出提醒
将 ALERT_CONDITION
设置为以下内容:
labels."servicehealth.googleapis.com/new_event"=true AND jsonPayload.detailedCategory = \"EMERGING_INCIDENT\" AND jsonPayload.impactedProductIds =~ \"ix7u9beT8ivBdjApTif3\" AND jsonPayload.@type = \"type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog\"
针对突发事件的任何更新或更改发出提醒
将 ALERT_CONDITION
设置为以下内容:
jsonPayload.detailedCategory = \"CONFIRMED_INCIDENT\" AND jsonPayload.@type = \"type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog\"
针对已确认突发事件的任何更新发送提醒
将 ALERT_CONDITION
设置为以下内容:
jsonPayload.state =~ \"ACTIVE\" AND jsonPayload.detailedCategory = \"CONFIRMED_INCIDENT\" AND jsonPayload.detailedState != \"EMERGING\" AND jsonPayload.@type = \"type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog\"
有关状态或相关性更新的提醒
将 ALERT_CONDITION
设置为以下内容:
jsonPayload.detailedCategory = \"CONFIRMED_INCIDENT\" AND "labels.servicehealth.googleapis.com/updated_fields" =~ \"'state'\" OR labels."servicehealth.googleapis.com/updated_fields" =~ \"'relevance'\" AND jsonPayload.@type = \"type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog\"
包含完整突发事件详情的提醒通知
以下提醒通知提供了完整的突发事件详情。
{
"displayName": "ALERT_NAME",
"combiner": "OR",
"conditions": [ {
"displayName": "Log match condition",
"conditionMatchedLog": {
"filter": "ALERT_CONDITION",
"labelExtractors": {
"description": "EXTRACT(jsonPayload.description)",
"impactedLocations": "EXTRACT(jsonPayload.impactedLocations)",
"impactedProducts": "EXTRACT(jsonPayload.impactedProducts)",
"startTime": "EXTRACT(jsonPayload.startTime)",
"state": "EXTRACT(jsonPayload.state)"
"detailedState": "EXTRACT(jsonPayload.detailedState)"
} } } ],
"documentation": {
"content": "# View details at [Service Health dashboard](https://console.cloud.google.com/servicehealth/incidentDetails/projects%2F${resource.labels.resource_container}%2Flocations%2F${resource.labels.location}%2Fevents%2F${resource.labels.event_id}?project=${resource.labels.resource_container}) \n## Description \n${log.extracted_label.description} \n## Impacted locations \n${log.extracted_label.impactedLocations} \n## Impacted products \n${log.extracted_label.impactedProducts} \n## Incident start time \n${log.extracted_label.startTime} \n## Event state \n${log.extracted_label.state} \n## Event detailed state \n ${log.extracted_label.detailedState}",
"mimeType": "text/markdown"
},
"notificationChannels": [ "NOTIFICATION_CHANNEL" ],
"enabled": true,
"alertStrategy": { "notificationRateLimit": { "period": "300s" }, "autoClose": "1800s" }
}
示例中的 labelExtractors
和 content
字段包含突发事件的所有可用信息。
包含指向 Service Health 信息中心链接的提醒通知
以下示例提供了指向 Service Health 信息中心的链接。
{
"displayName": "ALERT_NAME",
"combiner": "OR",
"conditions": [ {
"displayName": "Log match condition",
"conditionMatchedLog": {
"filter": "ALERT_CONDITION",
"labelExtractors": {
"description": "EXTRACT(jsonPayload.description)",
"impactedLocations": "EXTRACT(jsonPayload.impactedLocations)",
"impactedProducts": "EXTRACT(jsonPayload.impactedProducts)",
"startTime": "EXTRACT(jsonPayload.startTime)",
"state": "EXTRACT(jsonPayload.state)",
"detailedState": "EXTRACT(jsonPayload.detailedState)"
} } } ],
"documentation": {
"content": "# View details at [Service Health dashboard](https://console.cloud.google.com/servicehealth/eventDetails/projects%2F${resource.labels.resource_container}%2Flocations%2F${resource.labels.location}%2Fevents%2F${resource.labels.event_id})",
"mimeType": "text/markdown"
},
"notificationChannels": [ "NOTIFICATION_CHANNEL" ],
"enabled": true,
"alertStrategy": { "notificationRateLimit": { "period": "300s" }, "autoClose": "1800s" }
}