使用 Amazon CloudTrail 记录 Amazon CloudWatch API 和控制台操作 - Amazon CloudWatch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

使用 Amazon CloudTrail 记录 Amazon CloudWatch API 和控制台操作

Amazon CloudWatch、CloudWatch Synthetics、CloudWatch RUM 和 CloudWatch Internet Monitor 与 Amazon CloudTrail 集成,后者是一种提供用户、角色或 Amazon 服务所采取操作的记录的服务。CloudTrail 捕获由您的 Amazon 账户发出或代表该账户发出的 API 调用。捕获的调用包括来自 CloudWatch 控制台的调用和对 CloudWatch API 操作的代码调用。借助 CloudTrail 收集的信息,您可以确定向 CloudWatch 发出的请求、发出请求的 IP 地址、请求的发出时间及其他详细信息。

每个事件或日记账条目都包含有关生成请求的人员信息。身份信息有助于您确定以下内容:

  • 请求是使用根用户凭证还是用户凭证发出的。

  • 请求是否代表 IAM Identity Center 用户发出。

  • 请求是使用角色还是联合用户的临时安全凭证发出的。

  • 请求是否由其他 Amazon Web Services 服务 发出。

当您创建账户并可以自动访问 CloudTrail 事件历史记录时,CloudTrail 在您的 Amazon Web Services 账户 中处于活动状态。CloudTrail 事件历史记录提供对 Amazon Web Services 区域 中过去 90 天的已记录管理事件的可查看、可搜索、可下载和不可变记录。有关更多信息,请参见《Amazon CloudTrail 用户指南》的 使用 CloudTrail 事件历史记录。查看事件历史记录不会收取 CloudTrail 费用。

要持续记录您的 Amazon Web Services 账户 过去 90 天的事件,请创建跟踪或 CloudTrail Lake 事件数据存储。

CloudTrail 跟踪

通过跟踪记录,CloudTrail 可将日志文件传送至 Simple Storage Service (Amazon S3) 存储桶。使用 Amazon Web Services Management Console 创建的所有跟踪均具有多区域属性。您可以通过使用 Amazon CLI 创建单区域或多区域跟踪。建议创建多区域跟踪,因为您可记录您账户中的所有 Amazon Web Services 区域 的活动。如果您创建单区域跟踪,则只能查看跟踪的 Amazon Web Services 区域 中记录的事件。有关跟踪的更多信息,请参阅《Amazon CloudTrail 用户指南》中的为您的 Amazon Web Services 账户 创建跟踪为组织创建跟踪

通过创建跟踪,您可以从 CloudTrail 免费向您的 Amazon S3 存储桶传送一份正在进行的管理事件的副本,但会收取 Amazon S3 存储费用。有关 CloudTrail 定价的更多信息,请参阅 Amazon CloudTrail 定价。有关 Amazon S3 定价的信息,请参阅 Amazon S3 定价

CloudTrail Lake 事件数据存储

CloudTrail Lake 允许您对事件运行基于 SQL 的查询。CloudTrail Lake 可将基于行的 JSON 格式的现有事件转换为 Apache ORC 格式。ORC 是一种针对快速检索数据进行优化的列式存储格式。事件将被聚合到事件数据存储中,它是基于您通过应用高级事件选择器选择的条件的不可变的事件集合。应用于事件数据存储的选择器用于控制哪些事件持续存在并可供您查询。有关 CloudTrail Lake 的更多信息,请参阅《Amazon CloudTrail 用户指南》中的使用 Amazon CloudTrail Lake

CloudTrail Lake 事件数据存储和查询会产生费用。创建事件数据存储时,您可以选择要用于事件数据存储的定价选项。定价选项决定了摄取和存储事件的成本,以及事件数据存储的默认和最长保留期。有关 CloudTrail 定价的更多信息,请参阅 Amazon CloudTrail 定价

注意

