Ark*_* K. 5 google-bigquery google-cloud-logging google-cloud-monitoring
我有一个数据集 ID,表已创建。哪些被删除了。我需要检查谁删除了它们以及何时删除。
您需要启用审核日志导出。
删除有多种类型:
常见的删除类型解释如下:
类型 1:您发出表删除查询/API 调用等。
然后您可以运行如下查询:
SELECT * FROM `dataset.cloudaudit_googleapis_com_activity_20190919`
where resource.type='bigquery_resource'
and protopayload_auditlog.methodName='tableservice.delete'
Run Code Online (Sandbox Code Playgroud)
你会得到一个大表,它不能作为漂亮的图像发布在这里,但作为简化的 JSON,它在这里:
[
{
"logName": "projects/editedname/logs/cloudaudit.googleapis.com%2Factivity",
"resource": {
"type": "bigquery_resource",
"labels": {
"project_id": "editedname",
}
},
"protopayload_auditlog": {
"serviceName": "bigquery.googleapis.com",
"methodName": "tableservice.delete",
"resourceName": "projects/editedname/datasets/dataset/tables/industry2",
"authenticationInfo": {
"principalEmail": "something@domain.com",
"authoritySelector": null,
"serviceAccountKeyName": null,
"serviceAccountDelegationInfo": []
},
"authorizationInfo": [
{
"resource": "projects/editedname/datasets/dataset/tables/industry2",
"permission": "bigquery.tables.delete",
"granted": "true",
"resourceAttributes": null
}
],
"requestMetadata": {
"callerIp": "1.2.3.4",
"callerSuppliedUserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36,gzip(gfe)",
"callerNetwork": null,
"requestAttributes": null,
"destinationAttributes": null
},
},
"timestamp": "2019-09-19 08:47:00.381 UTC",
"receiveTimestamp": "2019-09-19 08:47:00.590316 UTC",
"severity": "NOTICE",
}
]
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,您有已删除的表,例如:industry2在我的示例中,还有用户或服务帐户的电子邮件地址、日期,甚至metadata是调用者的 IP 和 userAgent。
有关可用信息的更多信息,请参见此处
类型 2:您发出了表覆盖查询或CREATE OR REPLACE语法
对于此类“删除”,您不会找到单独的已删除条目。但是您可以在中查找“截断”标志metadataJson
| 归档时间: |
|
| 查看次数: |
6621 次 |
| 最近记录: |