

支援終止通知：2026 年 5 月 20 日， AWS 將終止對 的支援 AWS IoT Events。2026 年 5 月 20 日之後，您將無法再存取 AWS IoT Events 主控台或 AWS IoT Events 資源。如需詳細資訊，請參閱[AWS IoT Events 終止支援](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-end-of-support.html)。

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

# AWS IoT Events 使用 Amazon CloudWatch 進行監控
<a name="monitoring-cloudwatch"></a>

當您開發或偵錯 AWS IoT Events 偵測器模型時，您需要知道 AWS IoT Events 正在做什麼，以及它遇到的任何錯誤。Amazon CloudWatch AWS 會即時監控您的 AWS 資源和您在 上執行的應用程式。透過 CloudWatch，您可以全面了解資源使用、應用程式效能和運作狀態。 [在開發 AWS IoT Events 偵測器模型時啟用 Amazon CloudWatch 記錄](best-practices.md#best-practices-cw-logs) 提供如何為 啟用 CloudWatch 記錄的相關資訊 AWS IoT Events。若要產生類似如下所示的日誌，您必須將**詳細程度**設定為「偵錯」，並提供一或多個**偵錯目標**，即**偵測器模型名稱**和選用的 **KeyValue**。

下列範例顯示 產生的 CloudWatch DEBUG 層級日誌項目 AWS IoT Events。

```
{
  "timestamp": "2019-03-15T15:56:29.412Z",
  "level": "DEBUG",
  "logMessage": "Summary of message evaluation",
  "context": "MessageEvaluation",
  "status": "Success",
  "messageId": "SensorAggregate_2th846h",
  "keyValue": "boiler_1",
  "detectorModelName": "BoilerAlarmDetector",
  "initialState": "high_temp_alarm",
  "initialVariables": {
    "high_temp_count": 1,
    "high_pressure_count": 1
  },
  "finalState": "no_alarm",
  "finalVariables": {
    "high_temp_count": 0,
    "high_pressure_count": 0
  },
  "message": "{ \"temp\": 34.9, \"pressure\": 84.5}",
  "messageType": "CUSTOMER_MESSAGE",
  "conditionEvaluationResults": [
    {
      "result": "True",
      "eventName": "alarm_cleared",
      "state": "high_temp_alarm",
      "lifeCycle": "OnInput",
      "hasTransition": true
    },
    {
      "result": "Skipped",
      "eventName": "alarm_escalated",
      "state": "high_temp_alarm",
      "lifeCycle": "OnInput",
      "hasTransition": true,
      "resultDetails": "Skipped due to transition from alarm_cleared event"
    },
    {
      "result": "True",
      "eventName": "should_recall_technician",
      "state": "no_alarm",
      "lifeCycle": "OnEnter",
      "hasTransition": true
    }
  ]
}
```