有关 CloudTrail 中记录的 CloudWatch Logs API 调用的信息,请参阅 CloudTrail 中的 CloudWatch Logs 信息

CloudTrail 中的 CloudWatch 信息

CloudWatch 支持将以下操作记录为 CloudTrail 日志文件中的事件:

示例:CloudWatch 日志文件条目

下面的示例显示了一个 CloudTrail 日志条目,该条目演示了 PutMetricAlarm 操作。

{ "Records": [{ "eventVersion": "1.01", "userIdentity": { "type": "Root", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:root", "accountId": "123456789012", "accessKeyId": "EXAMPLE_KEY_ID" }, "eventTime": "2014-03-23T21:50:34Z", "eventSource": "monitoring.amazonaws.com", "eventName": "PutMetricAlarm", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-ruby2/2.0.0.rc4 ruby/1.9.3 x86_64-linux Seahorse/0.1.0", "requestParameters": { "threshold": 50.0, "period": 60, "metricName": "CloudTrail Test", "evaluationPeriods": 3, "comparisonOperator": "GreaterThanThreshold", "namespace": "AWS/CloudWatch", "alarmName": "CloudTrail Test Alarm", "statistic": "Sum" }, "responseElements": null, "requestID": "29184022-b2d5-11e3-a63d-9b463e6d0ff0", "eventID": "b096d5b7-dcf2-4399-998b-5a53eca76a27" }, ..additional entries ] }

以下日志文件条目显示某个用户调用了 CloudWatch Events PutRule 操作。

{ "eventVersion":"1.03", "userIdentity":{ "type":"Root", "principalId":"123456789012", "arn":"arn:aws:iam::123456789012:root", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "sessionContext":{ "attributes":{ "mfaAuthenticated":"false", "creationDate":"2015-11-17T23:56:15Z" } } }, "eventTime":"2015-11-18T00:11:28Z", "eventSource":"events.amazonaws.com", "eventName":"PutRule", "awsRegion":"us-east-1", "sourceIPAddress":"AWS Internal", "userAgent":"AWS CloudWatch Console", "requestParameters":{ "description":"", "name":"cttest2", "state":"ENABLED", "eventPattern":"{\"source\":[\"aws.ec2\"],\"detail-type\":[\"EC2 Instance State-change Notification\"]}", "scheduleExpression":"" }, "responseElements":{ "ruleArn":"arn:aws:events:us-east-1:123456789012:rule/cttest2" }, "requestID":"e9caf887-8d88-11e5-a331-3332aa445952", "eventID":"49d14f36-6450-44a5-a501-b0fdcdfaeb98", "eventType":"AwsApiCall", "apiVersion":"2015-10-07", "recipientAccountId":"123456789012" }

以下日志文件条目显示某个用户调用了 CloudWatch Logs CreateExportTask 操作。

{ "eventVersion": "1.03", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/someuser", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "someuser" }, "eventTime": "2016-02-08T06:35:14Z", "eventSource": "logs.amazonaws.com", "eventName": "CreateExportTask", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-ruby2/2.0.0.rc4 ruby/1.9.3 x86_64-linux Seahorse/0.1.0", "requestParameters": { "destination": "yourdestination", "logGroupName": "yourloggroup", "to": 123456789012, "from": 0, "taskName": "yourtask" }, "responseElements": { "taskId": "15e5e534-9548-44ab-a221-64d9d2b27b9b" }, "requestID": "1cd74c1c-ce2e-12e6-99a9-8dbb26bd06c9", "eventID": "fd072859-bd7c-4865-9e76-8e364e89307c", "eventType": "AwsApiCall", "apiVersion": "20140328", "recipientAccountId": "123456789012" }

CloudTrail 中的 CloudWatch 数据事件

CloudTrail 可以捕获与 CloudWatch 数据面板操作 GetMetricDataGetMetricWidgetImage 相关的 API 活动。

数据事件也称为数据面板操作,可让您深入了解在资源上或资源内执行的资源操作。数据事件通常是高容量活动。

默认情况下,CloudTrail 不记录数据事件。CloudTrail 事件历史记录不记录数据事件。

记录数据事件将收取额外费用。有关 CloudTrail 定价的更多信息,请参阅 Amazon CloudTrail 定价

您可以使用 CloudTrail 控制台、Amazon CLI 或 CloudTrail API 操作记录 CloudWatch 资源类型的数据事件。有关如何记录数据事件的更多信息,请参阅《Amazon CloudTrail 用户指南》中的使用 Amazon Web Services Management Console 记录数据事件使用 Amazon Command Line Interface 记录数据事件

可以按资源类型筛选数据面板事件。由于在 CloudTrail 中使用数据事件会产生额外费用,因此按资源筛选可以让您更好地控制自己记录和支付费用的内容。

使用 CloudTrail 收集的信息,可以确定向 CloudWatch GetMetricData 或 GetMetricWidgetImage API 发出的特定请求、请求者的 IP 地址、请求者的身份以及请求的日期和时间。使用 CloudTrail 记录 GetMetricDataGetMetricWidgetImage API 可帮助您实现 Amazon 账户的运营和风险审计、治理与合规性。

注意

当您在 CloudTrail 中查看 GetMetricData 事件时,可能会看到比您发起的调用更多的调用。这是因为 CloudWatch 将由内部组件发起的 GetMetricData 操作的事件记录到 CloudTrail。例如,在跨账户可观测性中,您将看到 CloudWatch 控制面板发起 GetMetricData 调用以刷新小组件数据,而监控账户发起 GetMetricData 调用以从源账户检索数据。这些内部发起的调用不会产生 CloudWatch 费用,但会计入 CloudTrail 中记录的事件数量,而 CloudTrail 根据记录的事件数量收费。

以下是 GetMetricData 操作的 CloudTrail 事件示例。

{ "eventVersion": "1.09", "userIdentity": { "type": "IAMUser", "principalId": "AIDA2NYTR2EPCTNY7AF3L", "arn": "arn:aws:iam::111122223333:user/admin", "accountId": "111122223333", "accessKeyId": "EXAMPLE1234567890", "userName": "admin" }, "eventTime": "2024-05-08T16:20:34Z", "eventSource": "monitoring.amazonaws.com", "eventName": "GetMetricData", "awsRegion": "us-east-1", "sourceIPAddress": "99.45.3.7", "userAgent": "aws-cli/2.13.23 Python/3.11.5 Darwin/23.4.0 exe/x86_64 prompt/off command/cloudwatch.get-metric-data", "requestParameters": { "metricDataQueries": [{ "id": "e1", "expression": "m1 / m2", "label": "ErrorRate" }, { "id": "m1", "metricStat": { "metric": { "namespace": "CWAgent", "metricName": "disk_used_percent", "dimensions": [{ "name": "LoadBalancerName", "value": "EXAMPLE4623a5cb6a7384c5229" }] }, "period": 300, "stat": "Sum", "unit": "Count" }, "returnData": false }, { "id": "m2", "metricStat": { "metric": { "namespace": "CWAgent", "metricName": "disk_used_percent", "dimensions": [{ "name": "LoadBalancerName", "value": "EXAMPLE4623a5cb6a7384c5229" }] }, "period": 300, "stat": "Sum" }, "returnData": true } ], "startTime": "Apr 19, 2024, 4:00:00 AM", "endTime": "May 8, 2024, 4:30:00 AM" }, "responseElements": null, "requestID": "EXAMPLE-57ac-47d5-938c-f5917c6799d5", "eventID": "EXAMPLE-211c-404b-b13d-36d93c8b4fbf", "readOnly": true, "resources": [{ "type": "AWS::CloudWatch::Metric" }], "eventType": "AwsApiCall", "managementEvent": false, "recipientAccountId": "111122223333", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "monitoring.us-east-1.amazonaws.com" } }

