---
title: "AI Gateway audit log reference"
description: "AI Gateway provides a standardized logging format for AI Policies,
  enabling the emission of analytics events and facilitating the aggregation of AI
  usage analytics across various providers."
url: "/ai-gateway/ai-audit-log-reference/"
canonical_url: "/ai-gateway/ai-audit-log-reference/"
content_type: reference
min_version:
  ai-gateway: '2.0'
products:
- AI Gateway
tags:
- ai
- logging
canonical: true
works_on:
- konnect


---

# AI Gateway audit log reference










AI Gateway emits structured analytics logs for [AI Policies](/ai-gateway/policies/) following the same patterns as Kong Gateway. This means AI Gateway logs are written to [the same locations](/ai-gateway/ai-logs/#where-are-ai-gateway-logs-located) as other Kong logs, such as `/usr/local/kong/logs/error.log`, or to Docker container logs if you're running a data plane in a containerized environment. 

You can set the [global log level](/ai-gateway/ai-logs/#configure-log-levels) for AI Gateway via the [`kong.conf`](/gateway/configuration/) file or the Admin API. You can control log verbosity by adjusting the `log_level` setting (for example, `info`, `notice`, `warn`, `error`, `crit`) to determine which log entries are captured.

When operating AI Gateway alongside Kong Gateway, logs are stored separately in each product's run time environment.

You can also use [logging Policies](/ai-gateway/policies/?category=logging) to route these logs to external systems, such as file systems, log aggregators, or monitoring tools.

## Log details

Each AI Gateway Policy returns a set of tokens. Log entries include the following details:

### Core logs

AI Gateway logs capture detailed information about the request and response payloads, token usage, model details, latency, and cost metrics. They provide a comprehensive view of each AI interaction.


> Logs and metrics for cost and token usage via the [OpenAI Files API](https://developers.openai.com/api/reference/resources/files/methods/list) are not currently supported.

#### `ai.proxy.payload.request`
Description: The request payload sent to the upstream AI provider.

#### `ai.proxy.payload.response`
Description: The response payload received from the upstream AI provider.

#### `ai.proxy.usage.prompt_tokens`
Description: |
  The number of tokens used for prompting.
  Used for text-based requests (chat, completions, embeddings).

#### `ai.proxy.usage.prompt_tokens_details`
Description: A breakdown of prompt tokens (`cached_tokens`, `audio_tokens`).

#### `ai.proxy.usage.completion_tokens`
Description: |
  The number of tokens used for completion.
  Used for text-based responses (chat, completions).

#### `ai.proxy.usage.completion_tokens_details`
Description: A breakdown of completion tokens (`rejected_prediction_tokens`, `reasoning_tokens`, `accepted_prediction_tokens`, `audio_tokens`).

#### `ai.proxy.usage.total_tokens`
Description: |
  The total number of tokens used (input + output).
  Includes prompt/completion tokens for text, and input/output tokens for non-text modalities.

#### `ai.proxy.usage.input_tokens`
Description: |
  The total number of input tokens (text + image + audio).
  Used for non-text requests (e.g., image or audio generation).

#### `ai.proxy.usage.input_tokens_details`
Description: A breakdown of input tokens by modality (`text_tokens`, `image_tokens`, `audio_tokens_count`).

#### `ai.proxy.usage.output_tokens`
Description: |
  The total number of output tokens (text + audio).
  Used for non-text responses (e.g., image or audio generation).

#### `ai.proxy.usage.output_tokens_details`
Description: A breakdown of output tokens by modality (`text_tokens`, `audio_tokens`).

#### `ai.proxy.usage.cost`
Description: The total cost of the request.

#### `ai.proxy.usage.time_per_token`
Description: Average time to generate an output token (ms).

#### `ai.proxy.usage.time_to_first_token`
Description: Time to receive the first output token (ms).

#### `ai.proxy.meta.request_model`
Description: The model used for the AI request.

#### `ai.proxy.meta.response_model`
Description: The model used to generate the AI response.

#### `ai.proxy.meta.provider_name`
Description: The name of the AI service provider.

#### `ai.proxy.meta.plugin_id`
Description: Unique identifier of the Policy instance.

#### `ai.proxy.meta.llm_latency`
Description: Time taken by the LLM provider to generate the full response (ms).

#### `ai.proxy.meta.request_mode`
Description: The request mode. Can be `oneshot`, `stream`, or `realtime`.



### AI AWS Guardrails logs

If you use the [AI AWS Guardrails Policy](/ai-gateway/policies/ai-aws-guardrails/), AI Gateway logs include fields under the `ai.proxy.aws-guardrails` object. These fields capture processing latency, the guardrails configuration applied, block reasons, and masking behavior.

#### `ai.proxy.aws-guardrails.aws_region`
Description: The AWS region where the guardrail was applied.

#### `ai.proxy.aws-guardrails.guardrails_id`
Description: The unique identifier of the guardrail configuration applied.

#### `ai.proxy.aws-guardrails.guardrails_version`
Description: The version of the guardrail applied. Can be a numeric version or `DRAFT`.

#### `ai.proxy.aws-guardrails.mode`
Description: The content guarding mode configured for the Policy. Possible values: `INPUT`, `OUTPUT`, `BOTH`.

#### `ai.proxy.aws-guardrails.input_processing_latency`
Description: The time, in milliseconds, spent processing the request through the guardrail.

#### `ai.proxy.aws-guardrails.output_processing_latency`
Description: The time, in milliseconds, spent processing the response through the guardrail.

#### `ai.proxy.aws-guardrails.input_block_reason`
Description: The reason the request was blocked. Empty if the request was allowed.

#### `ai.proxy.aws-guardrails.output_block_reason`
Description: The reason the response was blocked. Empty if the response was allowed.

#### `ai.proxy.aws-guardrails.input_masked`
Description: `true` if the request content was masked rather than blocked. Only present when `config.allow_masking` is `true`.

#### `ai.proxy.aws-guardrails.output_masked`
Description: `true` if the response content was masked rather than blocked. Only present when `config.allow_masking` is `true`.

#### `ai.proxy.aws-guardrails.input_block_source`
Description: The name of the Policy that blocked the request. Empty if the request was allowed.

#### `ai.proxy.aws-guardrails.output_block_source`
Description: The name of the Policy that blocked the response. Empty if the response was allowed.

#### `ai.proxy.aws-guardrails.input_block_consumer_id`
Description: The ID of the AI Consumer whose request was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.aws-guardrails.output_block_consumer_id`
Description: The ID of the AI Consumer whose response was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.aws-guardrails.guards_triggered_count`
Description: A counter that increments each time a block is triggered on either the input or output within a single request.

#### `ai.proxy.aws-guardrails.input_faulty_prompt`
Description: The raw request prompt that was blocked. Only present when `config.log_blocked_content` is `true`.

#### `ai.proxy.aws-guardrails.output_faulty_response`
Description: The raw response that was blocked. Only present when `config.log_blocked_content` is `true`.



### AI GCP Model Armor logs

If you use the [AI GCP Model Armor Policy](/ai-gateway/policies/ai-gcp-model-armor/), AI Gateway logs include fields under the `ai.proxy.gcp-model-armor` object. These fields capture the template applied, processing latency, and reasons for blocking when content is flagged.

#### `ai.proxy.gcp-model-armor.template_id`
Description: The GCP Model Armor template identifier applied to the request.

#### `ai.proxy.gcp-model-armor.input_processing_latency`
Description: The time, in milliseconds, spent processing the request through Model Armor.

#### `ai.proxy.gcp-model-armor.output_processing_latency`
Description: The time, in milliseconds, spent processing the response through Model Armor.

#### `ai.proxy.gcp-model-armor.input_block_reason`
Description: The check type or types that caused the request to be blocked, comma-separated (for example, `sexually_explicit`, `dangerous`). Empty if the request was allowed.

#### `ai.proxy.gcp-model-armor.output_block_reason`
Description: The check type or types that caused the response to be blocked, comma-separated. Empty if the response was allowed.

#### `ai.proxy.gcp-model-armor.mode`
Description: The content guarding mode configured for the Policy. Possible values: `INPUT`, `OUTPUT`, `BOTH`.

#### `ai.proxy.gcp-model-armor.input_block_source`
Description: The name of the Policy that blocked the request. Empty if the request was allowed.

#### `ai.proxy.gcp-model-armor.output_block_source`
Description: The name of the Policy that blocked the response. Empty if the response was allowed.

#### `ai.proxy.gcp-model-armor.input_block_consumer_id`
Description: The ID of the AI Consumer whose request was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.gcp-model-armor.output_block_consumer_id`
Description: The ID of the AI Consumer whose response was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.gcp-model-armor.guards_triggered_count`
Description: A counter that increments each time a block is triggered on either the input or output within a single request.

#### `ai.proxy.gcp-model-armor.input_faulty_prompt`
Description: The raw request prompt that was blocked. Only present when `config.log_blocked_content` is `true`.

#### `ai.proxy.gcp-model-armor.output_faulty_response`
Description: The raw response that was blocked. Only present when `config.log_blocked_content` is `true`.



### AI Azure Content Safety logs

If you use the [AI Azure Content Safety Policy](/ai-gateway/policies/ai-azure-content-safety/), AI Gateway writes to two separate log paths.

The first path records per-category severity data from the Azure Content Safety API. Each entry represents a category that breached its configured rejection threshold. Multiple entries can appear per request depending on which categories were configured and what was detected.

For information on categories and severity levels, see [Harm categories in Azure AI Content Safety](https://learn.microsoft.com/en-us/azure/foundry-classic/openai/concepts/content-filter-severity-levels).

#### `ai.audit.azure_content_safety.<CATEGORY>`
Description: The numeric rejection severity threshold for the category that was breached (for example, `Hate`, `Violence`). Defined by `config.categories[*].rejection_level`. Multiple entries can appear per request.



The second path records Policy metadata and block reasons under the `ai.proxy.azure-content-safety` object:

#### `ai.proxy.azure-content-safety.azure_tenant_id`
Description: The Azure tenant ID used for authentication.

#### `ai.proxy.azure-content-safety.azure_client_id`
Description: The Azure client ID used for authentication.

#### `ai.proxy.azure-content-safety.azure_api_version`
Description: The Azure Content Safety API version used for the request.

#### `ai.proxy.azure-content-safety.azure_content_safety_url`
Description: The Azure Content Safety endpoint URL.

#### `ai.proxy.azure-content-safety.input_processing_latency`
Description: The time, in milliseconds, spent processing the request through Azure Content Safety.

#### `ai.proxy.azure-content-safety.output_processing_latency`
Description: The time, in milliseconds, spent processing the response through Azure Content Safety.

#### `ai.proxy.azure-content-safety.input_block_reason`
Description: The reason the request was blocked. Empty if the request was allowed.

#### `ai.proxy.azure-content-safety.output_block_reason`
Description: The reason the response was blocked. Empty if the response was allowed.

#### `ai.proxy.azure-content-safety.mode`
Description: The content guarding mode configured for the Policy. Possible values: `INPUT`, `OUTPUT`, `BOTH`.

#### `ai.proxy.azure-content-safety.input_block_source`
Description: The name of the Policy that blocked the request. Empty if the request was allowed.

#### `ai.proxy.azure-content-safety.output_block_source`
Description: The name of the Policy that blocked the response. Empty if the response was allowed.

#### `ai.proxy.azure-content-safety.input_block_consumer_id`
Description: The ID of the AI Consumer whose request was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.azure-content-safety.output_block_consumer_id`
Description: The ID of the AI Consumer whose response was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.azure-content-safety.guards_triggered_count`
Description: A counter that increments each time a block is triggered on either the input or output within a single request.

#### `ai.proxy.azure-content-safety.input_faulty_prompt`
Description: The raw request prompt that was blocked. Only present when `config.log_blocked_content` is `true`.

#### `ai.proxy.azure-content-safety.output_faulty_response`
Description: The raw response that was blocked. Only present when `config.log_blocked_content` is `true`.



### AI Lakera Guard logs

If you use the [AI Lakera Guard Policy](/ai-gateway/policies/ai-lakera-guard/), AI Gateway logs include additional fields under the `ai.proxy.lakera-guard` object. These fields capture processing latency, Lakera-assigned request UUIDs, block reasons, and violation details when requests or responses are blocked.

#### `ai.proxy.lakera-guard.lakera_service_url`
Description: The Lakera API endpoint used for inspection (for example, `https://api.lakera.ai/v2/guard`).

#### `ai.proxy.lakera-guard.lakera_project_id`
Description: The Lakera project identifier used for the inspection. Defaults to `default` if no project ID is configured.

#### `ai.proxy.lakera-guard.mode`
Description: The content guarding mode configured for the Policy. Possible values: `INPUT`, `OUTPUT`, `BOTH`.

#### `ai.proxy.lakera-guard.input_processing_latency`
Description: The time, in milliseconds, that Lakera took to process the request.

#### `ai.proxy.lakera-guard.output_processing_latency`
Description: The time, in milliseconds, that Lakera took to process the response.

#### `ai.proxy.lakera-guard.input_request_uuid`
Description: The unique identifier assigned by Lakera for the inspected request.

#### `ai.proxy.lakera-guard.output_request_uuid`
Description: The unique identifier assigned by Lakera for the inspected response.

#### `ai.proxy.lakera-guard.input_block_reason`
Description: The detector type that caused Lakera to block the request. Empty if the request was allowed.

#### `ai.proxy.lakera-guard.output_block_reason`
Description: The detector type that caused Lakera to block the response. Empty if the response was allowed.

#### `ai.proxy.lakera-guard.input_block_detail`
Description: An array of violation objects present when Lakera blocks a request. Each object includes `policy_id`, `detector_id`, `project_id`, `message_id`, `detected` (boolean), and `detector_type` (for example, `moderated_content/hate`).

#### `ai.proxy.lakera-guard.output_block_detail`
Description: An array of violation objects present when Lakera blocks a response. The structure matches `input_block_detail`.

#### `ai.proxy.lakera-guard.input_block_source`
Description: The name of the Policy that blocked the request. Empty if the request was allowed.

#### `ai.proxy.lakera-guard.output_block_source`
Description: The name of the Policy that blocked the response. Empty if the response was allowed.

#### `ai.proxy.lakera-guard.input_block_consumer_id`
Description: The ID of the AI Consumer whose request was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.lakera-guard.output_block_consumer_id`
Description: The ID of the AI Consumer whose response was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.proxy.lakera-guard.guards_triggered_count`
Description: A counter that increments each time a block is triggered on either the input or output within a single request.

#### `ai.proxy.lakera-guard.input_faulty_prompt`
Description: The raw request prompt that was blocked. Only present when `config.log_blocked_content` is `true`.

#### `ai.proxy.lakera-guard.output_faulty_response`
Description: The raw response that was blocked. Only present when `config.log_blocked_content` is `true`.



### AI Custom Guardrail logs 

If you use the [AI Custom Guardrail Policy](/ai-gateway/policies/ai-custom-guardrail/), AI Gateway logs include additional fields under the `custom-guardrail` object. These fields record guardrail processing latency, block reasons, and the source and AI Consumer identity associated with any triggered guards.

The following fields appear in structured AI logs when the AI Custom Guardrail Policy is enabled:

#### `ai.proxy.custom-guardrail.mode`
Description: The inspection mode configured for the guardrail. For example, `BOTH` means both input and output are inspected.

#### `ai.proxy.custom-guardrail.input_processing_latency`
Description: The time (in milliseconds) taken to process the input through the guardrail.

#### `ai.proxy.custom-guardrail.output_processing_latency`
Description: The time (in milliseconds) taken to process the output through the guardrail.

#### `ai.proxy.custom-guardrail.input_block_reason`
Description: The reason the input was blocked. Empty if the input was not blocked.

#### `ai.proxy.custom-guardrail.output_block_reason`
Description: The reason the output was blocked. Empty if the output was not blocked.

#### `ai.proxy.custom-guardrail.input_block_source`
Description: The source that triggered the input block (for example, `ai-custom-guardrail`). Empty if the input was not blocked.

#### `ai.proxy.custom-guardrail.output_block_source`
Description: The source that triggered the output block. Empty if the output was not blocked.

#### `ai.proxy.custom-guardrail.input_block_consumer_id`
Description: the AI Consumer ID associated with the blocked input request. Set to `unknown` if the AI Consumer can't be identified.

#### `ai.proxy.custom-guardrail.output_block_consumer_id`
Description: the AI Consumer ID associated with the blocked output response. Empty if the output was not blocked.

#### `ai.proxy.custom-guardrail.guards_triggered_count`
Description: The number of individual guard rules that were triggered during the request.




> The Policy also allows you to define [custom metrics](/ai-gateway/policies/ai-custom-guardrail/#metrics) based on Lua expressions.


### AI PII Sanitizer logs

If you use the [AI PII Sanitizer Policy](/ai-gateway/policies/ai-sanitizer/), AI Gateway logs include additional fields that provide insight into the detection and redaction of personally identifiable information (PII). These fields track the number of entities identified and sanitized, the time taken to process the payload, and detailed metadata about each sanitized item, including the original value, redacted value, and detected entity type.

#### `ai.sanitizer.pii_identified`
Description: The number of PII entities detected in the input payload.

#### `ai.sanitizer.pii_sanitized`
Description: The number of PII entities that were anonymized or redacted.

#### `ai.sanitizer.duration`
Description: The time taken (in milliseconds) by the `ai-pii-service` container to process the payload.

#### `ai.sanitizer.sanitized_items`
Description: A list of sanitized PII entities, each including the original text, redacted text, and the entity type.

#### `ai.sanitizer.input_block_source`
Description: The name of the Policy that blocked the request. Empty if the request was allowed.

#### `ai.sanitizer.output_block_source`
Description: The name of the Policy that blocked the response. Empty if the response was allowed.

#### `ai.sanitizer.input_block_consumer_id`
Description: The ID of the AI Consumer whose request was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.sanitizer.output_block_consumer_id`
Description: The ID of the AI Consumer whose response was blocked, or `unknown` if no AI Consumer identity was resolved.

#### `ai.sanitizer.guards_triggered_count`
Description: A counter that increments each time a block is triggered on either the input or output within a single request.



### AI Prompt Compressor logs 

When the [AI Prompt Compressor Policy](/ai-gateway/policies/ai-prompt-compressor/) is enabled, additional logs record token counts before and after compression, compression ratios, and metadata about the compression method and model used.

#### `ai.compressor.original_token_count`
Description: The original number of tokens before compression.

#### `ai.compressor.compress_token_count`
Description: The number of tokens after compression.

#### `ai.compressor.save_token_count`
Description: The number of tokens saved by compression (original minus compressed).

#### `ai.compressor.compress_value`
Description: The compression ratio applied.

#### `ai.compressor.compress_type`
Description: The type or method of compression used.

#### `ai.compressor.compressor_model`
Description: The model used to perform the compression.

#### `ai.compressor.msg_id`
Description: The identifier of the message that was compressed.

#### `ai.compressor.information`
Description: A summary or message describing the result of compression.



### AI RAG Injector logs

If you use the [AI RAG Injector Policy](/ai-gateway/policies/ai-rag-injector/), AI Gateway logs include additional fields that provide detailed information about the retrieval-augmented generation process. These fields track the vector database used, whether relevant context was injected into the prompt, the latency of data fetching, and embedding metadata such as tokens used and the embedding provider and model used.

#### `ai.proxy.rag-inject.vector_db`
Description: The vector database used (for example, `pgvector`).

#### `ai.proxy.rag-inject.injected`
Description: Boolean indicating if RAG injection occurred.

#### `ai.proxy.rag-inject.fetch_latency`
Description: The fetch latency in milliseconds.

#### `ai.proxy.rag-inject.chunk_ids`
Description: List of chunk IDs retrieved.

#### `ai.proxy.rag-inject.embeddings_latency`
Description: Time taken to generate embeddings, in milliseconds.

#### `ai.proxy.rag-inject.embeddings_tokens`
Description: Number of tokens used for embeddings.

#### `ai.proxy.rag-inject.embeddings_provider`
Description: Provider used to generate embeddings.

#### `ai.proxy.rag-inject.embeddings_model`
Description: Model used to generate embeddings.



### AI Semantic Cache logs
If you use the [AI Semantic Cache Policy](/ai-gateway/policies/ai-semantic-cache/), AI Gateway logs include additional fields under the cache object for each Policy entry. These fields provide insight into cache behavior, such as whether a response was served from cache, how long it took to fetch, and which embedding provider and model were used if applicable.

#### `ai.proxy.cache.cache_status`
Description: The cache status. This can be `Hit`, `Miss`, `Bypass`, or `Refresh`.

#### `ai.proxy.cache.fetch_latency`
Description: The time, in milliseconds, it took to return a cached response.

#### `ai.proxy.cache.embeddings_provider`
Description: The provider used to generate the embeddings.

#### `ai.proxy.cache.embeddings_model`
Description: The model used to generate the embeddings.

#### `ai.proxy.cache.embeddings_latency`
Description: The time taken to generate the embeddings.




> **Note:** When returning a cached response, `time_per_token` and `llm_latency` are omitted.
> The cache response can be returned either as a semantic cache or an exact cache. If it's returned as a semantic cache, it will include additional details such as the embeddings provider, embeddings model, and embeddings latency.

### AI LLM as Judge logs

If you use the [AI LLM as Judge Policy](/ai-gateway/policies/ai-llm-as-judge/), AI Gateway logs include additional fields under the `ai-llm-as-judge` object. These fields provide insight into evaluation behavior, such as which models were scored, latency, and the numeric accuracy assigned by the judge.

#### `ai.proxy.ai-llm-as-judge.meta.llm_latency`
Description: The time, in milliseconds, that the judge model took to return a score.

#### `ai.proxy.ai-llm-as-judge.meta.request_model`
Description: The candidate model being evaluated by the judge.

#### `ai.proxy.ai-llm-as-judge.meta.response_model`
Description: The model used as the judge (for example, `gpt-4o`).

#### `ai.proxy.ai-llm-as-judge.meta.provider_name`
Description: The provider of the judge model (for example, `openai`).

#### `ai.proxy.ai-llm-as-judge.meta.request_mode`
Description: The mode used for evaluation (for example, `oneshot`).

#### `ai.proxy.ai-llm-as-judge.usage.llm_accuracy`
Description: The numeric accuracy score (1-100) returned by the judge model.




### AI MCP logs

If you create an [AI MCP Server](/ai-gateway/entities/ai-mcp-server/), AI Gateway logs include additional fields under the `ai.mcp` object. These fields provide insight into Model Context Protocol (MCP) traffic, including session IDs, JSON-RPC request/response payloads, latency, tool usage, and access control audit entries.

The MCP log structure groups traffic by **MCP session ID**, with each session containing zero or more recorded JSON-RPC requests:


#### `ai.mcp.mcp_session_id`
Description: The ID of the MCP session. A session can contain multiple requests.

#### `ai.mcp.rpc`
Description: An array of recorded JSON-RPC requests. Only JSON-RPC traffic is logged.

#### `ai.mcp.rpc[].id`
Description: The ID of the JSON-RPC request. Not all JSON-RPC requests have an ID.

#### `ai.mcp.rpc[].latency`
Description: The latency of the JSON-RPC request, in milliseconds.

#### `ai.mcp.rpc[].payload.request`
Description: The request payload of the JSON-RPC request, serialized as a JSON string.

#### `ai.mcp.rpc[].payload.response`
Description: The response payload of the JSON-RPC request, serialized as a JSON string.

#### `ai.mcp.rpc[].method`
Description: The JSON-RPC method name.

#### `ai.mcp.rpc[].tool_name`
Description: If the method is a tool call, the name of the tool being invoked.

#### `ai.mcp.rpc[].error`
Description: The error message if an error occurred during the request.

#### `ai.mcp.rpc[].response_body_size`
Description: The size of the JSON-RPC response body, in bytes.

#### `ai.mcp.audit`
Description: An array of access control audit entries. Each entry records whether access was allowed or denied for a specific MCP primitive or globally.

#### `ai.mcp.audit[].primitive_name`
Description: The name of the MCP primitive (for example, `list_users`).

#### `ai.mcp.audit[].primitive`
Description: The type of MCP primitive (for example, `tool`, `resource`, or `prompt`).

#### `ai.mcp.audit[].action`
Description: The access control decision: `allow` or `deny`.

#### `ai.mcp.audit[].consumer.name`
Description: The name of the AI Consumer making the request.

#### `ai.mcp.audit[].consumer.id`
Description: The UUID of the AI Consumer.

#### `ai.mcp.audit[].consumer.identifier`
Description: The type of AI Consumer identifier (for example, `consumer_group`).

#### `ai.mcp.audit[].scope`
Description: The scope of the access control check.




### AI A2A Proxy logs 

If you create an [AI Agent](/ai-gateway/entities/ai-agent/), AI Gateway logs include additional fields under the `ai.a2a` object when `log_statistics` is enabled. These fields provide observability into Agent-to-Agent (A2A) protocol traffic, including operation names, task lifecycle state, latency, streaming metrics, and optional request/response payloads.

When `config.logging.log_statistics` is enabled, it writes the following fields to the
`ai.a2a.rpc[]` array:

### `ai.a2a.rpc[].method`
Type: string
Description: A2A operation name

### `ai.a2a.rpc[].binding`
Type: string
Description: Protocol binding: `jsonrpc` or `rest`

### `ai.a2a.rpc[].latency`
Type: number
Description: End-to-end proxy latency in milliseconds

### `ai.a2a.rpc[].id`
Type: string
Description: Request ID (JSON-RPC) or task ID (REST)

### `ai.a2a.rpc[].task_id`
Type: string
Description: Task ID extracted from the response

### `ai.a2a.rpc[].task_state`
Type: string
Description: Normalized task state (see [task states](/plugins/ai-a2a-proxy/#task-states))

### `ai.a2a.rpc[].context_id`
Type: string
Description: A2A context ID extracted from the response

### `ai.a2a.rpc[].error`
Type: string
Description: Error type string when the upstream returned an error

### `ai.a2a.rpc[].response_body_size`
Type: number
Description: Response body size in bytes

### `ai.a2a.rpc[].streaming`
Type: boolean
Description: `true` for SSE streaming responses

### `ai.a2a.rpc[].ttfb_latency`
Type: number
Description: Time to first byte in milliseconds (streaming only)

### `ai.a2a.rpc[].sse_events_count`
Type: number
Description: Count of SSE `data:` events received (streaming only)

### `ai.a2a.rpc[].payload.request`
Type: string
Description: Request body (only when `log_payloads` is enabled)

### `ai.a2a.rpc[].payload.response`
Type: string
Description: Response body (only when `log_payloads` is enabled)




## Example log entries

### LLM traffic entry

The following example shows a structured AI Gateway log entry:

```json
{
  "ai": {
    "payload": {
      "request": "$OPTIONAL_PAYLOAD_REQUEST"
    },
    "proxy": {
      "payload": {
        "response": "$OPTIONAL_PAYLOAD_RESPONSE"
      },
      "usage": {
      "time_per_token": 30.142857142857,
      "time_to_first_token": 631,
      "completion_tokens": 21,
      "completion_tokens_details": {
        "rejected_prediction_tokens": 0,
        "reasoning_tokens": 0,
        "accepted_prediction_tokens": 0,
        "audio_tokens": 0
      },
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "audio_tokens": 0
      },
      "prompt_tokens": 14,
      "total_tokens": 35,
      "cost": 0
    },
      "meta": {
        "request_model": "command",
        "provider_name": "cohere",
        "response_model": "command",
        "plugin_id": "546c3856-24b3-469a-bd6c-f6083babd2cd",
        "llm_latency": 2670
      },
      "cache": {
        "cache_status": "Hit",
        "fetch_latency": 12,
        "embeddings_provider": "openai",
        "embeddings_model": "text-embedding-ada-002",
        "embeddings_latency": 42
      },
      "aws-guardrails": {
        "guardrails_id": "gr-1234abcd",
        "guardrails_version": "DRAFT",
        "aws_region": "us-west-2",
        "mode": "BOTH",
        "input_processing_latency": 134,
        "output_processing_latency": 278,
        "input_block_reason": "",
        "output_block_reason": "",
        "input_block_source": "",
        "output_block_source": "",
        "input_block_consumer_id": "",
        "output_block_consumer_id": "",
        "guards_triggered_count": 0
      },
      "rag-inject": {
        "vector_db": "pgvector",
        "injected": true,
        "fetch_latency": 154,
        "chunk_ids": ["chunk-1", "chunk-2"],
        "embeddings_latency": 37,
        "embeddings_tokens": 62,
        "embeddings_provider": "openai",
        "embeddings_model": "text-embedding-ada-002"
      }
    },
    "compressor": {
      "original_token_count": 845,
      "compress_token_count": 485,
      "save_token_count": 360,
      "compress_value": 0.5,
      "compress_type": "rate",
      "compressor_model": "microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank",
      "msg_id": 1,
      "information": "Compression was performed and saved 360 tokens"
    },
    "sanitizer": {
      "pii_identified": 3,
      "pii_sanitized": 3,
      "duration": 65,
      "sanitized_items": [
        {
          "entity_type": "EMAIL",
          "original": "jane.doe@example.com",
          "sanitized": "[REDACTED]"
        },
        {
          "entity_type": "PHONE_NUMBER",
          "original": "555-123-4567",
          "sanitized": "[REDACTED]"
        }
      ]
    },
    "audit": {
      "azure_content_safety": {
        "Hate": "High",
        "Violence": "Medium"
      }
    }
  }
}
```

### MCP traffic entry

The following example shows an MCP log entry:

```json
{
  "ai": {
    "mcp": {
      "mcp_session_id": "abc123session",
      "rpc": [
        {
          "method": "tools/call",
          "latency": 6,
          "id": "2",
          "response_body_size": 5030,
          "tool_name": "list_orders"
        }
      ],
      "audit": [
        {
          "primitive_name": "list_orders",
          "consumer": {
            "id": "6c95a611-9991-407b-b1c3-bc608d3bccc3",
            "name": "admin",
            "identifier": "consumer_group"
          },
          "scope": "primitive",
          "primitive": "tool",
          "action": "allow"
        }
      ]
    }
  }
}
```



## Related Resources

- [AI Gateway](/ai-gateway/)

- [AI Gateway logs](/ai-gateway/ai-logs/)

- [Monitor AI LLM metrics (Prometheus)](/ai-gateway/monitor-ai-llm-metrics/)

- [Gen AI OpenTelemetry metrics reference](/ai-gateway/ai-otel-metrics/)

- [Model cost management](/ai-gateway/model-cost-management/)

