使用 Amazon CloudTrail 记录 Amazon OpenSearch Ingestion API 调用 - 亚马逊 OpenSearch 服务
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Amazon CloudTrail 记录 Amazon OpenSearch Ingestion API 调用

Amazon OpenSearch Ingestion 与 Amazon CloudTrail 集成,后者是在 OpenSearch Ingestion 中提供用户、角色或 Amazon 服务所采取操作的记录的服务。

CloudTrail 以事件的形式捕获针对 OpenSearch Ingestion 的所有 API 调用。捕获的调用包括来自 OpenSearch Service 控制台 OpenSearch Ingestion 部分的调用,以及针对 OpenSearch Ingestion API 操作的代码调用。

如果您创建跟踪,则可以使 CloudTrail 事件持续传送到 Amazon S3 存储桶(包括 OpenSearch Ingestion 的事件)。如果您不配置跟踪,则仍可在 CloudTrail 控制台中的 Event history(事件历史记录)中查看最新事件。

使用 CloudTrail 收集的信息,您可以确定向 OpenSearch Ingestion 发出了什么请求、发出请求的 IP 地址、何人发出的请求、请求的发出时间,以及其他详细信息。

要了解有关 CloudTrail 的更多信息,请参阅《Amazon CloudTrail用户指南》。

CloudTrail 中的 OpenSearch Ingestion 信息

在您创建 Amazon Web Services 账户 时,将在该账户上启用 CloudTrail。当 OpenSearch Ingestion 中发生活动时,该活动将记录在 CloudTrail 事件中,并与其他 Amazon 服务事件一同保存在事件历史记录中。您可以在 Amazon Web Services 账户中查看、搜索和下载最新事件。有关更多信息,请参阅使用 CloudTrail 事件历史记录查看事件

要持续记录 Amazon Web Services 账户 中的事件(包括 OpenSearch Ingestion 的事件),请创建跟踪。通过跟踪记录,CloudTrail 可将日志文件传送至 Simple Storage Service(Amazon S3)存储桶。预设情况下,在控制台中创建跟踪记录时,此跟踪记录应用于所有Amazon Web Services 区域。

此跟踪记录在 Amazon 分区中记录所有区域中的事件,并将日志文件传送至您指定的 Simple Storage Service(Amazon S3)桶。此外,您可以配置其他 Amazon 服务,进一步分析在 CloudTrail 日志中收集的事件数据并采取行动。有关更多信息,请参阅下列内容:

所有 OpenSearch Ingestion 操作都由 CloudTrail 记录,并记录在 OpenSearch Ingestion API 参考中。例如,对 CreateCollectionListCollectionsDeleteCollection 操作的调用会在 CloudTrail 日志文件中生成条目。

每个事件或日志条目都包含有关生成请求的人员信息。身份信息可以帮助您确定:

  • 请求是使用根用户凭证还是(Amazon Identity and Access ManagementIAM)用户凭证发出的。

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

  • 请求是否由其它 Amazon 服务发出。

有关更多信息,请参阅 CloudTrail userIdentity 元素

了解 OpenSearch Ingestion 日志文件条目

跟踪是一种配置,可用于将事件作为日志文件传送到您指定的 Amazon S3 桶。CloudTrail 日志文件包含一个或多个日志条目。

事件表示来自任何源的单个请求。它包括有关所请求操作的信息、操作的日期和时间、请求参数等。CloudTrail 日志文件不是公用 API 调用的有序堆栈跟踪,因此它们不会按任何具体顺序显示。

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

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AIDACKCEVSQ6C2EXAMPLE", "arn":"arn:aws:iam::123456789012:user/test-user", "accountId": "123456789012", "accessKeyId": "access-key", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AIDACKCEVSQ6C2EXAMPLE", "arn": "arn:aws:iam::123456789012:role/Admin", "accountId": "123456789012", "userName": "Admin" }, "webIdFederationData": {}, "attributes": { "creationDate": "2023-04-21T16:48:33Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-04-21T16:49:22Z", "eventSource": "osis.amazonaws.com", "eventName": "UpdatePipeline", "awsRegion": "us-west-2", "sourceIPAddress": "123.456.789.012", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36", "requestParameters": { "pipelineName": "my-pipeline", "pipelineConfigurationBody": "version: \"2\"\nlog-pipeline:\n source:\n http:\n path: \"/test/logs\"\n processor:\n - grok:\n match:\n log: [ '%{COMMONAPACHELOG}' ]\n - date:\n from_time_received: true\n destination: \"@timestamp\"\n sink:\n - opensearch:\n hosts: [ \"https://search-b5zd22mwxhggheqpj5ftslgyle.us-west-2.es.amazonaws.com\" ]\n index: \"apache_logs2\"\n aws_sts_role_arn: \"arn:aws:iam::709387180454:role/canary-bootstrap-OsisRole-J1BARLD26QKN\"\n aws_region: \"us-west-2\"\n aws_sigv4: true\n" }, "responseElements": { "pipeline": { "pipelineName": "my-pipeline",sourceIPAddress "pipelineArn": "arn:aws:osis:us-west-2:123456789012:pipeline/my-pipeline", "minUnits": 1, "maxUnits": 1, "status": "UPDATING", "statusReason": { "description": "An update was triggered for the pipeline. It is still available to ingest data." }, "pipelineConfigurationBody": "version: \"2\"\nlog-pipeline:\n source:\n http:\n path: \"/test/logs\"\n processor:\n - grok:\n match:\n log: [ '%{COMMONAPACHELOG}' ]\n - date:\n from_time_received: true\n destination: \"@timestamp\"\n sink:\n - opensearch:\n hosts: [ \"https://search-b5zd22mwxhggheqpj5ftslgyle.us-west-2.es.amazonaws.com\" ]\n index: \"apache_logs2\"\n aws_sts_role_arn: \"arn:aws:iam::709387180454:role/canary-bootstrap-OsisRole-J1BARLD26QKN\"\n aws_region: \"us-west-2\"\n aws_sigv4: true\n", "createdAt": "Mar 29, 2023 1:03:44 PM", "lastUpdatedAt": "Apr 21, 2023 9:49:21 AM", "ingestEndpointUrls": [ "my-pipeline-tu33ldsgdltgv7x7tjqiudvf7m.us-west-2.osis.amazonaws.com" ] } }, "requestID": "12345678-1234-1234-1234-987654321098", "eventID": "12345678-1234-1234-1234-987654321098", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "709387180454", "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256", "clientProvidedHostHeader": "osis.us-west-2.amazonaws.com" }, "sessionCredentialFromConsole": "true" }