CloudTrail 中的查询生成信息

还支持查询生成器控制台事件的 CloudTrail 日志记录。查询生成器目前支持 CloudWatch Metric Insights 和 CloudWatch Logs Insights。在这些 CloudTrail 事件中,eventSourcemonitoring.amazonaws.com

以下示例显示了一个 CloudTrail 日志条目,该条目演示了 CloudWatch Metrics Insights 中的 GenerateQuery 操作。

{ "eventVersion": "1.09", "userIdentity": { "type": "AssumedRole", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:assumed-role/role_name", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::111222333444:role/Administrator", "accountId": "123456789012", "userName": "SAMPLE_NAME" }, "attributes": { "creationDate": "2020-04-08T21:43:24Z", "mfaAuthenticated": "false" } } }, "eventTime": "2020-04-08T23:06:30Z", "eventSource": "monitoring.amazonaws.com", "eventName": "GenerateQuery", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "exampleUserAgent", "requestParameters": { "query_ask": "***", "query_type": "MetricsInsights", "metrics_insights": { "aws_namespaces": [ "AWS/S3", "AWS/Lambda", "AWS/DynamoDB" ] }, "include_description": true }, "responseElements": null, "requestID": "2f56318c-cfbd-4b60-9d93-1234567890", "eventID": "52723fd9-4a54-478c-ac55-1234567890", "readOnly": true, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }

