Post metrics data so it can be graphed on Datadog’s dashboards
Query metrics from any time period
Modify tag configurations for metrics
View tags and volumes for metrics
Note: A graph can only contain a set number of points
and as the timeframe over which a metric is viewed increases,
aggregation between points occurs to stay below that set number.
The Post, Patch, and Delete manage_tags API methods can only be performed by
a user who has the Manage Tags for Metrics permission.
Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric.
Optionally, include percentile aggregations on any distribution metric. By setting exclude_tags_mode
to true, the behavior is changed from an allow-list to a deny-list, and tags in the defined list are
not queryable. Can only be used with application keys of users with the Manage Tags for Metrics
permission.
This endpoint requires the metric_tags_write permission.
Object for a single metric to be configure tags on.
attributes
object
Object containing the definition of a metric tag configuration to be created.
aggregations
[object]
Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags property.
include_percentiles
boolean
Toggle to include/exclude percentiles for a distribution metric.
Defaults to false. Can only be applied to metrics that have a metric_type of distribution.
metric_type [required]
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
tags [required]
[string]
A list of tag keys that will be queryable for your metric.
default:
id [required]
string
The metric name for this resource.
type [required]
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
Response object which includes a single metric’s tag configuration.
Expand All
Field
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags property.
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
// Create a tag configuration returns "Created" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){body:=datadogV2.MetricTagConfigurationCreateRequest{Data:datadogV2.MetricTagConfigurationCreateData{Type:datadogV2.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,Id:"ExampleMetric",Attributes:&datadogV2.MetricTagConfigurationCreateAttributes{Tags:[]string{"app","datacenter",},MetricType:datadogV2.METRICTAGCONFIGURATIONMETRICTYPES_GAUGE,},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.CreateTagConfiguration(ctx,"ExampleMetric",body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.CreateTagConfiguration`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.CreateTagConfiguration`:\n%s\n",responseContent)}
"""
Create a tag configuration returns "Created" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApifromdatadog_api_client.v2.model.metric_tag_configuration_create_attributesimport(MetricTagConfigurationCreateAttributes,)fromdatadog_api_client.v2.model.metric_tag_configuration_create_dataimportMetricTagConfigurationCreateDatafromdatadog_api_client.v2.model.metric_tag_configuration_create_requestimportMetricTagConfigurationCreateRequestfromdatadog_api_client.v2.model.metric_tag_configuration_metric_typesimportMetricTagConfigurationMetricTypesfromdatadog_api_client.v2.model.metric_tag_configuration_typeimportMetricTagConfigurationTypebody=MetricTagConfigurationCreateRequest(data=MetricTagConfigurationCreateData(type=MetricTagConfigurationType.MANAGE_TAGS,id="ExampleMetric",attributes=MetricTagConfigurationCreateAttributes(tags=["app","datacenter",],metric_type=MetricTagConfigurationMetricTypes.GAUGE,),),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.create_tag_configuration(metric_name="ExampleMetric",body=body)print(response)
# Create a tag configuration returns "Created" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newbody=DatadogAPIClient::V2::MetricTagConfigurationCreateRequest.new({data:DatadogAPIClient::V2::MetricTagConfigurationCreateData.new({type:DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS,id:"ExampleMetric",attributes:DatadogAPIClient::V2::MetricTagConfigurationCreateAttributes.new({tags:["app","datacenter",],metric_type:DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE,}),}),})papi_instance.create_tag_configuration("ExampleMetric",body)
// Create a tag configuration returns "Created" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;usedatadog_api_client::datadogV2::model::MetricTagConfigurationCreateAttributes;usedatadog_api_client::datadogV2::model::MetricTagConfigurationCreateData;usedatadog_api_client::datadogV2::model::MetricTagConfigurationCreateRequest;usedatadog_api_client::datadogV2::model::MetricTagConfigurationMetricTypes;usedatadog_api_client::datadogV2::model::MetricTagConfigurationType;#[tokio::main]asyncfnmain(){letbody=MetricTagConfigurationCreateRequest::new(MetricTagConfigurationCreateData::new("ExampleMetric".to_string(),MetricTagConfigurationType::MANAGE_TAGS,).attributes(MetricTagConfigurationCreateAttributes::new(MetricTagConfigurationMetricTypes::GAUGE,vec!["app".to_string(),"datacenter".to_string()],)),);letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.create_tag_configuration("ExampleMetric".to_string(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Create a tag configuration returns "Created" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiCreateTagConfigurationRequest={body:{data:{type:"manage_tags",id:"ExampleMetric",attributes:{tags:["app","datacenter"],metricType:"gauge",},},},metricName:"ExampleMetric",};apiInstance.createTagConfiguration(params).then((data: v2.MetricTagConfigurationResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get active metrics list returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_active_metrics(_from=9223372036854775807,)print(response)
# Get active metrics list returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::MetricsAPI.newpapi_instance.list_active_metrics(9223372036854775807)
// Get active metrics list returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewMetricsApi(apiClient)resp,r,err:=api.ListActiveMetrics(ctx,9223372036854775807,*datadogV1.NewListActiveMetricsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListActiveMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListActiveMetrics`:\n%s\n",responseContent)}
// Get active metrics list returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.MetricsApi;importcom.datadog.api.client.v1.model.MetricsListResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);try{MetricsListResponseresult=apiInstance.listActiveMetrics(9223372036854775807L);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listActiveMetrics");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
fromdatadogimportinitialize,apiimporttimeoptions={'api_key':'<DATADOG_API_KEY>','app_key':'<DATADOG_APPLICATION_KEY>'}initialize(**options)# Taking the last 24hoursfrom_time=int(time.time())-60*60*24*1result=api.Metric.list(from_time)print(result)
// Get active metrics list returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_metrics::ListActiveMetricsOptionalParams;usedatadog_api_client::datadogV1::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_active_metrics(9223372036854775807,ListActiveMetricsOptionalParams::default(),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get active metrics list returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiListActiveMetricsRequest={from:9223372036854775807,};apiInstance.listActiveMetrics(params).then((data: v1.MetricsListResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
require'rubygems'require'dogapi'api_key='<DATADOG_API_KEY>'app_key='<DATADOG_APPLICATION_KEY>'dog=Dogapi::Client.new(api_key,app_key)# Get metadata on metricresult=dog.get_metadata('system.net.bytes_sent')
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get metric metadata returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiGetMetricMetadataRequest={metricName:"metric_name",};apiInstance.getMetricMetadata(params).then((data: v1.MetricMetadata)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Response object which includes a single metric’s tag configuration.
Expand All
Field
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags property.
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
"""
List tag configuration by name returns "Success" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApi# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=environ["METRIC_TAG_CONFIGURATION_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_tag_configuration_by_name(metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,)print(response)
# List tag configuration by name returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.new# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]papi_instance.list_tag_configuration_by_name(METRIC_TAG_CONFIGURATION_DATA_ID)
// List tag configuration by name returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "metric_tag_configuration" in the systemMetricTagConfigurationDataID:=os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListTagConfigurationByName(ctx,MetricTagConfigurationDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListTagConfigurationByName`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListTagConfigurationByName`:\n%s\n",responseContent)}
// List tag configuration by name returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricTagConfigurationResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the systemStringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");try{MetricTagConfigurationResponseresult=apiInstance.listTagConfigurationByName(METRIC_TAG_CONFIGURATION_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listTagConfigurationByName");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// List tag configuration by name returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){// there is a valid "metric_tag_configuration" in the system
letmetric_tag_configuration_data_id=std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_tag_configuration_by_name(metric_tag_configuration_data_id.clone()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List tag configuration by name returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);// there is a valid "metric_tag_configuration" in the system
constMETRIC_TAG_CONFIGURATION_DATA_ID=process.env.METRIC_TAG_CONFIGURATION_DATA_IDasstring;constparams: v2.MetricsApiListTagConfigurationByNameRequest={metricName: METRIC_TAG_CONFIGURATION_DATA_ID,};apiInstance.listTagConfigurationByName(params).then((data: v2.MetricTagConfigurationResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Edit metric metadata returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiUpdateMetricMetadataRequest={body:{perUnit:"second",type:"count",unit:"byte",},metricName:"metric_name",};apiInstance.updateMetricMetadata(params).then((data: v1.MetricMetadata)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Update the tag configuration of a metric or percentile aggregations of a distribution metric or custom aggregations
of a count, rate, or gauge metric. By setting exclude_tags_mode to true the behavior is changed
from an allow-list to a deny-list, and tags in the defined list will not be queryable.
Can only be used with application keys from users with the Manage Tags for Metrics permission. This endpoint requires
a tag configuration to be created first.
This endpoint requires the metric_tags_write permission.
Object for a single tag configuration to be edited.
attributes
object
Object containing the definition of a metric tag configuration to be updated.
aggregations
[object]
Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags property.
include_percentiles
boolean
Toggle to include/exclude percentiles for a distribution metric.
Defaults to false. Can only be applied to metrics that have a metric_type of distribution.
tags
[string]
A list of tag keys that will be queryable for your metric.
default:
id [required]
string
The metric name for this resource.
type [required]
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
Response object which includes a single metric’s tag configuration.
Expand All
Field
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags property.
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
// Update a tag configuration returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "metric_tag_configuration" in the systemMetricTagConfigurationDataID:=os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")body:=datadogV2.MetricTagConfigurationUpdateRequest{Data:datadogV2.MetricTagConfigurationUpdateData{Type:datadogV2.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,Id:MetricTagConfigurationDataID,Attributes:&datadogV2.MetricTagConfigurationUpdateAttributes{Tags:[]string{"app",},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.UpdateTagConfiguration(ctx,MetricTagConfigurationDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.UpdateTagConfiguration`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.UpdateTagConfiguration`:\n%s\n",responseContent)}
// Update a tag configuration returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricTagConfigurationResponse;importcom.datadog.api.client.v2.model.MetricTagConfigurationType;importcom.datadog.api.client.v2.model.MetricTagConfigurationUpdateAttributes;importcom.datadog.api.client.v2.model.MetricTagConfigurationUpdateData;importcom.datadog.api.client.v2.model.MetricTagConfigurationUpdateRequest;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the systemStringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");MetricTagConfigurationUpdateRequestbody=newMetricTagConfigurationUpdateRequest().data(newMetricTagConfigurationUpdateData().type(MetricTagConfigurationType.MANAGE_TAGS).id(METRIC_TAG_CONFIGURATION_DATA_ID).attributes(newMetricTagConfigurationUpdateAttributes().tags(Collections.singletonList("app"))));try{MetricTagConfigurationResponseresult=apiInstance.updateTagConfiguration(METRIC_TAG_CONFIGURATION_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#updateTagConfiguration");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update a tag configuration returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApifromdatadog_api_client.v2.model.metric_tag_configuration_typeimportMetricTagConfigurationTypefromdatadog_api_client.v2.model.metric_tag_configuration_update_attributesimport(MetricTagConfigurationUpdateAttributes,)fromdatadog_api_client.v2.model.metric_tag_configuration_update_dataimportMetricTagConfigurationUpdateDatafromdatadog_api_client.v2.model.metric_tag_configuration_update_requestimportMetricTagConfigurationUpdateRequest# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=environ["METRIC_TAG_CONFIGURATION_DATA_ID"]body=MetricTagConfigurationUpdateRequest(data=MetricTagConfigurationUpdateData(type=MetricTagConfigurationType.MANAGE_TAGS,id=METRIC_TAG_CONFIGURATION_DATA_ID,attributes=MetricTagConfigurationUpdateAttributes(tags=["app",],),),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.update_tag_configuration(metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,body=body)print(response)
# Update a tag configuration returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.new# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]body=DatadogAPIClient::V2::MetricTagConfigurationUpdateRequest.new({data:DatadogAPIClient::V2::MetricTagConfigurationUpdateData.new({type:DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS,id:METRIC_TAG_CONFIGURATION_DATA_ID,attributes:DatadogAPIClient::V2::MetricTagConfigurationUpdateAttributes.new({tags:["app",],}),}),})papi_instance.update_tag_configuration(METRIC_TAG_CONFIGURATION_DATA_ID,body)
// Update a tag configuration returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;usedatadog_api_client::datadogV2::model::MetricTagConfigurationType;usedatadog_api_client::datadogV2::model::MetricTagConfigurationUpdateAttributes;usedatadog_api_client::datadogV2::model::MetricTagConfigurationUpdateData;usedatadog_api_client::datadogV2::model::MetricTagConfigurationUpdateRequest;#[tokio::main]asyncfnmain(){// there is a valid "metric_tag_configuration" in the system
letmetric_tag_configuration_data_id=std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();letbody=MetricTagConfigurationUpdateRequest::new(MetricTagConfigurationUpdateData::new(metric_tag_configuration_data_id.clone(),MetricTagConfigurationType::MANAGE_TAGS,).attributes(MetricTagConfigurationUpdateAttributes::new().tags(vec!["app".to_string()])),);letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.update_tag_configuration(metric_tag_configuration_data_id.clone(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Update a tag configuration returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);// there is a valid "metric_tag_configuration" in the system
constMETRIC_TAG_CONFIGURATION_DATA_ID=process.env.METRIC_TAG_CONFIGURATION_DATA_IDasstring;constparams: v2.MetricsApiUpdateTagConfigurationRequest={body:{data:{type:"manage_tags",id: METRIC_TAG_CONFIGURATION_DATA_ID,attributes:{tags:["app"],},},},metricName: METRIC_TAG_CONFIGURATION_DATA_ID,};apiInstance.updateTagConfiguration(params).then((data: v2.MetricTagConfigurationResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Deletes a metric’s tag configuration. Can only be used with application
keys from users with the Manage Tags for Metrics permission.
Note: This operation is irreversible.
This endpoint requires the metric_tags_write permission.
"""
Delete a tag configuration returns "No Content" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)api_instance.delete_tag_configuration(metric_name="ExampleMetric",)
# Delete a tag configuration returns "No Content" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newapi_instance.delete_tag_configuration("ExampleMetric")
// Delete a tag configuration returns "No Content" responsepackagemainimport("context""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)r,err:=api.DeleteTagConfiguration(ctx,"ExampleMetric")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.DeleteTagConfiguration`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}}
// Delete a tag configuration returns "No Content" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);try{apiInstance.deleteTagConfiguration("ExampleMetric");}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#deleteTagConfiguration");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Delete a tag configuration returns "No Content" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.delete_tag_configuration("ExampleMetric".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Delete a tag configuration returns "No Content" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiDeleteTagConfigurationRequest={metricName:"ExampleMetric",};apiInstance.deleteTagConfiguration(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Search metrics returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiListMetricsRequest={q:"q",};apiInstance.listMetrics(params).then((data: v1.MetricSearchResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Get a list of actively reporting metrics for your organization. Pagination is optional using the page[cursor] and page[size] query parameters.
Query parameters use bracket notation (for example, filter[tags], filter[queried][window][seconds]). Pass them as standard URL query strings, URL-encoding the brackets if your client does not handle them. For example: GET /api/v2/metrics?filter[tags]=env:prod&window[seconds]=86400&page[size]=500.
This endpoint requires the metrics_read permission.
OAuth apps require the metrics_read authorization scope to access this endpoint.
Arguments
Query Strings
Name
Type
Description
filter[configured]
boolean
Only return custom metrics that have been configured with Metrics Without Limits.
filter[tags_configured]
string
Only return metrics that have the given tag key(s) in their Metrics Without Limits configuration (included or excluded).
filter[metric_type]
enum
Only return metrics of the given metric type. Allowed enum values: non_distribution, distribution
filter[include_percentiles]
boolean
Only return distribution metrics that have percentile aggregations enabled (true) or disabled (false).
filter[queried]
boolean
Only return metrics that have been queried (true) or not queried (false) in the look back window. Set the window with filter[queried][window][seconds]; if omitted, a default window is used.
filter[queried][window][seconds]
integer
This parameter has no effect unless filter[queried] is also set. Only return metrics that have been queried or not queried in the specified window. The default value is 2,592,000 seconds (30 days), the maximum value is 15,552,000 seconds (180 days), and the minimum value is 1 second. For example: filter[queried]=true&filter[queried][window][seconds]=604800.
filter[tags]
string
Only return metrics that were submitted with tags matching this expression. You can use AND, OR, IN, and wildcards. For example: filter[tags]=env IN (staging,test) AND service:web*.
filter[related_assets]
boolean
Only return metrics that are used in at least one dashboard, monitor, notebook, or SLO.
window[seconds]
integer
Only return metrics that have been actively reporting in the specified window. The default value is 3600 seconds (1 hour), the maximum value is 2,592,000 seconds (30 days), and the minimum value is 1 second.
page[size]
integer
Maximum number of results per page. Send page[size] on the first request to opt in to pagination. On each subsequent request, send page[cursor] set to the value of meta.pagination.next_cursor from the previous response. The default value is 10000, the maximum value is 10000, and the minimum value is 1.
page[cursor]
string
Cursor for pagination. Use page[size] to opt-in to pagination and get the first page; for subsequent pages, use the value from meta.pagination.next_cursor in the response. Pagination is complete when next_cursor is null.
Response object that includes metrics and metric tag configurations.
Expand All
Field
Type
Description
data
[ <oneOf>]
Array of metrics and metric tag configurations.
Option 1
object
Object for a single metric tag configuration.
id
string
The metric name for this resource.
type
enum
The metric resource type.
Allowed enum values: metrics
default: metrics
Option 2
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags property.
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
default: manage_tags
links
object
Pagination links. Only present if pagination query parameters were provided.
first
string
Link to the first page.
last
string
Link to the last page.
next
string
Link to the next page.
prev
string
Link to previous page.
self
string
Link to current page.
meta
object
Response metadata object.
pagination
object
Paging attributes. Only present if pagination query parameters were provided.
cursor
string
The cursor used to get the current results, if any.
limit
int32
Number of results returned
next_cursor
string
The cursor used to get the next results, if any.
type
enum
Type of metric pagination.
Allowed enum values: cursor_limit
"""
Get a list of metrics returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_tag_configurations()print(response)
# Get a list of metrics returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newpapi_instance.list_tag_configurations()
// Get a list of metrics returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListTagConfigurations(ctx,*datadogV2.NewListTagConfigurationsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListTagConfigurations`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListTagConfigurations`:\n%s\n",responseContent)}
// Get a list of metrics returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricsAndMetricTagConfigurationsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);try{MetricsAndMetricTagConfigurationsResponseresult=apiInstance.listTagConfigurations();System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listTagConfigurations");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get a list of metrics returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::ListTagConfigurationsOptionalParams;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_tag_configurations(ListTagConfigurationsOptionalParams::default()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Get a list of metrics returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);apiInstance.listTagConfigurations().then((data: v2.MetricsAndMetricTagConfigurationsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Response Object that includes your query and the list of metrics retrieved.
Expand All
Field
Type
Description
error
string
Message indicating the errors if status is not ok.
from_date
int64
Start of requested time window, milliseconds since Unix epoch.
group_by
[string]
List of tag keys on which to group.
message
string
Message indicating success if status is ok.
query
string
Query string
res_type
string
Type of response.
series
[object]
List of timeseries queried.
aggr
string
Aggregation type.
display_name
string
Display name of the metric.
end
int64
End of the time window, milliseconds since Unix epoch.
expression
string
Metric expression.
interval
int64
Number of milliseconds between data samples.
length
int64
Number of data samples.
metric
string
Metric name.
pointlist
[array]
List of points of the timeseries in milliseconds.
query_index
int64
The index of the series' query within the request.
scope
string
Metric scope, comma separated list of tags.
start
int64
Start of the time window, milliseconds since Unix epoch.
tag_set
[string]
Unique tags identifying this series.
unit
[object]
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.
family
string
Unit family, allows for conversion between units of the same family, for scaling.
name
string
Unit name
plural
string
Plural form of the unit name.
scale_factor
double
Factor for scaling between units of the same family.
short_name
string
Abbreviation of the unit.
status
string
Status of the query.
to_date
int64
End of requested time window, milliseconds since Unix epoch.
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 hourfrom=Time.now-3600to=Time.nowquery='system.cpu.idle{*}by{host}'dog.get_points(query,from,to)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.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";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiQueryMetricsRequest={from:Math.round(newDate(newDate().getTime()+-1*86400*1000).getTime()/1000),to: Math.round(newDate().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));
View indexed and ingested tags for a given metric name.
Results are filtered by the window[seconds] parameter, which defaults to 14400 (4 hours).
This endpoint requires the metrics_read permission.
OAuth apps require the metrics_read authorization scope to access this endpoint.
Arguments
Path Parameters
Name
Type
Description
metric_name [required]
string
The name of the metric.
Query Strings
Name
Type
Description
window[seconds]
integer
The number of seconds of look back (from now) to query for tag data.
Default value is 14400 (4 hours), minimum value is 14400 (4 hours).
filter[tags]
string
Filter results to tags from data points that have the specified tags.
For example, filter[tags]=env:staging,host:123 returns tags only from data points with both env:staging and host:123.
filter[match]
string
Filter returned tags to those matching a substring.
For example, filter[match]=env returns tags like env:prod, environment:staging, etc.
filter[include_tag_values]
boolean
Whether to include tag values in the response.
Defaults to true.
filter[allow_partial]
boolean
Whether to allow partial results.
Defaults to false.
"""
List tags by metric name returns "Success" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApi# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=environ["METRIC_TAG_CONFIGURATION_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_tags_by_metric_name(metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,)print(response)
# List tags by metric name returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.new# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]papi_instance.list_tags_by_metric_name(METRIC_TAG_CONFIGURATION_DATA_ID)
// List tags by metric name returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "metric_tag_configuration" in the systemMetricTagConfigurationDataID:=os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListTagsByMetricName(ctx,MetricTagConfigurationDataID,*datadogV2.NewListTagsByMetricNameOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListTagsByMetricName`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListTagsByMetricName`:\n%s\n",responseContent)}
// List tags by metric name returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricAllTagsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the systemStringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");try{MetricAllTagsResponseresult=apiInstance.listTagsByMetricName(METRIC_TAG_CONFIGURATION_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listTagsByMetricName");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// List tags by metric name returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::ListTagsByMetricNameOptionalParams;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){// there is a valid "metric_tag_configuration" in the system
letmetric_tag_configuration_data_id=std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_tags_by_metric_name(metric_tag_configuration_data_id.clone(),ListTagsByMetricNameOptionalParams::default(),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List tags by metric name returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);// there is a valid "metric_tag_configuration" in the system
constMETRIC_TAG_CONFIGURATION_DATA_ID=process.env.METRIC_TAG_CONFIGURATION_DATA_IDasstring;constparams: v2.MetricsApiListTagsByMetricNameRequest={metricName: METRIC_TAG_CONFIGURATION_DATA_ID,};apiInstance.listTagsByMetricName(params).then((data: v2.MetricAllTagsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
The metrics end-point allows you to post time-series data that can be graphed on Datadog’s dashboards.
The maximum payload size is 3.2 megabytes (3200000 bytes). Compressed payloads must have a decompressed size of less than 62 megabytes (62914560 bytes).
If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect:
64 bits for the timestamp
64 bits for the value
40 bytes for the metric names
50 bytes for the timeseries
The full payload is approximately 100 bytes. However, with the DogStatsD API,
compression is applied, which reduces the payload size.
If the type of the metric is rate or count, define the corresponding interval in seconds.
metric [required]
string
The name of the timeseries.
points [required]
[array]
Points relating to a metric. All points must be tuples with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
tags
[string]
A list of tags associated with the metric.
type
string
The type of the metric. Valid types are "",count, gauge, and rate.
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
fromdatadogimportinitialize,apiimporttimeoptions={'api_key':'<DATADOG_API_KEY>'## EU costumers need to define 'api_host' as below#'api_host': 'https://api.datadoghq.eu/'}initialize(**options)now=time.time()future_10s=now+10# Submit a single point with a timestamp of `now`api.Metric.send(metric='page.views',points=1000)# Submit a point with a timestamp (must be current)api.Metric.send(metric='my.pair',points=(now,15))# Submit multiple points.api.Metric.send(metric='my.series',points=[(now,15),(future_10s,16)])# Submit a point with a host and tags.api.Metric.send(metric='my.series',points=100,host="myhost.example.com",tags=["version:1"])# Submit multiple metricsapi.Metric.send([{'metric':'my.series','points':15},{'metric':'my1.series','points':16}])
require'rubygems'require'dogapi'api_key='<DATADOG_API_KEY>'dog=Dogapi::Client.new(api_key)# Submit one metric value.dog.emit_point('some.metric.name',50.0,:host=>"my_host.example.com")# Submit multiple metric valuespoints=[[Time.now,0],[Time.now+10,10.0],[Time.now+20,20.0]]dog.emit_points('some.metric.name',points,:tags=>["version:1"])# Emit differents metrics in a single request to be more efficientdog.batch_metricsdodog.emit_point('test.api.test_metric',10)dog.emit_point('test.api.this_other_metric',1)end
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"cargo run
/**
* Submit deflate metrics returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:"gauge",points:[[Math.round(newDate().getTime()/1000),1.1]],tags:["test:ExampleMetric"],},],},contentEncoding:"deflate",};apiInstance.submitMetrics(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Submit metrics returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:"gauge",points:[[Math.round(newDate().getTime()/1000),1.1]],tags:["test:ExampleMetric"],},],},};apiInstance.submitMetrics(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
The metrics end-point allows you to post time-series data that can be graphed on Datadog’s dashboards.
The maximum payload size is 500 kilobytes (512000 bytes). Compressed payloads must have a decompressed size of less than 5 megabytes (5242880 bytes).
If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect:
64 bits for the timestamp
64 bits for the value
20 bytes for the metric names
50 bytes for the timeseries
The full payload is approximately 100 bytes.
Host name is one of the resources in the Resources field.
If the type of the metric is rate or count, define the corresponding interval in seconds.
metadata
object
Metadata for the metric.
origin
object
Metric origin information.
metric_type
int32
The origin metric type code
product
int32
The origin product code
service
int32
The origin service code
metric [required]
string
The name of the timeseries.
points [required]
[object]
Points relating to a metric. All points must be objects with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
timestamp
int64
The timestamp should be in seconds and current.
Current is defined as not more than 10 minutes in the future or more than 1 hour in the past.
value
double
The numeric value format should be a 64bit float gauge-type value.
resources
[object]
A list of resources to associate with this metric.
name
string
The name of the resource.
type
string
The type of the resource.
source_type_name
string
The source type name.
tags
[string]
A list of tags associated with the metric.
type
enum
The type of metric. The available types are 0 (unspecified), 1 (count), 2 (rate), and 3 (gauge).
Allowed enum values: 0,1,2,3
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
// Submit metrics returns "Payload accepted" responsepackagemainimport("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/datadogV2")funcmain(){body:=datadogV2.MetricPayload{Series:[]datadogV2.MetricSeries{{Metric:"system.load.1",Type:datadogV2.METRICINTAKETYPE_UNSPECIFIED.Ptr(),Points:[]datadogV2.MetricPoint{{Timestamp:datadog.PtrInt64(time.Now().Unix()),Value:datadog.PtrFloat64(0.7),},},Resources:[]datadogV2.MetricResource{{Name:datadog.PtrString("dummyhost"),Type:datadog.PtrString("host"),},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.SubmitMetrics(ctx,body,*datadogV2.NewSubmitMetricsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.SubmitMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.SubmitMetrics`:\n%s\n",responseContent)}
// Submit metrics with compression returns "Payload accepted" responsepackagemainimport("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/datadogV2")funcmain(){body:=datadogV2.MetricPayload{Series:[]datadogV2.MetricSeries{{Metric:"system.load.1",Type:datadogV2.METRICINTAKETYPE_UNSPECIFIED.Ptr(),Points:[]datadogV2.MetricPoint{{Timestamp:datadog.PtrInt64(time.Now().Unix()),Value:datadog.PtrFloat64(0.7),},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.SubmitMetrics(ctx,body,*datadogV2.NewSubmitMetricsOptionalParameters().WithContentEncoding(datadogV2.METRICCONTENTENCODING_ZSTD1))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.SubmitMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.SubmitMetrics`:\n%s\n",responseContent)}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"cargo run
/**
* Submit metrics returns "Payload accepted" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:0,points:[{timestamp: Math.round(newDate().getTime()/1000),value: 0.7,},],resources:[{name:"dummyhost",type:"host",},],},],},};apiInstance.submitMetrics(params).then((data: v2.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Submit metrics with compression returns "Payload accepted" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiSubmitMetricsRequest={body:{series:[{metric:"system.load.1",type:0,points:[{timestamp: Math.round(newDate().getTime()/1000),value: 0.7,},],},],},contentEncoding:"zstd1",};apiInstance.submitMetrics(params).then((data: v2.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
List tags and aggregations that are actively queried on dashboards, notebooks, monitors, the Metrics Explorer, and using the API for a given metric name.
This endpoint requires the metrics_read permission.
Arguments
Path Parameters
Name
Type
Description
metric_name [required]
string
The name of the metric.
Query Strings
Name
Type
Description
window[seconds]
integer
The number of seconds of look back (from now).
Default value is 604,800 (1 week), minimum value is 7200 (2 hours), maximum value is 2,630,000 (1 month).
"""
List active tags and aggregations returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_active_metric_configurations(metric_name="static_test_metric_donotdelete",)print(response)
# List active tags and aggregations returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newpapi_instance.list_active_metric_configurations("static_test_metric_donotdelete")
// List active tags and aggregations returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListActiveMetricConfigurations(ctx,"static_test_metric_donotdelete",*datadogV2.NewListActiveMetricConfigurationsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListActiveMetricConfigurations`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListActiveMetricConfigurations`:\n%s\n",responseContent)}
// List active tags and aggregations returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricSuggestedTagsAndAggregationsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);try{MetricSuggestedTagsAndAggregationsResponseresult=apiInstance.listActiveMetricConfigurations("static_test_metric_donotdelete");System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listActiveMetricConfigurations");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// List active tags and aggregations returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::ListActiveMetricConfigurationsOptionalParams;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_active_metric_configurations("static_test_metric_donotdelete".to_string(),ListActiveMetricConfigurationsOptionalParams::default(),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* List active tags and aggregations returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiListActiveMetricConfigurationsRequest={metricName:"static_test_metric_donotdelete",};apiInstance.listActiveMetricConfigurations(params).then((data: v2.MetricSuggestedTagsAndAggregationsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
A list of distribution points series to submit to Datadog.
host
string
The name of the host that produced the distribution point metric.
metric [required]
string
The name of the distribution points metric.
points [required]
[array]
Points relating to the distribution point metric. All points must be tuples with timestamp and a list of values (cannot be a string). Timestamps should be in POSIX time in seconds.
tags
[string]
A list of tags associated with the distribution point metric.
type
enum
The type of the distribution point.
Allowed enum values: distribution
## default
#
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"cargo run
/**
* Submit deflate distribution points returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiSubmitDistributionPointsRequest={body:{series:[{metric:"system.load.1.dist",points:[[Math.round(newDate().getTime()/1000),[1.0,2.0]]],},],},contentEncoding:"deflate",};apiInstance.submitDistributionPoints(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Submit distribution points returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.MetricsApi(configuration);constparams: v1.MetricsApiSubmitDistributionPointsRequest={body:{series:[{metric:"system.load.1.dist",points:[[Math.round(newDate().getTime()/1000),[1.0,2.0]]],},],},};apiInstance.submitDistributionPoints(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
List distinct metric volumes by metric name returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_volumes_by_metric_name(metric_name="static_test_metric_donotdelete",)print(response)
# List distinct metric volumes by metric name returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newpapi_instance.list_volumes_by_metric_name("static_test_metric_donotdelete")
// List distinct metric volumes by metric name returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListVolumesByMetricName(ctx,"static_test_metric_donotdelete")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListVolumesByMetricName`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListVolumesByMetricName`:\n%s\n",responseContent)}
// List distinct metric volumes by metric name returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricVolumesResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);try{MetricVolumesResponseresult=apiInstance.listVolumesByMetricName("static_test_metric_donotdelete");System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listVolumesByMetricName");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// List distinct metric volumes by metric name returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_volumes_by_metric_name("static_test_metric_donotdelete".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* List distinct metric volumes by metric name returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiListVolumesByMetricNameRequest={metricName:"static_test_metric_donotdelete",};apiInstance.listVolumesByMetricName(params).then((data: v2.MetricVolumesResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Create and define a list of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics.
Metrics are selected by passing a metric name prefix. Use the Delete method of this API path to remove tag configurations.
Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app.
If multiple calls include the same metric, the last configuration applied (not by submit order) is used, do not
expect deterministic ordering of concurrent calls. The exclude_tags_mode value will set all metrics that match the prefix to
the same exclusion state, metric tag configurations do not support mixed inclusion and exclusion for tags on the same metric.
Can only be used with application keys of users with the Manage Tags for Metrics permission.
This endpoint requires the metric_tags_write permission.
Request object to bulk configure tags for metrics matching the given prefix.
attributes
object
Optional parameters for bulk creating metric tag configurations.
emails
[string]
A list of account emails to notify when the configuration is applied.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false.
include_actively_queried_tags_window
double
When provided, all tags that have been actively queried are
configured (and, therefore, remain queryable) for each metric that
matches the given prefix. Minimum value is 1 second, and maximum
value is 7,776,000 seconds (90 days).
override_existing_configurations
boolean
When set to true, the configuration overrides any existing
configurations for the given metric with the new set of tags in this
configuration request. If false, old configurations are kept and
are merged with the set of tags in this configuration request.
Defaults to true.
tags
[string]
A list of tag names to apply to the configuration.
id [required]
string
A text prefix to match against metric names.
type [required]
enum
The metric bulk configure tags resource.
Allowed enum values: metric_bulk_configure_tags
Wrapper for a single bulk tag configuration status response.
Expand All
Field
Type
Description
data
object
The status of a request to bulk configure metric tags.
It contains the fields from the original request for reference.
attributes
object
Optional attributes for the status of a bulk tag configuration request.
emails
[string]
A list of account emails to notify when the configuration is applied.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
status
string
The status of the request.
tags
[string]
A list of tag names to apply to the configuration.
id [required]
string
A text prefix to match against metric names.
type [required]
enum
The metric bulk configure tags resource.
Allowed enum values: metric_bulk_configure_tags
// Configure tags for multiple metrics returns "Accepted" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "user" in the systemUserDataAttributesEmail:=os.Getenv("USER_DATA_ATTRIBUTES_EMAIL")body:=datadogV2.MetricBulkTagConfigCreateRequest{Data:datadogV2.MetricBulkTagConfigCreate{Attributes:&datadogV2.MetricBulkTagConfigCreateAttributes{Emails:[]string{UserDataAttributesEmail,},Tags:[]string{"test","examplemetric",},},Id:"system.load.1",Type:datadogV2.METRICBULKCONFIGURETAGSTYPE_BULK_MANAGE_TAGS,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.CreateBulkTagsMetricsConfiguration(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.CreateBulkTagsMetricsConfiguration`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.CreateBulkTagsMetricsConfiguration`:\n%s\n",responseContent)}
// Configure tags for multiple metrics returns "Accepted" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricBulkConfigureTagsType;importcom.datadog.api.client.v2.model.MetricBulkTagConfigCreate;importcom.datadog.api.client.v2.model.MetricBulkTagConfigCreateAttributes;importcom.datadog.api.client.v2.model.MetricBulkTagConfigCreateRequest;importcom.datadog.api.client.v2.model.MetricBulkTagConfigResponse;importjava.util.Arrays;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "user" in the systemStringUSER_DATA_ATTRIBUTES_EMAIL=System.getenv("USER_DATA_ATTRIBUTES_EMAIL");MetricBulkTagConfigCreateRequestbody=newMetricBulkTagConfigCreateRequest().data(newMetricBulkTagConfigCreate().attributes(newMetricBulkTagConfigCreateAttributes().emails(Collections.singletonList(USER_DATA_ATTRIBUTES_EMAIL)).tags(Arrays.asList("test","examplemetric"))).id("system.load.1").type(MetricBulkConfigureTagsType.BULK_MANAGE_TAGS));try{MetricBulkTagConfigResponseresult=apiInstance.createBulkTagsMetricsConfiguration(body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#createBulkTagsMetricsConfiguration");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Configure tags for multiple metrics returns "Accepted" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApifromdatadog_api_client.v2.model.metric_bulk_configure_tags_typeimportMetricBulkConfigureTagsTypefromdatadog_api_client.v2.model.metric_bulk_tag_config_createimportMetricBulkTagConfigCreatefromdatadog_api_client.v2.model.metric_bulk_tag_config_create_attributesimportMetricBulkTagConfigCreateAttributesfromdatadog_api_client.v2.model.metric_bulk_tag_config_create_requestimportMetricBulkTagConfigCreateRequestfromdatadog_api_client.v2.model.metric_bulk_tag_config_email_listimportMetricBulkTagConfigEmailListfromdatadog_api_client.v2.model.metric_bulk_tag_config_tag_name_listimportMetricBulkTagConfigTagNameList# there is a valid "user" in the systemUSER_DATA_ATTRIBUTES_EMAIL=environ["USER_DATA_ATTRIBUTES_EMAIL"]body=MetricBulkTagConfigCreateRequest(data=MetricBulkTagConfigCreate(attributes=MetricBulkTagConfigCreateAttributes(emails=MetricBulkTagConfigEmailList([USER_DATA_ATTRIBUTES_EMAIL,]),tags=MetricBulkTagConfigTagNameList(["test","examplemetric",]),),id="system.load.1",type=MetricBulkConfigureTagsType.BULK_MANAGE_TAGS,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.create_bulk_tags_metrics_configuration(body=body)print(response)
# Configure tags for multiple metrics returns "Accepted" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.new# there is a valid "user" in the systemUSER_DATA_ATTRIBUTES_EMAIL=ENV["USER_DATA_ATTRIBUTES_EMAIL"]body=DatadogAPIClient::V2::MetricBulkTagConfigCreateRequest.new({data:DatadogAPIClient::V2::MetricBulkTagConfigCreate.new({attributes:DatadogAPIClient::V2::MetricBulkTagConfigCreateAttributes.new({emails:[USER_DATA_ATTRIBUTES_EMAIL,],tags:["test","examplemetric",],}),id:"system.load.1",type:DatadogAPIClient::V2::MetricBulkConfigureTagsType::BULK_MANAGE_TAGS,}),})papi_instance.create_bulk_tags_metrics_configuration(body)
// Configure tags for multiple metrics returns "Accepted" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;usedatadog_api_client::datadogV2::model::MetricBulkConfigureTagsType;usedatadog_api_client::datadogV2::model::MetricBulkTagConfigCreate;usedatadog_api_client::datadogV2::model::MetricBulkTagConfigCreateAttributes;usedatadog_api_client::datadogV2::model::MetricBulkTagConfigCreateRequest;#[tokio::main]asyncfnmain(){// there is a valid "user" in the system
letuser_data_attributes_email=std::env::var("USER_DATA_ATTRIBUTES_EMAIL").unwrap();letbody=MetricBulkTagConfigCreateRequest::new(MetricBulkTagConfigCreate::new("system.load.1".to_string(),MetricBulkConfigureTagsType::BULK_MANAGE_TAGS,).attributes(MetricBulkTagConfigCreateAttributes::new().emails(vec![user_data_attributes_email.clone()]).tags(vec!["test".to_string(),"examplemetric".to_string()]),),);letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.create_bulk_tags_metrics_configuration(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Configure tags for multiple metrics returns "Accepted" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);// there is a valid "user" in the system
constUSER_DATA_ATTRIBUTES_EMAIL=process.env.USER_DATA_ATTRIBUTES_EMAILasstring;constparams: v2.MetricsApiCreateBulkTagsMetricsConfigurationRequest={body:{data:{attributes:{emails:[USER_DATA_ATTRIBUTES_EMAIL],tags:["test","examplemetric"],},id:"system.load.1",type:"metric_bulk_configure_tags",},},};apiInstance.createBulkTagsMetricsConfiguration(params).then((data: v2.MetricBulkTagConfigResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Delete all custom lists of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics.
Metrics are selected by passing a metric name prefix.
Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app.
Can only be used with application keys of users with the Manage Tags for Metrics permission.
This endpoint requires the metric_tags_write permission.
Wrapper for a single bulk tag configuration status response.
Expand All
Field
Type
Description
data
object
The status of a request to bulk configure metric tags.
It contains the fields from the original request for reference.
attributes
object
Optional attributes for the status of a bulk tag configuration request.
emails
[string]
A list of account emails to notify when the configuration is applied.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
status
string
The status of the request.
tags
[string]
A list of tag names to apply to the configuration.
id [required]
string
A text prefix to match against metric names.
type [required]
enum
The metric bulk configure tags resource.
Allowed enum values: metric_bulk_configure_tags
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Delete tags for multiple metrics returns "Accepted" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiDeleteBulkTagsMetricsConfigurationRequest={body:{data:{attributes:{emails:["[email protected]","[email protected]"],},id:"kafka.lag",type:"metric_bulk_configure_tags",},},};apiInstance.deleteBulkTagsMetricsConfiguration(params).then((data: v2.MetricBulkTagConfigResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Response object that includes metric cardinality estimates.
Expand All
Field
Type
Description
data
object
Object for a metric cardinality estimate.
attributes
object
Object containing the definition of a metric estimate attribute.
estimate_type
enum
Estimate type based on the queried configuration. By default, count_or_gauge is returned. distribution is returned for distribution metrics without percentiles enabled. Lastly, percentile is returned if filter[pct]=true is queried with a distribution metric.
Allowed enum values: count_or_gauge,distribution,percentile
default: count_or_gauge
estimated_at
date-time
Timestamp when the cardinality estimate was requested.
estimated_output_series
int64
Estimated cardinality of the metric based on the queried configuration.
id
string
The metric name for this resource.
type
enum
The metric estimate resource type.
Allowed enum values: metric_cardinality_estimate
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Tag Configuration Cardinality Estimator returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiEstimateMetricsOutputSeriesRequest={metricName:"system.cpu.idle",filterGroups:"app,host",filterNumAggregations: 4,};apiInstance.estimateMetricsOutputSeries(params).then((data: v2.MetricEstimateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Related Assets to a Metric returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_metric_assets(metric_name="system.cpu.user",)print(response)
# Related Assets to a Metric returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newpapi_instance.list_metric_assets("system.cpu.user")
// Related Assets to a Metric returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListMetricAssets(ctx,"system.cpu.user")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListMetricAssets`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListMetricAssets`:\n%s\n",responseContent)}
// Related Assets to a Metric returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricAssetsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);try{MetricAssetsResponseresult=apiInstance.listMetricAssets("system.cpu.user");System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listMetricAssets");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Related Assets to a Metric returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_metric_assets("system.cpu.user".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Related Assets to a Metric returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiListMetricAssetsRequest={metricName:"system.cpu.user",};apiInstance.listMetricAssets(params).then((data: v2.MetricAssetsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get tag key cardinality details returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.get_metric_tag_cardinality_details(metric_name="metric_name",)print(response)
# Get tag key cardinality details returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.newpapi_instance.get_metric_tag_cardinality_details("metric_name")
// Get tag key cardinality details returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.GetMetricTagCardinalityDetails(ctx,"metric_name")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.GetMetricTagCardinalityDetails`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.GetMetricTagCardinalityDetails`:\n%s\n",responseContent)}
// Get tag key cardinality details returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.get_metric_tag_cardinality_details("metric_name".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get tag key cardinality details returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiGetMetricTagCardinalityDetailsRequest={metricName:"metric_name",};apiInstance.getMetricTagCardinalityDetails(params).then((data: v2.MetricTagCardinalitiesResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Query timeseries data across various data sources and
process the data by applying formulas and functions.
This endpoint requires the timeseries_query permission.
OAuth apps require the timeseries_query authorization scope to access this endpoint.
The object describing a timeseries formula request.
formulas
[object]
List of formulas to be calculated and returned as responses.
formula [required]
string
Formula string, referencing one or more queries with their name property.
limit
object
Message for specifying limits to the number of values returned by a query.
This limit is only for scalar queries and has no effect on timeseries queries.
count
int32
The number of results to which to limit.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
from [required]
int64
Start date (inclusive) of the query in milliseconds since the Unix epoch.
interval
int64
A time interval in milliseconds.
May be overridden by a larger interval if the query would result in
too many points for the specified timeframe.
Defaults to a reasonable interval for the given timeframe.
queries [required]
[ <oneOf>]
List of queries to be run and used as inputs to the formulas.
Option 1
object
A query against Datadog custom metrics or Cloud Cost data sources.
data_source [required]
enum
A data source that is powered by the Metrics platform.
Allowed enum values: metrics,cloud_cost
default: metrics
name
string
The variable name for use in formulas.
query [required]
string
A classic metrics query string.
Option 2
object
An individual timeseries query for logs, RUM, traces, CI pipelines, security signals, and other event-based data sources. Use this query type for any data source powered by the Events Platform. See the data_source field for the full list of supported sources.
compute [required]
object
The instructions for what to compute for this query.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,maxShow 1 more,avg
default: count
interval
int64
Interval for compute in milliseconds.
metric
string
The "measure" attribute on which to perform the computation.
data_source [required]
enum
A data source that is powered by the Events Platform.
Allowed enum values: logs,spans,network,rum,security_signals,profiles,audit,events,ci_tests,ci_pipelinesShow 4 more,incident_analytics,product_analytics,on_call_events,dora
default: logs
group_by
[object]
The list of facets on which to split results.
facet [required]
string
The facet by which to split groups.
limit
int32
The maximum buckets to return for this group by. Note: at most 10000 buckets are allowed.
If grouping by multiple facets, the product of limits must not exceed 10000.
default: 10
sort
object
The dimension by which to sort a query's results.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,maxShow 1 more,avg
default: count
metric
string
The metric's calculated value which should be used to define the sort order of a query's results.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
type
enum
The type of sort to use on the calculated value.
Allowed enum values: alphabetical,measure
indexes
[string]
The indexes in which to search.
name
string
The variable name for use in formulas.
search
object
Configuration of the search/filter for an events query.
query
string
The search/filter string for an events query.
Option 3
object
A query for APM resource statistics such as latency, error rate, and hit count, grouped by resource name.
data_source [required]
enum
A data source for APM resource statistics queries.
Allowed enum values: apm_resource_stats
Filter APM data by the second primary tag. primary_tag_name must also be specified.
resource_name [required]
string
The resource name to filter by.
service [required]
string
The service name to filter by.
stat [required]
enum
The APM dependency statistic to query.
Allowed enum values: avg_duration,avg_root_duration,avg_spans_per_trace,error_rate,pct_exec_time,pct_of_traces,total_traces_count
Option 6
object
A query for SLO status, error budget, and burn rate metrics.
additional_query_filters
string
Additional filters applied to the SLO query.
data_source [required]
enum
A data source for SLO queries.
Allowed enum values: slo
default: slo
group_mode
enum
How SLO results are grouped in the response.
Allowed enum values: overall,components
measure [required]
enum
The SLO measurement to retrieve.
Allowed enum values: good_events,bad_events,slo_status,error_budget_remaining,error_budget_remaining_history,error_budget_burndown,burn_rate,slo_status_history,good_minutes,bad_minutes
name
string
The variable name for use in formulas.
slo_id [required]
string
The unique identifier of the SLO to query.
slo_query_type
enum
The type of SLO definition being queried.
Allowed enum values: metric,time_slice,monitor
Option 7
object
A query for host-level process metrics such as CPU and memory usage.
data_source [required]
enum
A data source for process-level infrastructure metrics.
Allowed enum values: process
default: process
is_normalized_cpu
boolean
Whether CPU metrics should be normalized by core count.
limit
int64
Maximum number of results to return.
metric [required]
string
The process metric to query.
name [required]
string
The variable name for use in formulas.
sort
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
tag_filters
[string]
Tag filters to narrow down processes.
text_filter
string
A full-text search filter to match process names or commands.
Option 8
object
A query for container-level metrics such as CPU and memory usage.
data_source [required]
enum
A data source for container-level infrastructure metrics.
Allowed enum values: container
default: container
is_normalized_cpu
boolean
Whether CPU metrics should be normalized by core count.
limit
int64
Maximum number of results to return.
metric [required]
string
The container metric to query.
name [required]
string
The variable name for use in formulas.
sort
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
tag_filters
[string]
Tag filters to narrow down containers.
text_filter
string
A full-text search filter to match container names.
to [required]
int64
End date (exclusive) of the query in milliseconds since the Unix epoch.
type [required]
enum
The type of the resource. The value should always be timeseries_request.
Allowed enum values: timeseries_request
{"data":{"attributes":{"formulas":[{"formula":"a","limit":{"count":10,"order":"desc"}}],"from":1636625471000,"interval":5000,"queries":[{"data_source":"apm_dependency_stats","name":"a","env":"ci","service":"cassandra","stat":"avg_duration","operation_name":"cassandra.query","resource_name":"DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?","primary_tag_name":"datacenter","primary_tag_value":"edge-eu1.prod.dog"}],"to":1636629071000},"type":"timeseries_request"}}
A message containing one response to a timeseries query made with timeseries formula query request.
Expand All
Field
Type
Description
data
object
A message containing the response to a timeseries query.
attributes
object
The object describing a timeseries response.
series
[object]
Array of response series. The index here corresponds to the index in the formulas or queries array from the request.
group_tags
[string]
List of tags that apply to a single response value.
query_index
int32
The index of the query in the "formulas" array (or "queries" array if no "formulas" was specified).
unit
[object]
Detailed information about the 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.
family
string
Unit family, allows for conversion between units of the same family, for scaling.
name
string
Unit name
plural
string
Plural form of the unit name.
scale_factor
double
Factor for scaling between units of the same family.
short_name
string
Abbreviation of the unit.
times
[integer]
Array of times, 1-1 match with individual values arrays.
values
[array]
Array of value-arrays. The index here corresponds to the index in the formulas or queries array from the request.
type
enum
The type of the resource. The value should always be timeseries_response.
Allowed enum values: timeseries_response
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
Query scalar values (as seen on Query Value, Table, and Toplist widgets).
Multiple data sources are supported with the ability to
process the data using formulas and functions.
This endpoint requires the timeseries_query permission.
OAuth apps require the timeseries_query authorization scope to access this endpoint.
List of formulas to be calculated and returned as responses.
formula [required]
string
Formula string, referencing one or more queries with their name property.
limit
object
Message for specifying limits to the number of values returned by a query.
This limit is only for scalar queries and has no effect on timeseries queries.
count
int32
The number of results to which to limit.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
from [required]
int64
Start date (inclusive) of the query in milliseconds since the Unix epoch.
queries [required]
[ <oneOf>]
List of queries to be run and used as inputs to the formulas.
Option 1
object
A query against Datadog custom metrics or Cloud Cost data sources.
aggregator [required]
enum
The type of aggregation that can be performed on metrics-based queries.
Allowed enum values: avg,min,max,sum,last,percentile,mean,l2norm,area
default: avg
data_source [required]
enum
A data source that is powered by the Metrics platform.
Allowed enum values: metrics,cloud_cost
default: metrics
name
string
The variable name for use in formulas.
query [required]
string
A classic metrics query string.
Option 2
object
An individual scalar query for logs, RUM, traces, CI pipelines, security signals, and other event-based data sources. Use this query type for any data source powered by the Events Platform. See the data_source field for the full list of supported sources.
compute [required]
object
The instructions for what to compute for this query.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,maxShow 1 more,avg
default: count
interval
int64
Interval for compute in milliseconds.
metric
string
The "measure" attribute on which to perform the computation.
data_source [required]
enum
A data source that is powered by the Events Platform.
Allowed enum values: logs,spans,network,rum,security_signals,profiles,audit,events,ci_tests,ci_pipelinesShow 4 more,incident_analytics,product_analytics,on_call_events,dora
default: logs
group_by
[object]
The list of facets on which to split results.
facet [required]
string
The facet by which to split groups.
limit
int32
The maximum buckets to return for this group by. Note: at most 10000 buckets are allowed.
If grouping by multiple facets, the product of limits must not exceed 10000.
default: 10
sort
object
The dimension by which to sort a query's results.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,maxShow 1 more,avg
default: count
metric
string
The metric's calculated value which should be used to define the sort order of a query's results.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
type
enum
The type of sort to use on the calculated value.
Allowed enum values: alphabetical,measure
indexes
[string]
The indexes in which to search.
name
string
The variable name for use in formulas.
search
object
Configuration of the search/filter for an events query.
query
string
The search/filter string for an events query.
Option 3
object
A query for APM resource statistics such as latency, error rate, and hit count, grouped by resource name.
data_source [required]
enum
A data source for APM resource statistics queries.
Allowed enum values: apm_resource_stats
Filter APM data by the second primary tag. primary_tag_name must also be specified.
resource_name [required]
string
The resource name to filter by.
service [required]
string
The service name to filter by.
stat [required]
enum
The APM dependency statistic to query.
Allowed enum values: avg_duration,avg_root_duration,avg_spans_per_trace,error_rate,pct_exec_time,pct_of_traces,total_traces_count
Option 6
object
A query for SLO status, error budget, and burn rate metrics.
additional_query_filters
string
Additional filters applied to the SLO query.
data_source [required]
enum
A data source for SLO queries.
Allowed enum values: slo
default: slo
group_mode
enum
How SLO results are grouped in the response.
Allowed enum values: overall,components
measure [required]
enum
The SLO measurement to retrieve.
Allowed enum values: good_events,bad_events,slo_status,error_budget_remaining,error_budget_remaining_history,error_budget_burndown,burn_rate,slo_status_history,good_minutes,bad_minutes
name
string
The variable name for use in formulas.
slo_id [required]
string
The unique identifier of the SLO to query.
slo_query_type
enum
The type of SLO definition being queried.
Allowed enum values: metric,time_slice,monitor
Option 7
object
A query for host-level process metrics such as CPU and memory usage.
aggregator
enum
The type of aggregation that can be performed on metrics-based queries.
Allowed enum values: avg,min,max,sum,last,percentile,mean,l2norm,area
default: avg
data_source [required]
enum
A data source for process-level infrastructure metrics.
Allowed enum values: process
default: process
is_normalized_cpu
boolean
Whether CPU metrics should be normalized by core count.
limit
int64
Maximum number of results to return.
metric [required]
string
The process metric to query.
name [required]
string
The variable name for use in formulas.
sort
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
tag_filters
[string]
Tag filters to narrow down processes.
text_filter
string
A full-text search filter to match process names or commands.
Option 8
object
A query for container-level metrics such as CPU and memory usage.
aggregator
enum
The type of aggregation that can be performed on metrics-based queries.
Allowed enum values: avg,min,max,sum,last,percentile,mean,l2norm,area
default: avg
data_source [required]
enum
A data source for container-level infrastructure metrics.
Allowed enum values: container
default: container
is_normalized_cpu
boolean
Whether CPU metrics should be normalized by core count.
limit
int64
Maximum number of results to return.
metric [required]
string
The container metric to query.
name [required]
string
The variable name for use in formulas.
sort
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
tag_filters
[string]
Tag filters to narrow down containers.
text_filter
string
A full-text search filter to match container names.
to [required]
int64
End date (exclusive) of the query in milliseconds since the Unix epoch.
type [required]
enum
The type of the resource. The value should always be scalar_request.
Allowed enum values: scalar_request
{"data":{"attributes":{"formulas":[{"formula":"a","limit":{"count":10,"order":"desc"}}],"from":1636625471000,"queries":[{"data_source":"apm_dependency_stats","name":"a","env":"ci","service":"cassandra","stat":"avg_duration","operation_name":"cassandra.query","resource_name":"DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?","primary_tag_name":"datacenter","primary_tag_value":"edge-eu1.prod.dog"}],"to":1636629071000},"type":"scalar_request"}}
A message containing one or more responses to scalar queries.
Expand All
Field
Type
Description
data
object
A message containing the response to a scalar query.
attributes
object
The object describing a scalar response.
columns
[ <oneOf>]
List of response columns, each corresponding to an individual formula or query in the request and with values in parallel arrays matching the series list.
Option 1
object
A column containing the tag keys and values in a group.
name
string
The name of the tag key or group.
type
enum
The type of column present for groups.
Allowed enum values: group
default: group
values
[array]
The array of tag values for each group found for the results of the formulas or queries.
Option 2
object
A column containing the numerical results for a formula or query.
meta
object
Metadata for the resulting numerical values.
unit
[object]
Detailed information about the unit.
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.
family
string
Unit family, allows for conversion between units of the same family, for scaling.
name
string
Unit name
plural
string
Plural form of the unit name.
scale_factor
double
Factor for scaling between units of the same family.
short_name
string
Abbreviation of the unit.
name
string
The name referencing the formula or query for this column.
type
enum
The type of column present for numbers.
Allowed enum values: number
default: number
values
[number]
The array of numerical values for one formula or query.
type
enum
The type of the resource. The value should always be scalar_response.
Allowed enum values: scalar_response
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Scalar cross product query returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiQueryScalarDataRequest={body:{data:{attributes:{formulas:[{formula:"a",limit:{count: 10,order:"desc",},},],from:1636625471000,queries:[{aggregator:"avg",dataSource:"metrics",query:"avg:system.cpu.user{*}",name:"a",},],to: 1636629071000,},type:"scalar_request",},},};apiInstance.queryScalarData(params).then((data: v2.ScalarFormulaQueryResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));