From c2592c9f122846d8a1c0bffe48f9ea91672d0d4c Mon Sep 17 00:00:00 2001 From: Jiachen Jiang Date: Wed, 8 Apr 2026 08:57:17 -0700 Subject: [PATCH] docs: add AI Bridge structured log record types and monitoring cross-link (#23979) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What Two small docs improvements for AI Bridge: 1. **`setup.md` – Structured Logging section**: Added a `record_type` table documenting the six event types emitted by AI Bridge structured logs (`interception_start`, `interception_end`, `token_usage`, `prompt_usage`, `tool_usage`, `model_thought`) along with their key fields. Previously only the `"interception log"` message prefix was mentioned. 2. **`monitoring.md`**: Added a "Structured Logging" section that cross-links to `setup.md#structured-logging`, so users landing on the monitoring page can discover the feature without navigating to the setup guide first.
Source reference Record types and fields were extracted from `enterprise/aibridgedserver/aibridgedserver.go` where they are emitted as `slog.F("record_type", "...")` string literals under the `InterceptionLogMarker` (`"interception log"`) message.
--- docs/ai-coder/ai-bridge/monitoring.md | 7 +++++++ docs/ai-coder/ai-bridge/setup.md | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/ai-coder/ai-bridge/monitoring.md b/docs/ai-coder/ai-bridge/monitoring.md index d339df3ee8..d3adc59733 100644 --- a/docs/ai-coder/ai-bridge/monitoring.md +++ b/docs/ai-coder/ai-bridge/monitoring.md @@ -10,6 +10,13 @@ We provide an example Grafana dashboard that you can import as a starting point These logs and metrics can be used to determine usage patterns, track costs, and evaluate tooling adoption. +## Structured Logging + +AI Bridge can emit structured logs for every interception event to your +existing log pipeline. This is useful for exporting data to external SIEM or +observability platforms. See [Structured Logging](./setup.md#structured-logging) +in the setup guide for configuration and a full list of record types. + ## Exporting Data AI Bridge interception data can be exported for external analysis, compliance reporting, or integration with log aggregation systems. diff --git a/docs/ai-coder/ai-bridge/setup.md b/docs/ai-coder/ai-bridge/setup.md index 50b6a4f86c..60d6d11763 100644 --- a/docs/ai-coder/ai-bridge/setup.md +++ b/docs/ai-coder/ai-bridge/setup.md @@ -150,4 +150,14 @@ ingestion, set `--log-json` to a file path or `/dev/stderr` so that records are emitted as JSON. Filter for AI Bridge records in your logging pipeline by matching on the -`"interception log"` message. +`"interception log"` message. Each log line includes a `record_type` field that +indicates the kind of event captured: + +| `record_type` | Description | Key fields | +|----------------------|-----------------------------------------|--------------------------------------------------------------------------------| +| `interception_start` | A new intercepted request begins. | `interception_id`, `initiator_id`, `provider`, `model`, `client`, `started_at` | +| `interception_end` | An intercepted request completes. | `interception_id`, `ended_at` | +| `token_usage` | Token consumption for a response. | `interception_id`, `input_tokens`, `output_tokens`, `created_at` | +| `prompt_usage` | The last user prompt in a request. | `interception_id`, `prompt`, `created_at` | +| `tool_usage` | A tool/function call made by the model. | `interception_id`, `tool`, `input`, `server_url`, `injected`, `created_at` | +| `model_thought` | Model reasoning or thinking content. | `interception_id`, `content`, `created_at` |