Skip to main content
POST
/
v2
/
metrics
Get metrics with filtering and grouping
curl --request POST \
  --url https://api.traceloop.com/v2/metrics \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "from_timestamp_sec": 1772905218,
  "to_timestamp_sec": 1772905218,
  "cursor": 1772905218000,
  "environments": [
    "prd",
    "stg",
    "dev"
  ],
  "filters": [
    {
      "field": "labels.agent_name",
      "operator": "equals",
      "value": "Travel Planner Agent",
      "values": [
        "Travel Planner Agent",
        "Calendar Planner Agent"
      ]
    }
  ],
  "limit": 50,
  "logical_operator": "AND",
  "metric_name": "answer relevancy",
  "metric_source": "llm_as_a_judge",
  "sort_by": "timestamp",
  "sort_order": "ASC"
}
'
{
  "metrics": {
    "data": [
      {
        "metric_name": "answer relevancy",
        "organization_id": "<string>",
        "points": [
          {
            "bool_value": true,
            "enum_value": "<string>",
            "numeric_value": 123,
            "event_time": 123,
            "labels": {
              "agent_name": "Travel Planner Agent",
              "entity_type": "span",
              "env_project_id": "1111",
              "environment": "dev",
              "evaluator_name": "",
              "insert_time": "1772616490000",
              "metric_source": "word_count",
              "metric_type": "numeric",
              "model": "gpt-4o-2024-08-06",
              "org_id": "12345",
              "run_id": "54321",
              "service_name": "travel-agent-demo",
              "span_id": "e118a1985c9cff23",
              "trace_id": "2c98a42d1225cb786f3395d97ca3014d",
              "unit": "words",
              "vendor": "openai"
            }
          }
        ]
      }
    ],
    "next_cursor": "<string>",
    "total_points": 123,
    "total_results": 123
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Metrics query parameters including filters, environments, and pagination

from_timestamp_sec
integer

Start time in Unix seconds timestamp.

Example:

1772905218

to_timestamp_sec
integer

End time in Unix seconds timestamp.

Example:

1772905218

cursor
integer

Pagination cursor for fetching the next page of results. The cursor is returned in the response to the previous request.

Example:

1772905218000

environments
string[]

List of environments to filter by

Example:
["prd", "stg", "dev"]
filters
object[]
limit
integer

Maximum number of metrics to return per page.

Example:

50

logical_operator
enum<string>
Available options:
AND,
OR
metric_name
string

Metric name to filter by. The metric_name is a metric attribute that is set on the metric object.

Example:

"answer relevancy"

metric_source
string

Metric source to filter by. The metric_source is a metric attribute that is set on the metric object.

Example:

"llm_as_a_judge"

sort_by
string

Field to sort by.

Example:

"timestamp"

sort_order
string

Sort order.

Example:

"ASC"

Response

Grouped metrics with data points

metrics
object