CloudTrail 中的 CloudWatch Internet Monitor

CloudWatch 互联网监测仪支持将以下操作记录为 CloudTrail 日志文件中的事件。

示例:CloudWatch Internet Monitor 日志文件条目

以下示例显示了一个 CloudTrail Internet Monitor 日志条目,该条目演示了 ListMonitors 操作。

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::000000000000:assumed-role/role_name", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::000000000000:role/Admin", "accountId":"123456789012", "userName": "SAMPLE_NAME" }, "webIdFederationData": {}, "attributes": { "creationDate": "2022-10-11T17:25:41Z", "mfaAuthenticated": "false" } } }, "eventTime": "2022-10-11T17:30:18Z", "eventSource": "internetmonitor.amazonaws.com", "eventName": "ListMonitors", "awsRegion": "us-east-2", "sourceIPAddress": "192.0.2.0", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)", "requestParameters": null, "responseElements": null, "requestID": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "eventID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb", "readOnly": true, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }

以下示例显示了一个 CloudTrail Internet Monitor 日志条目,该条目演示了 CreateMonitor 操作。

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::000000000000:assumed-role/role_name", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::000000000000:role/Admin", "accountId":"123456789012", "userName": "SAMPLE_NAME" }, "webIdFederationData": {}, "attributes": { "creationDate": "2022-10-11T17:25:41Z", "mfaAuthenticated": "false" } } }, "eventTime": "2022-10-11T17:30:08Z", "eventSource": "internetmonitor.amazonaws.com", "eventName": "CreateMonitor", "awsRegion": "us-east-2", "sourceIPAddress": "192.0.2.0", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)", "requestParameters": { "MonitorName": "TestMonitor", "Resources": ["arn:aws:ec2:us-east-2:444455556666:vpc/vpc-febc0b95"], "ClientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333" }, "responseElements": { "Arn": "arn:aws:internetmonitor:us-east-2:444455556666:monitor/ct-onboarding-test", "Status": "PENDING" }, "requestID": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "eventID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }

CloudTrail 中的 CloudWatch Synthetics 信息

CloudWatch Synthetics 支持在 CloudTrail 日志文件中将以下操作记录为事件:

示例:CloudWatch Synthetics 日志文件条目

下面的示例显示了一个 CloudTrail Synthetics 日志条目,该条目说明了 DescribeCanaries 操作。

