Get metrics with filtering and grouping
Changed onRetrieves metrics data with support for filtering, sorting, and pagination. Metrics are grouped by metric name with individual data points. Supports filtering by direct column fields (bool_value, trace_id, etc.), label fields (labels.agent_name, labels.trace_id), and attribute fields (attributes.*).
Request
- Base URLhttps://api.traceloop.com
- Authnone declared
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"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,
"metric_name": "answer relevancy",
"metric_source": "llm_as_a_judge",
"sort_by": "timestamp",
"sort_order": "ASC"
}Response
Grouped metrics with data points
Example response
{
"metrics": {
"data": [
{
"metric_name": "answer relevancy",
"points": [
{
"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"
}
}
]
}
]
}
}Changes
- breaking
request property
//was restricted to a list of enum values - warning
deleted the
pathrequest parameterproject_id - warning
removed the request property
// - info
added the new
containsenum value to the request property// - info
added the new
equalsenum value to the request property// - info
added the new
inenum value to the request property// - info
added the new
not_containsenum value to the request property// - info
added the new
not_equalsenum value to the request property// - info
added the new
not_inenum value to the request property//
- breaking
- warning
removed the request property
// - info
added the new optional request property
//
- warning