Skip to main content
POST
/
v3
/
queries
API to fetch metrics used to plot monitoring charts
curl --request POST \
  --url https://api.example.com/v3/queries \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "queries": [
    {
      "query_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "model_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "metric": "<string>",
      "columns": [
        "<string>"
      ],
      "baseline_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "categories": [
        "<string>"
      ],
      "segment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "segment": {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "definition": "<string>"
      }
    }
  ]
}
'
import requests

url = "https://api.example.com/v3/queries"

payload = {
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"queries": [
{
"query_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metric": "<string>",
"columns": ["<string>"],
"baseline_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"categories": ["<string>"],
"segment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"segment": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition": "<string>"
}
}
]
}
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({
project_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
queries: [
{
query_key: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
model_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
metric: '<string>',
columns: ['<string>'],
baseline_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
categories: ['<string>'],
segment_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
segment: {id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', definition: '<string>'}
}
]
})
};

fetch('https://api.example.com/v3/queries', 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.example.com/v3/queries",
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([
'project_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'queries' => [
[
'query_key' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'model_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'metric' => '<string>',
'columns' => [
'<string>'
],
'baseline_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'categories' => [
'<string>'
],
'segment_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'segment' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'definition' => '<string>'
]
]
]
]),
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.example.com/v3/queries"

payload := strings.NewReader("{\n \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"queries\": [\n {\n \"query_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metric\": \"<string>\",\n \"columns\": [\n \"<string>\"\n ],\n \"baseline_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"categories\": [\n \"<string>\"\n ],\n \"segment_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"segment\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"definition\": \"<string>\"\n }\n }\n ]\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.example.com/v3/queries")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"queries\": [\n {\n \"query_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metric\": \"<string>\",\n \"columns\": [\n \"<string>\"\n ],\n \"baseline_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"categories\": [\n \"<string>\"\n ],\n \"segment_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"segment\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"definition\": \"<string>\"\n }\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v3/queries")

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 \"project_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"queries\": [\n {\n \"query_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metric\": \"<string>\",\n \"columns\": [\n \"<string>\"\n ],\n \"baseline_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"categories\": [\n \"<string>\"\n ],\n \"segment_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"segment\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"definition\": \"<string>\"\n }\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "api_version": "3.0",
  "kind": "NORMAL",
  "data": {
    "organization": {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "name": "<string>"
    },
    "project": {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "name": "<string>"
    },
    "filters": {
      "time_zone": "Etc/GMT",
      "bin_size": "Hour",
      "time_range": {
        "start_time": "2023-11-07T05:31:56Z",
        "end_time": "2023-11-07T05:31:56Z"
      }
    },
    "results": {}
  }
}
{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}
{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}
{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}
{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Monitoring queries request object

project_id
string<uuid>
required

Unique identifier of the project

time_comparison
enum<string>

Specifes the time period to comapre the data against

Available options:
Previous Day,
Previous Week,
Previous Month,
Previous Quarter,
Previous Year
query_type
enum<string>

Specfies the query type to fetch the corresponding metrics

Available options:
MONITORING,
EMBEDDING,
ANALYTICS
filters
QueryFilter · object

Filters for querying data, including time, time zone, and bin size.

queries
Monitoring query request fields · object[]

Response

OK

Response object for standard API responses.

api_version
enum<string>
default:3.0

API version.

Available options:
2.0,
3.0
kind
enum<string>
default:NORMAL

Type of response, indicating a normal response.

Available options:
NORMAL
data
object