

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# EventBridge 与成本异常检测配合使用
<a name="cad-eventbridge"></a>

AWS 成本异常检测与 EventBridge事件总线服务集成，您可以使用该服务将应用程序与来自各种来源的数据连接起来。有关更多信息，请参阅 [Amazon EventBridge 用户指南](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html)。

您可以使用 EventBridge 来检测成本异常检测事件并做出反应。然后，根据您创建的规则，当事件与您在规则中指定的值匹配时， EventBridge 调用一个或多个目标操作。根据事件的类型，您可以捕获事件信息、启动其他事件、发送通知、采取纠正措施或执行其他操作。要为成本异常检测事件设置 EventBridge 规则，请参阅亚马逊* EventBridge 用户指南*[中的在 Amazon EventBridge 中创建规则](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-get-started.html#eb-gs-create-rule)。

## 示例：成本异常检测 EventBridge 事件
<a name="cad-eventbridge-example"></a>

当检测到即时警报时，订阅用户会收到 `Anomaly Detected` 详细信息类型的事件。以下示例显示了详细信息类型的事件正文：

```
{
    "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"
    }
}
```