

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 篩選 DevOps Guru 通知
<a name="update-notifications-filter"></a>

您可以使用 Amazon SNS 訂閱篩選條件政策，透過 [更新 Amazon SNS 通知組態](update-notifications.md#update-notification-configurations)或 來篩選 DevOps Guru 通知。

**Topics**
+ [使用 Amazon SNS 訂閱篩選條件政策篩選通知](#use-subscription-filter-policy)
+ [Amazon DevOps Guru 的篩選 Amazon SNS 通知範例](#sample-filtered-notification)

## 使用 Amazon SNS 訂閱篩選條件政策篩選通知
<a name="use-subscription-filter-policy"></a>

您可以建立 Amazon Simple Notification Service (Amazon SNS) 訂閱篩選條件政策，以減少從 Amazon DevOps Guru 收到的通知數量。

使用篩選條件政策來指定您收到的通知類型。您可以使用下列關鍵字篩選 Amazon SNS 訊息。
+ `NEW_INSIGHT` — 建立新的洞見時收到通知。
+ `CLOSED_INSIGHT` — 在現有洞見關閉時收到通知。
+ `NEW_RECOMMENDATION` — 從洞見建立新建議時收到通知。
+ `NEW_ASSOCIATION` — 從洞見偵測到新的異常時收到通知。
+ `CLOSED_ASSOCIATION` — 在現有異常關閉時收到通知。
+ `SEVERITY_UPGRADED` — 升級洞見嚴重性時收到通知

如需有關如何建立 Amazon SNS 訂閱篩選條件政策的資訊，請參閱《Amazon *Simple Notification Service *[開發人員指南》中的 Amazon SNS 訂閱篩選條件政策](https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html)。在篩選政策中，您可以使用政策的 指定其中一個關鍵字`MessageType`。例如，以下會出現在篩選條件中，指定 Amazon SNS 主題只會在從洞見偵測到新的異常時傳送通知。

```
{ 
  "MessageType":["NEW_ ASSOCIATION"] 
}
```

## Amazon DevOps Guru 的篩選 Amazon SNS 通知範例
<a name="sample-filtered-notification"></a>

以下是來自具有篩選條件政策之 Amazon SNS 主題的 Amazon SNS) 通知範例。其`MessageType`設定為 `NEW_ASSOCIATION`，因此只有在從洞見偵測到新的異常時才會傳送通知。

```
{
      "accountId": "123456789012",
      "region": "us-east-1",
      "messageType": "NEW_ASSOCIATION",
      "insightId": "ADyf4FvaVNDzu9MA2-IgFDkAAAAAAAAAEGpJd5sjicgauU2wmAlnWUyyI2hiO5it",
      "insightName": "Repeated Insight: Anomalous increase in Lambda ApigwLambdaDdbStack-22-Function duration due to increased number of invocations",
      "insightUrl": "https://us-east-1.console.aws.amazon.com/devops-guru/insight/reactive/ADyf4FvaVNDzu9MA2-IgFDkAAAAAAAAAEGpJd5sjicgauU2wmAlnWUyyI2hiO5it",
      "insightType": "REACTIVE",
      "insightDescription": "At March 29, 2023 22:02 GMT, Lambda function ApigwLambdaDdbStack-22-Function had\n an increased duration anomaly possibly caused by the Lambda function invocation increase. DevOps Guru has detected this is a repeated insight. DevOps Guru treats repeated insights as 'Low Severity'.",
      "startTime": 1628767500000,
      "startTimeISO": "2023-03-29T22:00:00Z",
      "anomalies": [
        {
          "id": "AG2n8ljW74BoI1CHu-m_oAgAAAF7Ohu24N4Yro69ZSdUtn_alzPH7VTpaL30JXiF",
          "startTime": 1628767500000,
          "startTimeISO": "2023-03-29T22:00:00Z",
          "openTime": 1680127740000,
          "openTimeISO": "2023-03-29T22:09:00Z",
          "sourceDetails": [
            {
              "dataSource": "CW_METRICS",
              "dataIdentifiers": {
                "namespace": "AWS/SQS",
                "name": "ApproximateAgeOfOldestMessage",
                "stat": "Maximum",
                "unit": "None",
                "period": "60",
                "dimensions": "{\"QueueName\":\"FindingNotificationsDLQ\"}"
              }
            }
          ],
          "associatedResourceArns":[
          	"arn:aws:sns:us-east-1:123456789012:DevOpsGuru-insights-sns"
          ]
        }
      ],
      "resourceCollection":{
      "cloudFormation":{
         "stackNames":[
            "CapstoneNotificationPublisherEcsApplicationInfrastructure"
          ]
        }
      }
}
```