|
|
ADK Audit Logging with Cloud Logging
Author: Venkata Sudhakar
Enterprise deployments require a complete, tamper-evident record of every agent interaction for compliance, incident investigation, and performance analysis. GCP Cloud Logging provides a centralised, managed logging service that accepts structured JSON log entries, supports advanced queries, and integrates with Cloud Monitoring for alerting. ADK agents emit audit logs at every lifecycle event - request received, tool called, response delivered - giving a full conversation trace for every session.
ShopMax India is required by their internal compliance policy to retain agent interaction logs for 12 months and be able to reconstruct any conversation within 24 hours of an audit request. The engineering team writes structured JSON audit logs to Cloud Logging at four points: request received, tool called, response generated, and session closed, with all logs tagged by customer ID, session ID, and agent name.
The below example shows a structured audit logger for ShopMax India ADK agents that writes compliance-grade logs to Cloud Logging.
It gives the following output,
Cloud Logging client initialised: project=shopmax-india
Logger: shopmax-agent-audit
Log entry 1: REQUEST_RECEIVED
session=sess_abc123 | user=CUST-88821 | message_length=45
Log entry 2: TOOL_CALLED
session=sess_abc123 | tool=get_order_status | args=order_id=ORD-20260406-9921
Log entry 3: RESPONSE_SENT
session=sess_abc123 | latency=780ms | tokens=234 | response_length=182
Audit logs written to Cloud Logging: shopmax-agent-audit
The below example shows Cloud Logging query syntax to reconstruct a full conversation session and generate a daily audit summary report for ShopMax India compliance review.
It gives the following output,
Session sess_abc123: 3 audit events
[2026-04-06T04:28:42Z] REQUEST_RECEIVED - INFO
[2026-04-06T04:28:43Z] TOOL_CALLED - INFO
[2026-04-06T04:28:44Z] RESPONSE_SENT - INFO
Daily audit: {
"date": "2026-04-06",
"total_events": 18432,
"by_type": {
"REQUEST_RECEIVED": 6144,
"TOOL_CALLED": 4821,
"RESPONSE_SENT": 6144,
"SESSION_CLOSED": 1323
},
"unique_sessions": 6144,
"unique_users": 4891
}
Cloud Logging audit trails give ShopMax India a complete, queryable record of every agent interaction. Compliance auditors can reconstruct any conversation by session ID in seconds. Security teams can query for anomalous patterns - sessions with unusually high tool call counts, blocked requests, or guardrail triggers - and Cloud Monitoring can alert on these metrics in real time to catch issues before they escalate.
|
|