POST /metric
Record a metrics event. Metrics are used to track classification activity, redaction actions, agent response times, and user sessions in OneTrust AI Governance.
Endpoint
POST /metric
Authentication
Requires Authorization: Bearer <token> header. Returns 401 Unauthorized with a WWW-Authenticate header if the token is missing or invalid.
Request Body
{
"attributes": {
"agent_id": "example-agent-001",
"platform": "AMAZON_BEDROCK",
"new_session": "true"
},
"meter": {
"name": "ai_guard.user",
"value": "1"
}
}Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
attributes | object | Yes | Key-value pairs of metric attributes (all values must be strings) |
meter | object | Yes | The meter definition |
meter.name | string | Yes | Meter name (see supported meters below) |
meter.value | string | Yes | Meter value as a string |
Required Attributes
All metric events must include these attributes:
| Attribute | Description |
|---|---|
agent_id | Unique identifier for the calling agent |
platform | AI platform: AMAZON_BEDROCK, AMAZON_SAGEMAKER, AZURE_FOUNDRY, DATABRICKS, or GCP_VERTEX |
SDK NoteWhen using the Python SDK,
agent_idandplatformare injected automatically by the client. You only need to specify additional attributes.
Supported Meters
ai_guard.agent β Agent Response Time
ai_guard.agent β Agent Response TimeRecords LLM agent response time as a histogram.
{
"attributes": { "agent_id": "my-agent", "platform": "AMAZON_BEDROCK" },
"meter": { "name": "ai_guard.agent", "value": "1234" }
}| Value | Format | Description |
|---|---|---|
| Response time | Integer string (milliseconds) | Time taken by the LLM agent to generate a response |
ai_guard.user β User Session
ai_guard.user β User SessionRecords a user interaction or session event as a counter.
{
"attributes": { "agent_id": "my-agent", "platform": "AMAZON_BEDROCK", "new_session": "true" },
"meter": { "name": "ai_guard.user", "value": "1" }
}| Additional Attribute | Required | Values | Description |
|---|---|---|---|
new_session | Yes | "true" or "false" | Whether this event starts a new session |
ai_guard.redact β Redaction Event
ai_guard.redact β Redaction EventRecords a redaction or block action as a counter.
{
"attributes": { "agent_id": "my-agent", "platform": "AMAZON_BEDROCK", "action": "redact", "actor": "user" },
"meter": { "name": "ai_guard.redact", "value": "1" }
}| Additional Attribute | Required | Values | Description |
|---|---|---|---|
action | Yes | "redact" or "block" | The type of redaction action taken |
actor | Yes | "user" or "agent" | Source of the classified text |
Response
200 OK
Returns an empty body on success.
Error Responses
400 Bad Request
Returned if metrics are not enabled on the server or the request is malformed:
{
"code": 400,
"message": "Metrics not permitted"
}401 Unauthorized
{
"code": 401,
"message": "Invalid or missing bearer token"
}curl Example
curl -X POST https://localhost:4443/metric \
--pinnedpubkey "sha256//x48Lk2iu3R3nAhSiz07bExGHTusDRjHqBx9ArK3cFGE=" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"attributes": { "agent_id": "my-agent", "platform": "AMAZON_BEDROCK", "new_session": "true" },
"meter": {
"name": "ai_guard.user",
"value": "1"
}
}'SDK Usage
For Python SDK usage, see Observability & Metrics.
Updated 3 days ago