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

FieldTypeRequiredDescription
attributesobjectYesKey-value pairs of metric attributes (all values must be strings)
meterobjectYesThe meter definition
meter.namestringYesMeter name (see supported meters below)
meter.valuestringYesMeter value as a string

Required Attributes

All metric events must include these attributes:

AttributeDescription
agent_idUnique identifier for the calling agent
platformAI platform: AMAZON_BEDROCK, AMAZON_SAGEMAKER, AZURE_FOUNDRY, DATABRICKS, or GCP_VERTEX
πŸ“˜

SDK Note

When using the Python SDK, agent_id and platform are injected automatically by the client. You only need to specify additional attributes.

Supported Meters

ai_guard.agent β€” Agent Response Time

Records LLM agent response time as a histogram.

{
  "attributes": { "agent_id": "my-agent", "platform": "AMAZON_BEDROCK" },
  "meter": { "name": "ai_guard.agent", "value": "1234" }
}
ValueFormatDescription
Response timeInteger string (milliseconds)Time taken by the LLM agent to generate a response

ai_guard.user β€” User Session

Records 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 AttributeRequiredValuesDescription
new_sessionYes"true" or "false"Whether this event starts a new session

ai_guard.redact β€” Redaction Event

Records 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 AttributeRequiredValuesDescription
actionYes"redact" or "block"The type of redaction action taken
actorYes"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.