GET https://api.ap1.datadoghq.com/api/v1/query https://api.ap2.datadoghq.com/api/v1/query https://api.datadoghq.eu/api/v1/query https://api.ddog-gov.com/api/v1/query https://api.us2.ddog-gov.com/api/v1/query https://api.uk1.datadoghq.com/api/v1/query https://api.datadoghq.com/api/v1/query https://api.us3.datadoghq.com/api/v1/query https://api.us5.datadoghq.com/api/v1/query
Présentation Interrogez les points de séries temporelles.
This endpoint requires the timeseries_query permission.
OAuth apps require the timeseries_query authorization scope to access this endpoint.
Arguments Chaînes de requête Start of the queried time period, seconds since the Unix epoch.
End of the queried time period, seconds since the Unix epoch.
Réponse OK
Response Object that includes your query and the list of metrics retrieved.
Expand All
Message indicating the errors if status is not ok.
Start of requested time window, milliseconds since Unix epoch.
List of tag keys on which to group.
Message indicating success if status is ok.
List of timeseries queried.
Display name of the metric.
End of the time window, milliseconds since Unix epoch.
Number of milliseconds between data samples.
List of points of the timeseries in milliseconds.
The index of the series' query within the request.
Metric scope, comma separated list of tags.
Start of the time window, milliseconds since Unix epoch.
Unique tags identifying this series.
Detailed information about the metric unit.
The first element describes the "primary unit" (for example, bytes in bytes per second).
The second element describes the "per unit" (for example, second in bytes per second).
If the second element is not present, the API returns null.
Unit family, allows for conversion between units of the same family, for scaling.
Plural form of the unit name.
Factor for scaling between units of the same family.
Abbreviation of the unit.
End of requested time window, milliseconds since Unix epoch.
{
"error" : "string" ,
"from_date" : "integer" ,
"group_by" : [],
"message" : "string" ,
"query" : "string" ,
"res_type" : "time_series" ,
"series" : [
{
"aggr" : "avg" ,
"display_name" : "system.cpu.idle" ,
"end" : "integer" ,
"expression" : "system.cpu.idle{host:foo,env:test}" ,
"interval" : "integer" ,
"length" : "integer" ,
"metric" : "system.cpu.idle" ,
"pointlist" : [
[
1681683300000 ,
77.62145685254418
]
],
"query_index" : "integer" ,
"scope" : "host:foo,env:test" ,
"start" : "integer" ,
"tag_set" : [],
"unit" : [
{
"family" : "time" ,
"name" : "minute" ,
"plural" : "minutes" ,
"scale_factor" : 60 ,
"short_name" : "min"
}
]
}
],
"status" : "ok" ,
"to_date" : "integer"
} Bad Request
Error response object.
Expand All
Array of errors returned by the API.
{
"errors" : [
"Bad Request"
]
} Forbidden
Error response object.
Expand All
Array of errors returned by the API.
{
"errors" : [
"Bad Request"
]
} Too many requests
Error response object.
Expand All
Array of errors returned by the API.
{
"errors" : [
"Bad Request"
]
} Exemple de code Copier
# Required query arguments export from = "CHANGE_ME" export to = "CHANGE_ME" export query = "CHANGE_ME" # Curl command curl -X GET "https://api.ap1.datadoghq.com "https://api.ap2.datadoghq.com "https://api.datadoghq.eu "https://api.ddog-gov.com "https://api.us2.ddog-gov.com "https://api.uk1.datadoghq.com "https://api.datadoghq.com "https://api.us3.datadoghq.com "https://api.us5.datadoghq.com /api/v1/query ? from = ${from} & to = ${to} & query = ${query} " \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY} " \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY} "
"""
Query timeseries points returns "OK" response
"""
from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient , Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
configuration = Configuration ()
with ApiClient ( configuration ) as api_client :
api_instance = MetricsApi ( api_client )
response = api_instance . query_metrics (
_from = int (( datetime . now () + relativedelta ( days =- 1 )) . timestamp ()),
to = int ( datetime . now () . timestamp ()),
query = "system.cpu.idle{*}" ,
)
print ( response )
Instructions First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" python3 "example.py"
# Query timeseries points returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient :: V1 :: MetricsAPI . new
p api_instance . query_metrics (( Time . now + - 1 * 86400 ) . to_i , Time . now . to_i , "system.cpu.idle{*}" )
Instructions First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi :: Client . new ( api_key , app_key )
# Get points from the last hour
from = Time . now - 3600
to = Time . now
query = 'system.cpu.idle{*}by{host}'
dog . get_points ( query , from , to ) Instructions First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" rb "example.rb"
// Query timeseries points returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main () {
ctx := datadog . NewDefaultContext ( context . Background ())
configuration := datadog . NewConfiguration ()
apiClient := datadog . NewAPIClient ( configuration )
api := datadogV1 . NewMetricsApi ( apiClient )
resp , r , err := api . QueryMetrics ( ctx , time . Now (). AddDate ( 0 , 0 , - 1 ). Unix (), time . Now (). Unix (), "system.cpu.idle{*}" )
if err != nil {
fmt . Fprintf ( os . Stderr , "Error when calling `MetricsApi.QueryMetrics`: %v\n" , err )
fmt . Fprintf ( os . Stderr , "Full HTTP response: %v\n" , r )
}
responseContent , _ := json . MarshalIndent ( resp , "" , " " )
fmt . Fprintf ( os . Stdout , "Response from `MetricsApi.QueryMetrics`:\n%s\n" , responseContent )
}
Instructions First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" go run "main.go"
// Query timeseries points returns "OK" response
import com.datadog.api.client.ApiClient ;
import com.datadog.api.client.ApiException ;
import com.datadog.api.client.v1.api.MetricsApi ;
import com.datadog.api.client.v1.model.MetricsQueryResponse ;
import java.time.OffsetDateTime ;
public class Example {
public static void main ( String [] args ) {
ApiClient defaultClient = ApiClient . getDefaultApiClient ();
MetricsApi apiInstance = new MetricsApi ( defaultClient );
try {
MetricsQueryResponse result =
apiInstance . queryMetrics (
OffsetDateTime . now (). plusDays ( - 1 ). toInstant (). getEpochSecond (),
OffsetDateTime . now (). toInstant (). getEpochSecond (),
"system.cpu.idle{*}" );
System . out . println ( result );
} catch ( ApiException e ) {
System . err . println ( "Exception when calling MetricsApi#queryMetrics" );
System . err . println ( "Status code: " + e . getCode ());
System . err . println ( "Reason: " + e . getResponseBody ());
System . err . println ( "Response headers: " + e . getResponseHeaders ());
e . printStackTrace ();
}
}
}
Instructions First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" java "Example.java"
from datadog import initialize , api
import time
options = {
'api_key' : '<DATADOG_API_KEY>' ,
'app_key' : '<DATADOG_APPLICATION_KEY>'
}
initialize ( ** options )
now = int ( time . time ())
query = 'system.cpu.idle{*}by {host} '
print ( api . Metric . query ( start = now - 3600 , end = now , query = query ))
Instructions First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" python "example.py"
// Query timeseries points returns "OK" response
use datadog_api_client ::datadog ;
use datadog_api_client ::datadogV1 ::api_metrics ::MetricsAPI ;
#[tokio::main]
async fn main () {
let configuration = datadog ::Configuration ::new ();
let api = MetricsAPI ::with_config ( configuration );
let resp = api
. query_metrics ( 1636542671 , 1636629071 , "system.cpu.idle{*}" . to_string ())
. await ;
if let Ok ( value ) = resp {
println! ( " {:#?} " , value );
} else {
println! ( " {:#?} " , resp . unwrap_err ());
}
}
Instructions First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" cargo run
/**
* Query timeseries points returns "OK" response
*/
import { client , v1 } from "@datadog/datadog-api-client" ;
const configuration = client . createConfiguration ();
const apiInstance = new v1 . MetricsApi ( configuration );
const params : v1.MetricsApiQueryMetricsRequest = {
from : Math . round (
new Date ( new Date (). getTime () + - 1 * 86400 * 1000 ). getTime () / 1000
),
to : Math.round ( new Date (). getTime () / 1000 ),
query : "system.cpu.idle{*}" ,
};
apiInstance
. queryMetrics ( params )
. then (( data : v1.MetricsQueryResponse ) => {
console . log (
"API called successfully. Returned data: " + JSON . stringify ( data )
);
})
. catch (( error : any ) => console . error ( error ));
Instructions First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE = "datadoghq.com us3.datadoghq.com us5.datadoghq.com datadoghq.eu ap1.datadoghq.com ap2.datadoghq.com uk1.datadoghq.com ddog-gov.com us2.ddog-gov.com " DD_API_KEY = "<DD_API_KEY>" DD_APP_KEY = "<DD_APP_KEY>" tsc "example.ts"