- "query": "// Update these thresholds if noisy in your environment\nlet SnapshotDeletionThreshold = 10;\nlet TimeWindow = 1m;\nGCPAuditLogs\n| where ServiceName == \"compute.googleapis.com\"\n| where MethodName has \"compute.snapshots.delete\"\n| where GCPResourceType == \"gce_snapshot\" and Severity == \"NOTICE\"\n| extend \n AuthzInfoJson = parse_json(AuthorizationInfo),\n RequestMetadataJson = parse_json(RequestMetadata),\n ResponseJson = parse_json(Response)\n| extend PermissionType = tostring(AuthzInfoJson[0].permissionType)\n| where PermissionType == \"ADMIN_WRITE\"\n| extend \n CallerIpAddress = tostring(RequestMetadataJson.callerIp),\n UserAgent = tostring(RequestMetadataJson.callerSuppliedUserAgent),\n SnapshotName = extract(@\"snapshots/([^/]+)\", 1, GCPResourceName),\n OperationType = tostring(ResponseJson.operationType),\n OperationId = tostring(ResponseJson.id)\n| summarize \n SnapshotCount = count(),\n SnapshotList = make_set(SnapshotName, 100),\n FirstDeletion = min(TimeGenerated),\n LastDeletion = max(TimeGenerated),\n OperationIds = make_set(OperationId, 100),\n CallerIPs = make_set(CallerIpAddress, 10)\n by PrincipalEmail, ProjectId, UserAgent\n| where SnapshotCount >= SnapshotDeletionThreshold\n| extend DeletionTimeSpan = LastDeletion - FirstDeletion\n| where DeletionTimeSpan <= TimeWindow\n| extend \n AccountName = tostring(split(PrincipalEmail, \"@\")[0]), \n AccountUPNSuffix = tostring(split(PrincipalEmail, \"@\")[1])\n| project \n TimeGenerated = FirstDeletion,\n PrincipalEmail,\n ProjectId,\n ResourceName = GCPResourceName,\n SnapshotCount,\n SnapshotList,\n FirstDeletion,\n LastDeletion,\n DeletionTimeSpan,\n CallerIPs,\n UserAgent,\n OperationIds,\n AccountName,\n AccountUPNSuffix,\n",
0 commit comments