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 '
{
"cursor": 123,
"environments": [
"<string>"
],
"filters": [
{
"field": "<string>",
"operator": "<string>",
"value": "<string>",
"valueType": "<string>",
"values": [
"<string>"
]
}
],
"from_timestamp_sec": 123,
"limit": 123,
"metric_name": "<string>",
"metric_source": "<string>",
"sort_by": "<string>",
"sort_order": "<string>",
"to_timestamp_sec": 123
}
'import requests
url = "https://api.traceloop.com/v2/metrics"
payload = {
"cursor": 123,
"environments": ["<string>"],
"filters": [
{
"field": "<string>",
"operator": "<string>",
"value": "<string>",
"valueType": "<string>",
"values": ["<string>"]
}
],
"from_timestamp_sec": 123,
"limit": 123,
"metric_name": "<string>",
"metric_source": "<string>",
"sort_by": "<string>",
"sort_order": "<string>",
"to_timestamp_sec": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cursor: 123,
environments: ['<string>'],
filters: [
{
field: '<string>',
operator: '<string>',
value: '<string>',
valueType: '<string>',
values: ['<string>']
}
],
from_timestamp_sec: 123,
limit: 123,
metric_name: '<string>',
metric_source: '<string>',
sort_by: '<string>',
sort_order: '<string>',
to_timestamp_sec: 123
})
};
fetch('https://api.traceloop.com/v2/metrics', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.traceloop.com/v2/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cursor' => 123,
'environments' => [
'<string>'
],
'filters' => [
[
'field' => '<string>',
'operator' => '<string>',
'value' => '<string>',
'valueType' => '<string>',
'values' => [
'<string>'
]
]
],
'from_timestamp_sec' => 123,
'limit' => 123,
'metric_name' => '<string>',
'metric_source' => '<string>',
'sort_by' => '<string>',
'sort_order' => '<string>',
'to_timestamp_sec' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.traceloop.com/v2/metrics"
payload := strings.NewReader("{\n \"cursor\": 123,\n \"environments\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\",\n \"valueType\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"from_timestamp_sec\": 123,\n \"limit\": 123,\n \"metric_name\": \"<string>\",\n \"metric_source\": \"<string>\",\n \"sort_by\": \"<string>\",\n \"sort_order\": \"<string>\",\n \"to_timestamp_sec\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.traceloop.com/v2/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cursor\": 123,\n \"environments\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\",\n \"valueType\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"from_timestamp_sec\": 123,\n \"limit\": 123,\n \"metric_name\": \"<string>\",\n \"metric_source\": \"<string>\",\n \"sort_by\": \"<string>\",\n \"sort_order\": \"<string>\",\n \"to_timestamp_sec\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.traceloop.com/v2/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cursor\": 123,\n \"environments\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\",\n \"valueType\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"from_timestamp_sec\": 123,\n \"limit\": 123,\n \"metric_name\": \"<string>\",\n \"metric_source\": \"<string>\",\n \"sort_by\": \"<string>\",\n \"sort_order\": \"<string>\",\n \"to_timestamp_sec\": 123\n}"
response = http.request(request)
puts response.read_body{
"metrics": {
"data": [
{
"metric_name": "<string>",
"organization_id": "<string>",
"points": [
{
"bool_value": true,
"enum_value": "<string>",
"event_time": 123,
"labels": {},
"numeric_value": 123
}
]
}
],
"next_cursor": "<string>",
"total_points": 123,
"total_results": 123
}
}{
"error": "error message"
}{
"error": "error message"
}{
"error": "error message"
}Metrics
Get metrics with filtering and grouping
Retrieves 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.*).
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 '
{
"cursor": 123,
"environments": [
"<string>"
],
"filters": [
{
"field": "<string>",
"operator": "<string>",
"value": "<string>",
"valueType": "<string>",
"values": [
"<string>"
]
}
],
"from_timestamp_sec": 123,
"limit": 123,
"metric_name": "<string>",
"metric_source": "<string>",
"sort_by": "<string>",
"sort_order": "<string>",
"to_timestamp_sec": 123
}
'import requests
url = "https://api.traceloop.com/v2/metrics"
payload = {
"cursor": 123,
"environments": ["<string>"],
"filters": [
{
"field": "<string>",
"operator": "<string>",
"value": "<string>",
"valueType": "<string>",
"values": ["<string>"]
}
],
"from_timestamp_sec": 123,
"limit": 123,
"metric_name": "<string>",
"metric_source": "<string>",
"sort_by": "<string>",
"sort_order": "<string>",
"to_timestamp_sec": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cursor: 123,
environments: ['<string>'],
filters: [
{
field: '<string>',
operator: '<string>',
value: '<string>',
valueType: '<string>',
values: ['<string>']
}
],
from_timestamp_sec: 123,
limit: 123,
metric_name: '<string>',
metric_source: '<string>',
sort_by: '<string>',
sort_order: '<string>',
to_timestamp_sec: 123
})
};
fetch('https://api.traceloop.com/v2/metrics', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.traceloop.com/v2/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cursor' => 123,
'environments' => [
'<string>'
],
'filters' => [
[
'field' => '<string>',
'operator' => '<string>',
'value' => '<string>',
'valueType' => '<string>',
'values' => [
'<string>'
]
]
],
'from_timestamp_sec' => 123,
'limit' => 123,
'metric_name' => '<string>',
'metric_source' => '<string>',
'sort_by' => '<string>',
'sort_order' => '<string>',
'to_timestamp_sec' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.traceloop.com/v2/metrics"
payload := strings.NewReader("{\n \"cursor\": 123,\n \"environments\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\",\n \"valueType\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"from_timestamp_sec\": 123,\n \"limit\": 123,\n \"metric_name\": \"<string>\",\n \"metric_source\": \"<string>\",\n \"sort_by\": \"<string>\",\n \"sort_order\": \"<string>\",\n \"to_timestamp_sec\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.traceloop.com/v2/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cursor\": 123,\n \"environments\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\",\n \"valueType\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"from_timestamp_sec\": 123,\n \"limit\": 123,\n \"metric_name\": \"<string>\",\n \"metric_source\": \"<string>\",\n \"sort_by\": \"<string>\",\n \"sort_order\": \"<string>\",\n \"to_timestamp_sec\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.traceloop.com/v2/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cursor\": 123,\n \"environments\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\",\n \"valueType\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"from_timestamp_sec\": 123,\n \"limit\": 123,\n \"metric_name\": \"<string>\",\n \"metric_source\": \"<string>\",\n \"sort_by\": \"<string>\",\n \"sort_order\": \"<string>\",\n \"to_timestamp_sec\": 123\n}"
response = http.request(request)
puts response.read_body{
"metrics": {
"data": [
{
"metric_name": "<string>",
"organization_id": "<string>",
"points": [
{
"bool_value": true,
"enum_value": "<string>",
"event_time": 123,
"labels": {},
"numeric_value": 123
}
]
}
],
"next_cursor": "<string>",
"total_points": 123,
"total_results": 123
}
}{
"error": "error message"
}{
"error": "error message"
}{
"error": "error message"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Project ID
Body
application/json
Metrics query parameters including filters, environments, and pagination
Response
Grouped metrics with data points
Show child attributes
Show child attributes
Was this page helpful?
⌘I