{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:assumed-role/role_name", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::111222333444:role/Administrator", "accountId":"123456789012", "userName": "SAMPLE_NAME" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-04-08T21:43:24Z" } } }, "eventTime": "2020-04-08T23:06:47Z", "eventSource": "synthetics.amazonaws.com", "eventName": "DescribeCanaries", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-internal/3 aws-sdk-java/1.11.590 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.212-b03 java/1.8.0_212 vendor/Oracle_Corporation", "requestParameters": null, "responseElements": null, "requestID": "201ed5f3-15db-4f87-94a4-123456789", "eventID": "73ddbd81-3dd0-4ada-b246-123456789", "readOnly": true, "eventType": "AwsApiCall", "recipientAccountId": "111122223333" }

下面的示例显示了一个 CloudTrail Synthetics 日志条目,该条目说明了 UpdateCanary 操作。

{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:assumed-role/role_name", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::111222333444:role/Administrator", "accountId":"123456789012", "userName": "SAMPLE_NAME" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-04-08T21:43:24Z" } } }, "eventTime": "2020-04-08T23:06:47Z", "eventSource": "synthetics.amazonaws.com", "eventName": "UpdateCanary", "awsRegion": "us-east-1", "sourceIPAddress": "192.0.2.0", "userAgent": "aws-internal/3 aws-sdk-java/1.11.590 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.212-b03 java/1.8.0_212 vendor/Oracle_Corporation", "requestParameters": { "Schedule": { "Expression": "rate(1 minute)" }, "name": "sample_canary_name", "Code": { "Handler": "myOwnScript.handler", "ZipFile": "SAMPLE_ZIP_FILE" } }, "responseElements": null, "requestID": "fe4759b0-0849-4e0e-be71-1234567890", "eventID": "9dc60c83-c3c8-4fa5-bd02-1234567890", "readOnly": false, "eventType": "AwsApiCall", "recipientAccountId": "111122223333" }

下面的示例显示了一个 CloudTrail Synthetics 日志条目,该条目说明了 GetCanaryRuns 操作。

{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:assumed-role/role_name", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::111222333444:role/Administrator", "accountId":"123456789012", "userName": "SAMPLE_NAME" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-04-08T21:43:24Z" } } }, "eventTime": "2020-04-08T23:06:30Z", "eventSource": "synthetics.amazonaws.com", "eventName": "GetCanaryRuns", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-internal/3 aws-sdk-java/1.11.590 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.212-b03 java/1.8.0_212 vendor/Oracle_Corporation", "requestParameters": { "Filter": "TIME_RANGE", "name": "sample_canary_name", "FilterValues": [ "2020-04-08T23:00:00.000Z", "2020-04-08T23:10:00.000Z" ] }, "responseElements": null, "requestID": "2f56318c-cfbd-4b60-9d93-1234567890", "eventID": "52723fd9-4a54-478c-ac55-1234567890", "readOnly": true, "eventType": "AwsApiCall", "recipientAccountId": "111122223333" }

CloudTrail 中的 CloudWatch RUM 信息

CloudWatch RUM 支持将以下操作记录为 CloudTrail 日志文件中的事件:

示例:CloudWatch RUM 日志文件条目

本节包含某些 CloudWatch RUM API 的 CloudTrail 条目示例。

以下示例是演示 CreateAppMonitor 操作的 CloudTrail 日志条目。

{ "eventVersion": "1.09", "userIdentity": { "type": "AssumedRole", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:sts::777777777777:assumed-role/EXAMPLE", "accountId": "777777777777", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:iam::777777777777:role/EXAMPLE", "accountId": "777777777777", "userName": "USERNAME_EXAMPLE" }, "attributes": { "creationDate": "2024-07-23T16:48:47Z", "mfaAuthenticated": "false" } } }, "eventTime": "2024-07-23T18:02:57Z", "eventSource": "rum.amazonaws.com", "eventName": "CreateAppMonitor", "awsRegion": "us-east-1", "sourceIPAddress": "54.240.198.39", "userAgent": "aws-internal/3 aws-sdk-java/1.12.641 Linux/5.10.219-186.866.amzn2int.x86_64 OpenJDK_64-Bit_Server_VM/25.402-b08 java/1.8.0_402 vendor/Oracle_Corporation cfg/retry-mode/standard", "requestParameters": { "CustomEvents": { "Status": "ENABLED" }, "CwLogEnabled": true, "Domain": "*.github.io", "AppMonitorConfiguration": { "SessionSampleRate": 1, "IncludedPages": [], "ExcludedPages": [], "Telemetries": [ "performance", "errors", "http" ], "EnableXRay": false, "AllowCookies": true, "IdentityPoolId": "us-east-1:c81b9a1c-a5c9-4de5-8585-eb8df04e66f0" }, "Tags": { "TestAppMonitor": "" }, "Name": "TestAppMonitor" }, "responseElements": { "Id": "65a8cc63-4ae8-4f2c-b5fc-4a54ef43af51" }, "requestID": "cf7c30ad-25d3-4274-bab1-39c95a558007", "eventID": "2d43cc69-7f89-4f1a-95ae-0fc7e9b9fb3b", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "777777777777", "eventCategory": "Management" }

