使用 AWS CloudTrail 記錄 Amazon ElastiCache API 呼叫 - Amazon ElastiCache

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

使用 AWS CloudTrail 記錄 Amazon ElastiCache API 呼叫

Amazon ElastiCache 已與 AWS CloudTrail 整合,這項服務可提供由使用者、角色或 Amazon ElastiCache 中 AWS 服務所採取之動作的記錄。CloudTrail 將 Amazon ElastiCache 的所有 API 呼叫擷取為事件,包括來自 Amazon ElastiCache 主控台的呼叫以及來自對 Amazon ElastiCache API 作業發出的程式碼呼叫。如果您建立追蹤記錄,就可以持續傳送 CloudTrail 事件至 Amazon S3 儲存貯體,包括 Amazon ElastiCache 的事件。即使您未設定追蹤,依然可以透過 CloudTrail 主控台中的 Event history (事件歷史記錄) 檢視最新事件。您可以利用 CloudTrail 所收集的資訊來判斷向 Amazon ElastiCache 發出的請求,以及發出請求的 IP 地址、人員、時間和其他詳細資訊。

若要進一步了解 CloudTrail,請參閱《AWS CloudTrail 使用者指南》

CloudTrail 中的 Amazon ElastiCache 資訊

當您建立帳戶時,系統即會在 AWS 帳戶中啟用 CloudTrail。在 Amazon ElastiCache 中發生活動時,該活動將與 Event history (事件歷史紀錄) 中的其他 AWS 服務事件一起記錄在 CloudTrail 事件中。您可以檢視、搜尋和下載 AWS 帳戶的最新事件。如需詳細資訊,請參閱使用 CloudTrail 事件歷史記錄檢視事件

若要持續記錄您 AWS 帳戶中正在進行的事件 (包括 Amazon ElastiCache 的事件),請建立追蹤記錄。追蹤能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。根據預設,當您在主控台建立權杖時,權杖會套用到所有區域。該追蹤會記錄來自 AWS 分割區中所有區域的事件,並將日誌檔案交付到您指定的 Amazon S3 儲存貯體。此外,您可以設定其他 AWS 服務,以進一步分析和處理 CloudTrail 日誌中所收集的事件資料。如需詳細資訊,請參閱下列內容:

CloudTrail 會記錄所有Amazon ElastiCache 動作,並記載於 ElastiCache API 參考中。例如,對 CreateCacheClusterDescribeCacheClusterModifyCacheCluster 動作發出的呼叫會在 CloudTrail 記錄檔案中產生項目。

每一筆事件或日誌項目都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項:

  • 該請求是否使用根或 IAM 使用者憑證提出。

  • 提出該請求時,是否使用了特定角色或聯合身分使用者的暫時安全憑證。

  • 該請求是否由另一項 AWS 服務提出。

如需詳細資訊,請參閱 CloudTrail userIdentity 元素

了解 Amazon ElastiCache 日誌檔案項目

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

以下範例顯示的是展示 CreateCacheCluster 動作的 CloudTrail 日誌項目。

{ "eventVersion":"1.01", "userIdentity":{ "type":"IAMUser", "principalId":"EXAMPLEEXAMPLEEXAMPLE", "arn":"arn:aws:iam::123456789012:user/elasticache-allow", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "userName":"elasticache-allow" }, "eventTime":"2014-12-01T22:00:35Z", "eventSource":"elasticache.amazonaws.com", "eventName":"CreateCacheCluster", "awsRegion":"us-west-2", "sourceIPAddress":"192.0.2.01", "userAgent":"AWS CLI/ElastiCache 1.10 API 2014-12-01", "requestParameters":{ "numCacheNodes":2, "cacheClusterId":"test-memcached", "engine":"memcached", "aZMode":"cross-az", "cacheNodeType":"cache.m1.small", }, "responseElements":{ "engine":"memcached", "clientDownloadLandingPage":"https://console.aws.amazon.com/elasticache/home#client-download:", "cacheParameterGroup":{ "cacheParameterGroupName":"default.memcached1.4", "cacheNodeIdsToReboot":{ }, "parameterApplyStatus":"in-sync" }, "preferredAvailabilityZone":"Multiple", "numCacheNodes":2, "cacheNodeType":"cache.m1.small", "cacheClusterStatus":"creating", "autoMinorVersionUpgrade":true, "preferredMaintenanceWindow":"thu:05:00-thu:06:00", "cacheClusterId":"test-memcached", "engineVersion":"1.4.14", "cacheSecurityGroups":[ { "status":"active", "cacheSecurityGroupName":"default" } ], "pendingModifiedValues":{ } }, "requestID":"104f30b3-3548-11e4-b7b8-6d79ffe84edd", "eventID":"92762127-7a68-42ce-8787-927d2174cde1" }

