

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

# 搭配成本異常偵測使用 AWS 使用者通知
<a name="cad-user-notifications"></a>

您可以使用[AWS 使用者通知](https://docs.aws.amazon.com/notifications/latest/userguide/what-is-service.html)來設定交付管道，通知您有關成本異常偵測事件。當事件符合指定的規則時，您會收到通知。您可以透過多個管道接收事件的通知，包括電子郵件、Amazon Chime、Microsoft Teams [和 Slack 等聊天應用程式中的 Amazon Q Developer](https://docs.aws.amazon.com/chatbot/latest/adminguide/what-is.html)，或[AWS 主控台行動應用程式](https://docs.aws.amazon.com/consolemobileapp/latest/userguide/what-is-consolemobileapp.html)推送通知。您也可以在 AWS 使用者通知主控台中使用[主控台通知中心](https://console.aws.amazon.com/notifications/)查看通知。

AWS 使用者通知也支援彙總，可減少您在特定事件期間收到的通知數量。如需詳細資訊，請參閱《[AWS 使用者通知使用者指南》](https://docs.aws.amazon.com/notifications/latest/userguide/what-is-service.html)。

若要使用 AWS 使用者通知，您必須擁有正確的 AWS Identity and Access Management (IAM) 許可。如需設定 IAM 許可的詳細資訊，請參閱*AWS 《 使用者*[通知使用者指南》中的建立通知組態](https://docs.aws.amazon.com/notifications/latest/userguide/getting-started.html#getting-started-step1)。

## 範例： 的 EventBridge 事件 `Anomaly Detected`
<a name="cad-user-notifications-example"></a>

以下是 的一般化範例事件`Anomaly Detected`。您可以使用 AWS 使用者通知訂閱 EventBridge 事件 （例如此事件）。

```
{
    "version": "0",
    "id": "<id>", // alphanumeric string
    "source": "aws.ce",
    "detail-type": "Anomaly Detected",
    "account": "<account ID>", // 12 digit account id.
    "region": "<region>", // Cost Anomaly Detection home region.
    "time": "<date>", // Format: yyyy-MM-dd'T'hh:mm:ssZ
    "resources": [ 
         "arn:aws:ce::123456789012:anomalymonitor/abcdef12-1234-4ea0-84cc-918a97d736ef"
    ],
    "detail": {
         "accountName": "<account name>",
         "anomalyEndDate": "2021-05-25T00:00:00Z",
         "anomalyId": "12345678-abcd-ef12-3456-987654321a12",
         "anomalyScore": { 
            "currentScore": 0.47,
            "maxScore": 0.47
         },
         "anomalyStartDate": "2021-05-25T00:00:00Z",
         "dimensionValue": "<dimension value>", // service name for AWS Service Monitor
         "feedback": "string",
         "impact": {
            "maxImpact": 151,
            "totalActualSpend": 1301,
            "totalExpectedSpend": 300,
            "totalImpact": 1001,
            "totalImpactPercentage": 333.67
         },
         "rootCauses": [ 
            {
                "linkedAccount": "<linked account ID>", // 12 digit account id.
                "linkedAccountName": "<linked account name>",
                "region": "<region>",
                "service": "<service name>", // AWS service name
                "usageType": "<usage type>", // AWS service usage type
                "impact": {
                    "contribution": 601,
                }
            }
        ],
        "accountId": "<account ID>", // 12 digit account id.
        "monitorArn": "arn:aws:ce::123456789012:anomalymonitor/abcdef12-1234-4ea0-84cc-918a97d736ef",
        "monitorName": "<your monitor name>",
        "anomalyDetailsLink": "https://console.aws.amazon.com/cost-management/home#/anomaly-detection/monitors/abcdef12-1234-4ea0-84cc-918a97d736ef/anomalies/12345678-abcd-ef12-3456-987654321a12"
    }
}
```

## 篩選事件
<a name="cad-user-notifications-filter"></a>

您可以使用 AWS 使用者通知主控台中可用的篩選條件，或如果您從 JSON 程式碼建立自己的 EventBridge 篩選條件，則可依服務和名稱來篩選事件。

**Topics**
+ [範例：依影響篩選](#example-filter-by-impact)
+ [範例：依服務維度篩選](#example-filter-by-service-dimension)
+ [範例：依成本分配標籤篩選](#example-filter-by-cost-allocation-tag)
+ [範例：依區域根本原因篩選](#example-filter-by-region-root-cause)
+ [範例：依多個條件篩選](#example-filter-composition)

### 範例：依影響篩選
<a name="example-filter-by-impact"></a>

下列篩選條件會擷取總影響大於 100 USD 且百分比影響大於 10% 的任何異常。

```
{
    "detail": {
        "impact": {
            "totalImpact": [{
                "numeric": [">", 100]
            }],
            "totalImpactPercentage": [{
                "numeric": [">", 10]
            }]
        }
    }
}
```

### 範例：依服務維度篩選
<a name="example-filter-by-service-dimension"></a>

下列篩選條件會擷取 AWS 服務監視器偵測到的 EC2 服務特有異常。

```
{
    "detail": {
        "dimensionValue": ["Amazon Elastic Compute Cloud - Compute"],
        "monitorName": ["aws-services-monitor"]
    }
}
```

### 範例：依成本分配標籤篩選
<a name="example-filter-by-cost-allocation-tag"></a>

下列篩選條件會擷取由維度成本分配標籤監視器偵測到的前端應用程式團隊的異常。

```
{
  "detail": {
    "dimensionValue": ["ApplicationTeam:Frontend"],
    "monitorName": ["dimensional-CAT-monitor"]
  }
}
```

### 範例：依區域根本原因篩選
<a name="example-filter-by-region-root-cause"></a>

下列篩選條件會擷取美國東部 （維吉尼亞北部） 區域中根本原因的異常。

```
{
  "detail": {
    "rootCauses": {
      "region": ["us-east-1"]
    }
  }
}
```

### 範例：依多個條件篩選
<a name="example-filter-composition"></a>

下列複雜篩選條件會擷取前端應用程式團隊的異常，其總影響大於 100 美元、百分比影響大於 10%，以及美國東部 （維吉尼亞北部） 區域的根本原因。

```
{
  "detail": {
    "dimensionValue": ["ApplicationTeam:Frontend"],
    "monitorName": ["dimensional-CAT-monitor"],
    "impact": {
        "totalImpact": [{ "numeric": [">", 100] }],
        "totalImpactPercentage": [{ "numeric": [">", 10] }]
    },
    "rootCauses": {
        "region": ["us-east-1"]
    }
  }
}
```