以下示例是演示 PutRumMetricsDestination 操作的 CloudTrail 日志条目。

{ "eventVersion": "1.09", "userIdentity": { "type": "AssumedRole", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:sts::777777777777:assumed-role/EXAMPLE", "accountId": "777777777777", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:iam::777777777777:role/EXAMPLE", "accountId": "777777777777", "userName": "USERNAME_EXAMPLE" }, "attributes": { "creationDate": "2024-07-23T16:48:47Z", "mfaAuthenticated": "false" } } }, "eventTime": "2024-07-23T18:22:22Z", "eventSource": "rum.amazonaws.com", "eventName": "PutRumMetricsDestination", "awsRegion": "us-east-1", "sourceIPAddress": "52.94.133.142", "userAgent": "aws-cli/2.13.25 Python/3.11.5 Linux/5.10.219-186.866.amzn2int.x86_64 exe/x86_64.amzn.2 prompt/off command/rum.put-rum-metrics-destination", "requestParameters": { "Destination": "CloudWatch", "AppMonitorName": "TestAppMonitor" }, "responseElements": null, "requestID": "9b03fcce-b3a2-44fc-b771-900e1702998a", "eventID": "6250f9b7-0505-4f96-9668-feb64f82de5b", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "777777777777", "eventCategory": "Management" }

下面的示例显示了一个 CloudTrail 日志条目,该条目演示了 BatchCreateRumMetricsDefinitions 操作。

{ "eventVersion": "1.09", "userIdentity": { "type": "AssumedRole", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:sts::777777777777:assumed-role/EXAMPLE", "accountId": "777777777777", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:iam::777777777777:role/EXAMPLE", "accountId": "777777777777", "userName": "USERNAME_EXAMPLE" }, "attributes": { "creationDate": "2024-07-23T16:48:47Z", "mfaAuthenticated": "false" } } }, "eventTime": "2024-07-23T18:23:11Z", "eventSource": "rum.amazonaws.com", "eventName": "BatchCreateRumMetricDefinitions", "awsRegion": "us-east-1", "sourceIPAddress": "52.94.133.142", "userAgent": "aws-cli/2.13.25 Python/3.11.5 Linux/5.10.219-186.866.amzn2int.x86_64 exe/x86_64.amzn.2 prompt/off command/rum.batch-create-rum-metric-definitions", "requestParameters": { "Destination": "CloudWatch", "MetricDefinitions": [ { "Name": "NavigationToleratedTransaction", "Namespace": "AWS/RUM", "DimensionKeys": { "metadata.browserName": "BrowserName" }, "EventPattern": "{\"metadata\":{\"browserName\":[\"Chrome\"]},\"event_type\":[\"com.amazon.rum.performance_navigation_event\"],\"event_details\": {\"duration\": [{\"numeric\": [\"<=\",2000,\"<\",8000]}]}}" }, { "Name": "HttpErrorCount", "DimensionKeys": { "metadata.browserName": "BrowserName", "metadata.countryCode": "CountryCode" }, "EventPattern": "{\"metadata\":{\"browserName\":[\"Chrome\"], \"countryCode\":[\"US\"]},\"event_type\":[\"com.amazon.rum.http_event\"]}" } ], "AppMonitorName": "TestAppMonitor" }, "responseElements": { "Errors": [], "MetricDefinitions": [] }, "requestID": "b14c5eda-f107-48e5-afae-1ac20d0962a8", "eventID": "001b55c6-1de1-48c0-a236-31096dffe249", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "777777777777", "eventCategory": "Management" }

