

Amazon Monitron 不再向新客戶開放。現有客戶可以繼續正常使用該服務。如需類似 Amazon Monitron 的功能，請參閱我們的[部落格文章](https://aws.amazon.com/blogs/machine-learning/maintain-access-and-consider-alternatives-for-amazon-monitron)。

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

# 使用 記錄 Amazon Monitron 動作 AWS CloudTrail
<a name="logging-using-cloudtrail"></a>

Amazon Monitron 已與 整合 AWS CloudTrail，此服務提供由 Amazon Monitron AWS 中的使用者、角色或服務所採取之動作的記錄。CloudTrail 會將 Amazon Monitron 的 API 呼叫擷取為事件。CloudTrail 會從 Amazon Monitron 主控台和 Amazon Monitron 行動應用程式擷取呼叫。如果您建立線索，則可以將 CloudTrail 事件持續交付至 Amazon Simple Storage Service (Amazon S3) 儲存貯體，包括 Amazon Monitron 的事件。即使您未設定追蹤，依然可以透過 CloudTrail 主控台中的**事件歷史記錄**檢視最新事件。您可以使用 CloudTrail 所收集的資訊，判斷向 Amazon Monitron 提出的主控台或行動應用程式請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間，以及其他詳細資訊。

若要進一步了解 CloudTrail，包括如何設定及啟用，請參閱[《AWS CloudTrail 使用者指南》](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)。

**Topics**
+ [CloudTrail 中的 Amazon Monitron 資訊](service-name-info-in-cloudtrail.md)
+ [範例：Amazon Monitron 日誌檔案項目](understanding-service-name-entries.md)

# CloudTrail 中的 Amazon Monitron 資訊
<a name="service-name-info-in-cloudtrail"></a>

當您建立帳戶時，會為您的 AWS 使用者啟用 CloudTrail。當 Amazon Monitron 中發生支援的事件活動時，該活動會與**事件歷史記錄**中的其他 AWS 服務事件一起記錄在 CloudTrail 事件中。您可以在 AWS 帳戶中檢視、搜尋和下載最近的事件。如需詳細資訊，請參閱《使用 CloudTrail 事件歷史記錄檢視事件》[https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。

若要持續記錄您 AWS 帳戶中的事件，包括 Amazon Monitron 的事件，請建立追蹤。*線索*能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。根據預設，當您在主控台中建立線索時，線索會套用至所有 AWS 區域。該追蹤會記錄來自 AWS 分割區中所有區域的事件，並將日誌檔案交付到您指定的 Amazon S3 儲存貯體。此外，您可以設定其他 AWS 服務，以進一步分析和處理 CloudTrail 日誌中所收集的事件資料。如需詳細資訊，請參閱下列內容：
+ [建立追蹤的概觀](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail 支援的服務和整合](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [設定 CloudTrail 的 Amazon SNS 通知](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [從多個區域接收 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html)，以及[從多個帳戶接收 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

Amazon Monitron 支援將許多動作記錄為事件。雖然操作可透過 AWS 主控台或 Amazon Monitron 行動應用程式公開存取，但 APIs 本身不公開，且可能會有所變更。它們僅用於記錄，不應使用它們建置應用程式。

Amazon Monitron 支援下列動作做為 CloudTrail 日誌檔案中的事件：
+ [CreateProject](https://docs.aws.amazon.com/Monitron/latest/user-guide/mp-creating-project.html)
+ [UpdateProject](https://docs.aws.amazon.com/Monitron/latest/user-guide/mp-updating-project.html)
+ [DeleteProject](https://docs.aws.amazon.com/Monitron/latest/user-guide/mp-delete-project.html)
+ [GetProject](https://docs.aws.amazon.com/Monitron/latest/user-guide/mp-project-tasks.html)
+ [ListProjects](https://docs.aws.amazon.com/Monitron/latest/user-guide/mp-project-tasks.html)
+ [AssociateProjectAdminUser](https://docs.aws.amazon.com/Monitron/latest/user-guide/mu-adding-user.html)
+ [DisassociateProjectAdminUser](https://docs.aws.amazon.com/Monitron/latest/user-guide/mu-remove-project-admin.html)
+ [ListProjectAdminUsers](https://docs.aws.amazon.com/Monitron/latest/user-guide/user-management-chapter.html)
+ [GetProjectAdminUser](https://docs.aws.amazon.com/Monitron/latest/user-guide/user-management-chapter.html)
+ [TagResource](https://docs.aws.amazon.com/Monitron/latest/user-guide/tagging.html#tag-original-1)
+ [UntagResource](https://docs.aws.amazon.com/Monitron/latest/user-guide/tagging.html#modify-tag-1)
+ [ListTagsForResource](https://docs.aws.amazon.com/Monitron/latest/user-guide/tagging.html)
+ [CreateSensor](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-add-sensors.html)
+ [UpdateSensor](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-edit-sensorposition.html)
+ [DeleteSensor](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-delete-sensor.html)
+ [CreateGateway](https://docs.aws.amazon.com/Monitron/latest/user-guide/adding-gateway.html)
+ [DeleteGateway](https://docs.aws.amazon.com/Monitron/latest/user-guide/deleting-gateway.html)
+ [CreateSite](https://docs.aws.amazon.com/Monitron/latest/user-guide/SM-creating-site.html)
+ [UpdateSite](https://docs.aws.amazon.com/Monitron/latest/user-guide/SM-editing-site.html)
+ [DeleteSite](https://docs.aws.amazon.com/Monitron/latest/user-guide/SM-deleting-site.html)
+ [CreateAsset](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-add-assets.html)
+ [UpdateAsset](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-edit-assets.html)
+ [DeleteAsset](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-delete-assets.html)
+ [CreateAssetStateTransition](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-assets.html)
+ [CreateUserAccessRoleAssociation](https://docs.aws.amazon.com/Monitron/latest/user-guide/what-is-monitron.html)
+ [UpdateUserAccessRoleAssociation](https://docs.aws.amazon.com/Monitron/latest/user-guide/what-is-monitron.html)
+ [DeleteUserAccessRoleAssociation](https://docs.aws.amazon.com/Monitron/latest/user-guide/what-is-monitron.html)
+ [FinishSensorCommissioning](https://docs.aws.amazon.com/Monitron/latest/user-guide/as-add-sensors.html)
+ [StartSensorCommissioning](https://docs.aws.amazon.com/Monitron/latest/user-guide/adding-position.html)

每一筆事件或日誌專案都會包含產生請求者的資訊。這包含提出請求的 IAM 身分類型，以及使用哪些登入資料的詳細資訊。如果使用暫時性登入資料，此元素會說明登入資料的取得方式。身分資訊可協助您判斷下列事項：
+ 是否使用根或 AWS Identity and Access Management (IAM) 使用者登入資料提出請求 
+ 提出該請求時，是否使用了特定角色或聯合身分使用者的臨時安全憑證
+ 請求是否由其他 AWS 服務提出

如需詳細資訊，請參閱《CloudTrail 使用者指南》*AWS *中的 [CloudTrail userIdentity 元素](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html)。

# 範例：Amazon Monitron 日誌檔案項目
<a name="understanding-service-name-entries"></a>

追蹤是一種組態，能讓事件以日誌檔案的形式交付到您指定的 Amazon S3 儲存貯體。CloudTrail 日誌檔案包含一或多個日誌專案。一個事件為任何來源提出的單一請求，並包含請求動作、請求的日期和時間、請求參數等資訊。CloudTrail 日誌檔並非依公有 API 呼叫的堆疊追蹤排序，因此不會以任何特定順序出現。

下列範例顯示示範專案刪除 (`DeleteProject`) 動作的 CloudTrail 日誌項目。

**Topics**
+ [成功的 DeleteProject 動作](#collapsible-section-1)
+ [DeleteProject 動作失敗 （授權錯誤）](#collapsible-section-2)
+ [DeleteProject 動作失敗 （衝突例外狀況錯誤）](#collapsible-section-3)

## 成功的 DeleteProject 動作
<a name="collapsible-section-1"></a>

下列範例顯示成功`DeleteProject`執行動作後CloudTrail 日誌中可能出現的內容。

```
{
  "eventVersion": "1.05",
  "userIdentity": {
    "type": "AssumedRole",
    "principalId": "principal ID",
    "arn": "ARN",
    "accountId": "account ID",
    "accessKeyId": "access key ID",
    "sessionContext": {
      "sessionIssuer": {
        "type": "Role",
        "principalId": "principal ID",
        "arn": "ARN",
        "accountId": "account ID",
        "userName": "user name"
      },
      "webIdFederationData": {},
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "timestamp"
      }
    }
  },
  "eventTime": "timestamp",
  "eventSource": "monitron.amazonaws.com",
  "eventName": "DeleteProject",
  "awsRegion": "region",
  "sourceIPAddress": "source IP address",
  "userAgent": "user agent",
  "requestParameters": {
    "Name": "name"
  },
  "responseElements": {
    "Name": "name"
  },
  "requestID": "request ID",
  "eventID": "event ID",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "recipientAccountId": "account ID"
}
```

## DeleteProject 動作失敗 （授權錯誤）
<a name="collapsible-section-2"></a>

下列範例顯示由於發生錯誤而失敗`DeleteProject`的動作後CloudTrail 日誌中可能會出現的內容。在此情況下，錯誤是授權錯誤，使用者沒有刪除指定專案的許可。

```
{
    "eventVersion": "1.05",
    "userIdentity": {
        "type": "IAMUser",
        "principalId": "principal ID",
        "arn": "ARN",
        "accountId": "account ID",
        "accessKeyId": "access key ID",
        "userName": "user name",
        "sessionContext": {
            "sessionIssuer": {},
            "webIdFederationData": {},
            "attributes": {
                "mfaAuthenticated": "false",
                "creationDate": "timestamp"
            }
        }
    },
    "eventTime": "timestamp",
    "eventSource": "monitron.amazonaws.com",
    "eventName": "DeleteProject",
    "awsRegion": "region",
    "sourceIPAddress": "source IP address",
    "userAgent": "user agent",
    "errorCode": "AccessDenied",
    "requestParameters": {
        "Name": "name"
    },
    "responseElements": {
        "Message": "User: user ARN is not authorized to perform: monitron:DeleteProject on resource: resource ARN"
    },
    "requestID": "request ID",
    "eventID": "event ID",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "recipientAccountId": "account ID"
}
```

## DeleteProject 動作失敗 （衝突例外狀況錯誤）
<a name="collapsible-section-3"></a>

下列範例顯示由於發生錯誤而失敗`DeleteProject`的動作後CloudTrail 日誌中可能會出現的內容。在此情況下，錯誤是衝突例外狀況，當 Amazon Monitron 嘗試刪除專案時，感應器仍然存在。

```
{
  "eventVersion": "1.05",
  "userIdentity": {
    "type": "AssumedRole",
    "principalId": "principal ID",
    "arn": "ARN",
    "accountId": "account ID",
    "accessKeyId": "access key ID",
    "sessionContext": {
      "sessionIssuer": {
        "type": "Role",
        "principalId": "principal ID",
        "arn": "ARN",
        "accountId": "account ID",
        "userName": "user name"
      },
      "webIdFederationData": {},
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "timestamp"
      }
    }
  },
  "eventTime": "timestamp",
  "eventSource": "monitron.amazonaws.com",
  "eventName": "DeleteProject",
  "awsRegion": "region",
  "sourceIPAddress": "source IP address",
  "userAgent": "user agent",
  "errorCode": "ConflictException",
  "requestParameters": {
    "Name": "name"
  },
  "responseElements": {
    "message": "This project still has sensors associated to it and cannot be deleted."
  },
  "requestID": "request ID",
  "eventID": "event ID",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "recipientAccountId": "account ID"
}
```