

# EventBridge를 사용하여 APM 알림을 수집하기 위한 페이로드 요구 사항
<a name="idr-gs-apm-payload-requirements"></a>

**사고 탐지 및 대응은 어디에서 APM 알림을 수집하나요?**

AWS 사고 탐지 및 대응은 최종 변환된 페이로드를 보내는 이벤트 버스에 관리형 규칙을 설치합니다. 이를 위해 사용자 지정 이벤트 버스를 생성하는 것이 가장 좋습니다.

**페이로드는 어떤 형식이어야 하나요?**

AWS 사고 탐지 및 대응에서 수집하는 이벤트 버스 이벤트에는 다음과 같은 최소 JSON 키-값 페어가 필요합니다.

```
{  
    "detail-type": "ams.monitoring/generic-apm",  
    "source": "GenericAPMEvent"  
    "detail": {  
        "incident-detection-response-identifier": "Your alarm name from your APM",  
    }  
}
```

다음 예제는 변환 전과 후에 파트너 이벤트 버스의 이벤트를 보여줍니다.

**변환 전:**

```
{  
    "version": "0",  
    "id": "a6150a80-601d-be41-1a1f-2c5527a99199",  
    "detail-type": "Datadog Alert Notification",  
    "source": "aws.partner/datadog.com/Datadog-aaa111bbbc",  
    "account": "123456789012",  
    "time": "2023-10-25T14:42:25Z",  
    "region": "us-east-1",  
    "resources": [],  
    "detail": {  
        "alert_type": "error",  
        "event_type": "query_alert_monitor",  
        "meta": {  
            "monitor": {  
                "id": 222222,  
                "org_id": 3333333333,  
                "type": "query alert",  
                "name": "UnHealthyHostCount",  
                "message": "@awseventbridge-Datadog-aaa111bbbc",  
                "query": "max(last_5m):avg:aws.applicationelb.un_healthy_host_count{aws_account:123456789012} <= 1",  
                "created_at": 1686884769000,  
                "modified": 1698244915000,  
                "options": {  
                    "thresholds": {  
                        "critical": 1.0  
                    }  
                },  
            },  
            "result": {  
                "result_id": 7281010972796602670,  
                "result_ts": 1698244878,  
                "evaluation_ts": 1698244868,  
                "scheduled_ts": 1698244938,  
                "metadata": {  
                    "monitor_id": 222222,  
                    "metric": "aws.applicationelb.un_healthy_host_count"  
                }  
            },  
            "transition": {  
                "trans_name": "Triggered",  
                "trans_type": "alert"  
            },  
            "states": {  
                "source_state": "OK",  
                "dest_state": "Alert"  
            },  
            "duration": 0  
        },  
        "priority": "normal",  
        "source_type_name": "Monitor Alert",  
        "tags": [  
            "aws_account:123456789012",  
            "monitor"  
        ]  
    }  
}
```

이벤트가 변환되기 전에 `detail-type` 및 `source`는 알림이 발생한 APM 세부 정보를 나타냅니다. 수집 전에 수정해야 합니다. `incident-detection-response-identifier` 키가 아직 없으며 수집 전에 추가해야 합니다.

Lambda 함수는 위의 이벤트를 변환하여 대상 사용자 지정 또는 기본 이벤트 버스에 넣습니다. 변환된 페이로드에는 필수 키:값 페어가 포함되어야 합니다.

**변환 후:**

```
{  
    "version": "0",  
    "id": "7f5e0fc1-e917-2b5d-a299-50f4735f1283",  
    "detail-type": "ams.monitoring/generic-apm",  
    "source": "GenericAPMEvent",  
    "account": "123456789012",  
    "time": "2023-10-25T14:42:25Z",  
    "region": "us-east-1",  
    "resources": [],  
    "detail": {  
        "incident-detection-response-identifier": "UnHealthyHostCount",  
        "alert_type": "error",  
        "event_type": "query_alert_monitor",  
        "meta": {  
            "monitor": {  
                "id": 222222,  
                "org_id": 3333333333,  
                "type": "query alert",  
                "name": "UnHealthyHostCount",  
                "message": "@awseventbridge-Datadog-aaa111bbbc",  
                "query": "max(last_5m):avg:aws.applicationelb.un_healthy_host_count{aws_account:123456789012} <= 1",  
                "created_at": 1686884769000,  
                "modified": 1698244915000,  
                "options": {  
                    "thresholds": {  
                        "critical": 1.0  
                    }  
                },  
            },  
            "result": {  
                "result_id": 7281010972796602670,  
                "result_ts": 1698244878,  
                "evaluation_ts": 1698244868,  
                "scheduled_ts": 1698244938,  
                "metadata": {  
                    "monitor_id": 222222,  
                    "metric": "aws.applicationelb.un_healthy_host_count"  
                }  
            },  
            "transition": {  
                "trans_name": "Triggered",  
                "trans_type": "alert"  
            },  
            "states": {  
                "source_state": "OK",  
                "dest_state": "Alert"  
            },  
            "duration": 0  
        },  
        "priority": "normal",  
        "source_type_name": "Monitor Alert",  
        "tags": [  
            "aws_account:123456789012",  
            "monitor"  
        ]  
    }  
}
```

이제 `detail-type`이 `ams.monitoring/generic-apm`이고, 소스가 `GenericAPMEvent`이며, 세부 사항에 새 키:값 페어 `incident-detection-response-identifier`가 있습니다.

`incident-detection-response-identifier` 값은 APM이 전송하는 페이로드를 기반으로 알림 이름에서 가져옵니다. APM 알림 이름 경로는 한 APM에서 다른 APM으로 다릅니다. Lambda 함수는 Lambda가 수신한 APM JSON 페이로드의 올바른 경로에서 경보 이름을 가져와 `incident-detection-response-identifier` 값에 사용하도록 설정해야 합니다.

`incident-detection-response-identifier` 값은 AWS 사고 탐지 및 대응으로 전송되는 경보 유형별로 고유해야 합니다. `incident-detection-response-identifier`에 설정된 각 고유 이름은 온보딩 중에 AWS 사고 탐지 및 대응 팀에 제공되어야 합니다. `incident-detection-response-identifier` 키에 대해 알 수 없거나 누락된 값이 있는 이벤트는 처리되지 않습니다.