CloudTrail 中的 CloudWatch RUM 数据面板事件

CloudTrail 可以捕获与 CloudWatch RUM 数据面板操作 PutRumEvents 相关的 API 活动。

数据事件也称为数据面板操作,可让您深入了解在资源上或资源内执行的资源操作。数据事件通常是高容量活动。

要在 CloudTrail 中启用 PutRumEvents 数据事件日志记录,需要在 CloudTrail 中启用数据面板 API 活动日志记录。有关更多信息,请参阅记录数据事件用于跟踪

可以按资源类型筛选数据面板事件。由于在 CloudTrail 中使用数据事件会产生额外费用,因此按资源筛选可以让您更好地控制自己记录和支付费用的内容。

使用 CloudTrail 收集的信息,可以确定向 CloudWatch RUM PutRumEvents API 发出的特定请求、请求者的 IP 地址、请求者的身份以及请求的日期和时间。使用 CloudTrail 记录 PutRumEvents API 可帮助您实现 Amazon 账户的运营和风险审计、治理与合规性。

以下示例显示一个 CloudTrail 日志条目,该条目演示 PutRumEvents 操作。

{ "Records": [ { "eventVersion": "1.09", "userIdentity": { "type": "AssumedRole", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:sts::777777777777:assumed-role/EXAMPLE", "accountId": "777777777777", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "EXAMPLE_PRINCIPAL_ID", "arn": "arn:aws:iam::777777777777:role/EXAMPLE", "accountId": "777777777777", "userName": "USERNAME_EXAMPLE" }, "attributes": { "creationDate": "2024-05-16T20:32:39Z", "mfaAuthenticated": "false" } }, "invokedBy": "AWS Internal" }, "eventTime": "2024-05-16T20:32:42Z", "eventSource": "rum.amazonaws.com", "eventName": "PutRumEvents", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "requestParameters": { "id": "73ddbd81-1234-5678-b246-123456789", "batchId": "123456-3dd0-4ada-b246-123456789", "appMonitorDetails": { "name": "APP-MONITOR-NAME", "id": "123456-3dd0-4ada-b246-123456789", "version": "1.0.0" }, "userDetails": { "userId": "73ddbd81-1111-9999-b246-123456789", "sessionId": "a1b2c3456-15db-4f87-6789-123456789" }, "rumEvents": [ { "id": "201f367a-15db-1234-94a4-123456789", "timestamp": "May 16, 2024, 8:32:20 PM", "type": "com.amazon.rum.dom_event", "metadata": "{}", "details": "{}" } ] }, "responseElements": null, "requestID": "201ed5f3-15db-4f87-94a4-123456789", "eventID": "73ddbd81-3dd0-4ada-b246-123456789", "readOnly": false, "resources": [ { "accountId": "777777777777", "type": "AWS::RUM::AppMonitor", "ARN": "arn:aws:rum:us-east-1:777777777777:appmonitor/APPMONITOR_NAME_EXAMPLE" } ], "eventType": "AwsApiCall", "managementEvent": false, "recipientAccountId": "777777777777", "eventCategory": "Data" } ] }