以下範例顯示的是展示 DescribeCacheCluster 動作的 CloudTrail 日誌項目。請注意,所有 Amazon ElastiCache Describe 呼叫 (ResponseElements) 都已移除 Describe* 區段,並顯示為 null

{ "eventVersion":"1.01", "userIdentity":{ "type":"IAMUser", "principalId":"EXAMPLEEXAMPLEEXAMPLE", "arn":"arn:aws:iam::123456789012:user/elasticache-allow", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "userName":"elasticache-allow" }, "eventTime":"2014-12-01T22:01:00Z", "eventSource":"elasticache.amazonaws.com", "eventName":"DescribeCacheClusters", "awsRegion":"us-west-2", "sourceIPAddress":"192.0.2.01", "userAgent":"AWS CLI/ElastiCache 1.10 API 2014-12-01", "requestParameters":{ "showCacheNodeInfo":false, "maxRecords":100 }, "responseElements":null, "requestID":"1f0b5031-3548-11e4-9376-c1d979ba565a", "eventID":"a58572a8-e81b-4100-8e00-1797ed19d172" }

以下範例顯示的是記錄 ModifyCacheCluster 動作的 CloudTrail 日誌項目。

{ "eventVersion":"1.01", "userIdentity":{ "type":"IAMUser", "principalId":"EXAMPLEEXAMPLEEXAMPLE", "arn":"arn:aws:iam::123456789012:user/elasticache-allow", "accountId":"123456789012", "accessKeyId":"AKIAIOSFODNN7EXAMPLE", "userName":"elasticache-allow" }, "eventTime":"2014-12-01T22:32:21Z", "eventSource":"elasticache.amazonaws.com", "eventName":"ModifyCacheCluster", "awsRegion":"us-west-2", "sourceIPAddress":"192.0.2.01", "userAgent":"AWS CLI/ElastiCache 1.10 API 2014-12-01", "requestParameters":{ "applyImmediately":true, "numCacheNodes":3, "cacheClusterId":"test-memcached" }, "responseElements":{ "engine":"memcached", "clientDownloadLandingPage":"https://console.aws.amazon.com/elasticache/home#client-download:", "cacheParameterGroup":{ "cacheParameterGroupName":"default.memcached1.4", "cacheNodeIdsToReboot":{ }, "parameterApplyStatus":"in-sync" }, "cacheClusterCreateTime":"Dec 1, 2014 10:16:06 PM", "preferredAvailabilityZone":"Multiple", "numCacheNodes":2, "cacheNodeType":"cache.m1.small", "cacheClusterStatus":"modifying", "autoMinorVersionUpgrade":true, "preferredMaintenanceWindow":"thu:05:00-thu:06:00", "cacheClusterId":"test-memcached", "engineVersion":"1.4.14", "cacheSecurityGroups":[ { "status":"active", "cacheSecurityGroupName":"default" } ], "configurationEndpoint":{ "address":"test-memcached.example.cfg.use1prod.cache.amazonaws.com", "port":11211 }, "pendingModifiedValues":{ "numCacheNodes":3 } }, "requestID":"807f4bc3-354c-11e4-9376-c1d979ba565a", "eventID":"e9163565-376f-4223-96e9-9f50528da645" }