Loading...
Loading...
Audits AI agent data access, blast radius, and blocked policy operations in Google Cloud by querying Cloud Audit Logs via BigQuery. Use when investigating what resources or services an agent accessed, identifying top originating principals the agent is acting as, or triaging PERMISSION_DENIED errors to distinguish VPC Service Controls perimeter violations from IAM permission denials. Don't use for configuring Cloud Monitoring alert policies, modifying IAM policies or VPC Service Controls perimeters, querying non-audit application logs, or performing write operations.
npx skill4agent add google/skills agent-platform-access-auditgcloudgcloudbqPERMISSION_DENIEDgcloud auth logingcloud auth application-default loginbq query_AllLogslogging.googleapis.combigquery.googleapis.comagentregistry.googleapis.comgcloud services enable logging.googleapis.com bigquery.googleapis.com agentregistry.googleapis.com --project={PROJECT_ID}roles/logging.privateLogViewerroles/bigquery.dataViewerroles/bigquery.jobUserroles/agentregistry.viewer{PROJECT_ID}gcloud config get-value projectgcloud config get-value project(unset){PROJECT_ID}{PRINCIPAL_SUBJECT}principal://...principal://...{PRINCIPAL_SUBJECT}financial-advisorprincipal://..._AllLogsLOCATION=$(gcloud asset search-all-resources \
--scope=projects/{PROJECT_ID} \
--query='displayName:"{AGENT_NAME}"' \
--format="value(location)" \
--limit=1)
echo "Resolved location: $LOCATION"
gcloud agent-registry agents search \
--location="${LOCATION:-global}" \
--project={PROJECT_ID} \
--search-string="displayName:{AGENT_NAME}" \
--format=jsonattributes["agentregistry.googleapis.com/system/RuntimeIdentity"]["principal"]principal://...{PRINCIPAL_SUBJECT}principal://sa://bq query_AllLogssa://...principal://...principal://...namelocationprincipal://...bq queryprincipal://...principal_subject = 'financial-advisor'LIKEprincipal_subject@principal_subjectWHEREprincipal://...bq query--parameter="principal_subject:STRING:{PRINCIPAL_SUBJECT}"references/audit-queries.md| User Intent | Section in | Key Output Columns |
|---|---|---|
| Inspect individual data access operations, methods, or target resources | Section 2 — Scenario 1: Data access audit logs | |
| Top 5 Google Cloud services accessed (read vs. write counts) | Section 3 — Scenario 2, Query 2A: Top 5 Google Cloud Services Accessed | |
| Top 5 callers / principals invoking or delegating to the agent | Section 3 — Scenario 2, Query 2B: Top 5 Originating Principals | |
| Access activity breakdown over time by permission category | Section 3 — Scenario 2, Query 2C: Access Activity Over Time | |
Investigate | Section 4 — Scenario 4: Blocked data access attempt logs | |
| Custom follow-up filters (e.g., filtering by resource or method) | Section 5 — Cloud Audit Logs ( | Combine canonical template with exact column paths from the dictionary |
logs.timestamp >= TIMESTAMP_SUB(...)references/audit-queries.mdINTERVAL 7 DAYbq querybq query_Default{LINK_ID}gcloud logging links list --bucket=_Default --location=global --project={PROJECT_ID} --format="value(name)"projects/{PROJECT_ID}/locations/global/buckets/_Default/links/default_log_bucket/links/default_log_bucket{PROJECT_ID}{LINK_ID}^[a-z0-9_-]+$global._Default._AllLogs{LINK_ID}._AllLogs`{PROJECT_ID}.{LINK_ID}._AllLogs`_Defaultbqgcloud logging links create default_log_bucket --bucket=_Default --location=global --project={PROJECT_ID}bq query{PRINCIPAL_SUBJECT}--parameter\`{PROJECT_ID}.{LINK_ID}._AllLogs\` bq query \
--use_legacy_sql=false \
--project_id={PROJECT_ID} \
--format=json \
--parameter="principal_subject:STRING:{PRINCIPAL_SUBJECT}" \
"<SQL_QUERY>"SELECTEXPORT DATACREATEDROPALTERINSERTUPDATEDELETE_AllLogsresource_namemethod_namestatus.messageprincipal://...original_principalformatted_principalstatus.code = 7block_reasonattempted_operationattempted_method_nameattempted_target_resourceVPC service controls violationvpcServiceControlsUniqueIdIAM permission deniedvpcServiceControlsUniqueIdnull