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

使用 Amazon CloudTrail 记录 Amazon Glue API 调用

Amazon Glue 与 Amazon CloudTrail 集成,后者是在 Amazon 中记录用户、角色或 Amazon Glue 服务所执行操作的服务。CloudTrail 将 Amazon Glue 的所有 API 调用作为事件捕获。捕获的调用包含来自 Amazon Glue 控制台和代码的 Amazon Glue API 操作调用。如果您创建跟踪,则可以使 CloudTrail 事件持续传送到 Amazon S3 存储桶(包括 Amazon Glue 的事件)。如果您不配置跟踪记录,则仍可在 CloudTrail 控制台中的事件历史记录中查看最新事件。使用 CloudTrail 收集的信息,您可以确定向 Amazon Glue 发出了什么请求、发出请求的 IP 地址、何人发出的请求、请求的发出时间以及其他详细信息。

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

CloudTrail 中的 Amazon Glue 信息

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

要持续记录 Amazon 账户中的事件(包括 Amazon Glue 的事件),请创建跟踪。通过跟踪记录,CloudTrail 可将日志文件传送至 Amazon S3 存储桶。预设情况下,在控制台中创建跟踪时,此跟踪应用于所有 Amazon 区域。此跟踪记录在 Amazon 分区中记录所有区域中的事件,并将日志文件传送至您指定的 Amazon S3 存储桶。此外,您可以配置其他 Amazon 服务,进一步分析在 CloudTrail 日志中收集的事件数据并采取行动。有关更多信息,请参阅下列内容:

所有 Amazon Glue 操作都由 CloudTrail 记录,并记录在 Amazon Glue API 中。例如,对 CreateDatabaseCreateTableCreateScript 操作的调用会在 CloudTrail 日志文件中生成条目。

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

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

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

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

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

但是,CloudTrail 不记录有关调用的所有信息。例如,它不会记录某些敏感信息 (如在连接请求中使用的 ConnectionProperties),而且它记录 null 而不是以下 API 返回的响应:

BatchGetPartition GetCrawlers GetJobs GetTable CreateScript GetCrawlerMetrics GetJobRun GetTables GetCatalogImportStatus GetDatabase GetJobRuns GetTableVersions GetClassifier GetDatabases GetMapping GetTrigger GetClassifiers GetDataflowGraph GetObjects GetTriggers GetConnection GetDevEndpoint GetPartition GetUserDefinedFunction GetConnections GetDevEndpoints GetPartitions GetUserDefinedFunctions GetCrawler GetJob GetPlan

了解 Amazon Glue 日志文件条目

跟踪是一种配置,可用于将事件作为日志文件传送到您指定的 Amazon S3 存储桶。CloudTrail 日志文件包含一个或多个日记账条目。一个事件表示来自任何源的一个请求,包括有关所请求的操作、操作的日期和时间、请求参数等方面的信息。CloudTrail 日志文件不是公用 API 调用的有序堆栈跟踪,因此它们不会按任何特定顺序显示。

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

{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::123456789012:user/johndoe", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "johndoe" }, "eventTime": "2017-10-11T22:29:49Z", "eventSource": "glue.amazonaws.com", "eventName": "DeleteCrawler", "awsRegion": "us-east-1", "sourceIPAddress": "72.21.198.64", "userAgent": "aws-cli/1.11.148 Python/3.6.1 Darwin/16.7.0 botocore/1.7.6", "requestParameters": { "name": "tes-alpha" }, "responseElements": null, "requestID": "b16f4050-aed3-11e7-b0b3-75564a46954f", "eventID": "e73dd117-cfd1-47d1-9e2f-d1271cad838c", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

此示例显示了一个 CloudTrail 日志条目,该条目说明了 CreateConnection 操作。

{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::123456789012:user/johndoe", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "johndoe" }, "eventTime": "2017-10-13T00:19:19Z", "eventSource": "glue.amazonaws.com", "eventName": "CreateConnection", "awsRegion": "us-east-1", "sourceIPAddress": "72.21.198.66", "userAgent": "aws-cli/1.11.148 Python/3.6.1 Darwin/16.7.0 botocore/1.7.6", "requestParameters": { "connectionInput": { "name": "test-connection-alpha", "connectionType": "JDBC", "physicalConnectionRequirements": { "subnetId": "subnet-323232", "availabilityZone": "us-east-1a", "securityGroupIdList": [ "sg-12121212" ] } } }, "responseElements": null, "requestID": "27136ebc-afac-11e7-a7d6-ab217e5c3f19", "eventID": "e8b3baeb-c511-4597-880f-c16210c60a4a", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }