> ## Documentation Index
> Fetch the complete documentation index at: https://developer.onetrust.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Meter Definitions

The AI Guard service registers four meters under the instrument name `ai-guard-server`. Three are submitted by clients via `POST /metric`, and one is generated automatically from classification responses.

## Required Attributes

All meters require the following attributes:

| Attribute  | Description                                | Example            |
| ---------- | ------------------------------------------ | ------------------ |
| `agent_id` | Unique identifier for the calling AI agent | `"my-agent"`       |
| `platform` | AI platform originating the request        | `"AMAZON_BEDROCK"` |

### Supported Platform Values

| Platform               | Value              |
| ---------------------- | ------------------ |
| Amazon Bedrock         | `AMAZON_BEDROCK`   |
| Amazon SageMaker       | `AMAZON_SAGEMAKER` |
| Azure AI Foundry       | `AZURE_FOUNDRY`    |
| Databricks             | `DATABRICKS`       |
| Google Cloud Vertex AI | `GCP_VERTEX`       |

## Meter Reference

### `ai_guard.agent` — Agent Response Time

| Property                | Value                                          |
| ----------------------- | ---------------------------------------------- |
| **Type**                | Histogram (u64)                                |
| **Source**              | `POST /metric` (SDK)                           |
| **Value**               | Response time in milliseconds (integer string) |
| **Required Attributes** | `agent_id`, `platform`                         |

Records the response time of the LLM agent. Used to track agent performance and latency trends.

**SDK Example:**

```python
client.metric(MetricsEvent(
    attributes={},
    meter=MetricsEventMeter(name="ai_guard.agent", value="1234"),
))
```

**Export Statistics (OneTrust exporter):**

| Statistic | Description                                                    |
| --------- | -------------------------------------------------------------- |
| `AVG`     | Average response time (`sum / count`)                          |
| `MIN`     | Minimum response time in the interval                          |
| `MAX`     | Maximum response time in the interval                          |
| `P99`     | 99th percentile, interpolated from histogram bucket boundaries |

***

### `ai_guard.user` — User Session

| Property                | Value                                 |
| ----------------------- | ------------------------------------- |
| **Type**                | Counter (u64)                         |
| **Source**              | `POST /metric` (SDK)                  |
| **Value**               | `"1"`                                 |
| **Required Attributes** | `agent_id`, `platform`, `new_session` |

Records user interactions and session starts. Used to track engagement metrics.

| Additional Attribute | Values               | Description                                   |
| -------------------- | -------------------- | --------------------------------------------- |
| `new_session`        | `"true"` / `"false"` | Whether this interaction starts a new session |

**SDK Example:**

```python
client.metric(MetricsEvent(
    attributes={"new_session": "true"},
    meter=MetricsEventMeter(name="ai_guard.user", value="1"),
))
```

***

### `ai_guard.redact` — Redaction Event

| Property                | Value                                     |
| ----------------------- | ----------------------------------------- |
| **Type**                | Counter (u64)                             |
| **Source**              | `POST /metric` (SDK)                      |
| **Value**               | `"1"`                                     |
| **Required Attributes** | `agent_id`, `platform`, `action`, `actor` |

Records redaction and block events. Used to track how often sensitive data is detected and acted upon.

| Additional Attribute | Values                 | Description                   |
| -------------------- | ---------------------- | ----------------------------- |
| `action`             | `"redact"` / `"block"` | The type of action taken      |
| `actor`              | `"user"` / `"agent"`   | Source of the classified text |

**SDK Example:**

```python
client.metric(MetricsEvent(
    attributes={"action": "redact", "actor": "user"},
    meter=MetricsEventMeter(name="ai_guard.redact", value="1"),
))
```

***

### `ai_guard.classification` — Classification Count

| Property                | Value                                                 |
| ----------------------- | ----------------------------------------------------- |
| **Type**                | Counter (u64)                                         |
| **Source**              | Auto-generated (per match in classification response) |
| **Value**               | `"1"` (per match)                                     |
| **Required Attributes** | `agent_id`, `platform`, `actor`, `classifier`         |

Automatically incremented once per classifier match in a classification response. Tracks which types of sensitive data are being detected most frequently.

| Attribute    | Source               | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| `agent_id`   | From request context | Unique agent identifier                                    |
| `platform`   | From request context | AI platform identifier                                     |
| `actor`      | From request context | `"user"` or `"agent"`                                      |
| `classifier` | Auto-set by service  | The classifier code that matched (e.g., `US_PHONE_NUMBER`) |

> ⚠️ Not Submittable
>
> This meter is generated **automatically** by the service. It **cannot** be submitted via `POST /metric` or `client.metric()`.

## Custom Attributes

The service supports optional additional attribute keys beyond the built-in required keys. These are configured in the `metrics.allowed-attributes` section of the service configuration:

```yaml
metrics:
  allowed-attributes:
    - custom_key
    - environment
```

Attributes not in the allowed set or the required set (`agent_id`, `platform`) are rejected with a `400 Bad Request`.

## What's Next?

* [Metrics Exporters](https://developer.onetrust.com/onetrust/docs/ai-guard-exporters) — How metrics are exported to AI Governance
* [Metrics Overview](https://developer.onetrust.com/onetrust/docs/ai-guard-metrics-overview) — Pipeline architecture
* [Observability & Metrics (SDK)](https://developer.onetrust.com/onetrust/docs/ai-guard-metrics) — Send metrics from your application