You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The agent automatically produces structured audit logs that correlate each user session with Red Hat API requests. When `LOG_FORMAT=json` (the default in Cloud Run), every log record includes:
1315
+
1316
+
-**`user_id`** — authenticated user (JWT `sub` claim)
1317
+
-**`org_id`** — Red Hat organization (JWT `org_id` claim)
1318
+
-**`order_id`** — Google Cloud Marketplace order
1319
+
-**`request_id`** — UUID4 correlation ID (unique per request)
1320
+
1321
+
Each agent lifecycle event carries an `event_type` tag (`request_authenticated`, `agent_run_started`, `tool_call_completed`, `mcp_jwt_forwarded`, etc.) and tool calls include a `data_source` field identifying which Red Hat Insights MCP tool retrieved the data.
1322
+
1323
+
This provides a full data lineage audit trail: every piece of information disclosed by the agent can be traced back to a specific authenticated user prompt and a verified Red Hat Insights data source. These persistent logs are independent of the ephemeral ADK session storage.
1324
+
1325
+
### Querying Audit Logs
1326
+
1327
+
Cloud Logging automatically parses JSON log fields. To filter logs from the Lightspeed Agent service specifically, add a `resource.labels.service_name` filter:
1328
+
1329
+
```bash
1330
+
# All Lightspeed Agent logs (filter by Cloud Run service name)
1331
+
gcloud logging read'resource.type="cloud_run_revision" AND resource.labels.service_name="lightspeed-agent"' \
1332
+
--project=$GOOGLE_CLOUD_PROJECT --limit=50
1333
+
1334
+
# All actions by a specific user (scoped to the agent service)
1335
+
gcloud logging read'resource.type="cloud_run_revision" AND resource.labels.service_name="lightspeed-agent" AND jsonPayload.user_id="<user-id>"' \
1336
+
--project=$GOOGLE_CLOUD_PROJECT --limit=50
1337
+
1338
+
# All events in a single request (correlation)
1339
+
gcloud logging read'resource.type="cloud_run_revision" AND resource.labels.service_name="lightspeed-agent" AND jsonPayload.request_id="<request-id>"' \
1340
+
--project=$GOOGLE_CLOUD_PROJECT
1341
+
1342
+
# All MCP data access for an organization
1343
+
gcloud logging read'resource.type="cloud_run_revision" AND resource.labels.service_name="lightspeed-agent" AND jsonPayload.org_id="<org-id>" AND jsonPayload.message=~"mcp_jwt_forwarded"' \
1344
+
--project=$GOOGLE_CLOUD_PROJECT
1345
+
1346
+
# All tool calls with data source tracking
1347
+
gcloud logging read'resource.type="cloud_run_revision" AND resource.labels.service_name="lightspeed-agent" AND jsonPayload.message=~"tool_call_completed"' \
1348
+
--project=$GOOGLE_CLOUD_PROJECT --limit=20
1349
+
```
1350
+
1351
+
No additional configuration is required — audit logging is automatically active when `LOG_FORMAT=json`.
Copy file name to clipboardExpand all lines: docs/configuration.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -249,6 +249,60 @@ LOG_FORMAT=text # Human-readable for development
249
249
AGENT_LOGGING_DETAIL=detailed # Include tool args/results in logs
250
250
```
251
251
252
+
#### Audit Logging
253
+
254
+
The `LOG_FORMAT` setting controls how log records are formatted:
255
+
256
+
-**`json`** (default) — Structured JSON output. Every log record automatically includes audit context fields (`user_id`, `org_id`, `order_id`, `request_id`). Recommended for production and Cloud Run, where Cloud Logging parses these fields for querying.
257
+
-**`text`** — Human-readable output (`timestamp - logger - level - message`). Audit context fields are **not** included in the log record. The agent execution plugin still embeds `user_id`, `org_id`, `order_id`, and `request_id` in the log message text, but they are not available as structured fields for filtering. Recommended for local development.
258
+
259
+
When `LOG_FORMAT=json`, every log record automatically includes audit context fields:
260
+
261
+
| Field | Source | Description |
262
+
|-------|--------|-------------|
263
+
|`user_id`| JWT `sub` claim | Authenticated user identifier |
264
+
|`org_id`| JWT `org_id` claim | Red Hat organization identifier |
265
+
|`order_id`| DCR client lookup | Google Cloud Marketplace order |
266
+
|`request_id`| Generated UUID4 | Per-request correlation ID |
267
+
268
+
These fields enable:
269
+
-**Request correlation** — all events in a single request share the same `request_id`
270
+
-**User audit** — filter by `user_id` to trace all actions by a specific user
271
+
-**Organization audit** — filter by `org_id` for organization-level auditing
272
+
-**Data lineage** — `tool_call_completed` events include `data_source=<mcp_tool>`, and `mcp_jwt_forwarded` events prove data was retrieved using the user's authorized JWT
273
+
274
+
Each agent lifecycle event is tagged with an `event_type` in the log message:
275
+
276
+
| Event Type | Description |
277
+
|------------|-------------|
278
+
|`request_authenticated`| User JWT validated, user_id and org_id extracted |
279
+
|`agent_run_started`| ADK agent invocation started |
0 commit comments