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 or configure custom aggregations
on any count, rate, or gauge metric.
Can only be used with application keys of users with the Manage Tags for Metrics 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]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
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
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
tags [required]
[string]
A list of tag keys that will be queryable for your metric.
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
フィールド
種類
説明
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
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.
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
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" response
packagemainimport("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:"ExampleCreateatagconfigurationreturnsCreatedresponse",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,"ExampleCreateatagconfigurationreturnsCreatedresponse",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="ExampleCreateatagconfigurationreturnsCreatedresponse",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="ExampleCreateatagconfigurationreturnsCreatedresponse",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:"ExampleCreateatagconfigurationreturnsCreatedresponse",attributes:DatadogAPIClient::V2::MetricTagConfigurationCreateAttributes.new({tags:["app","datacenter",],metric_type:DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE,}),}),})papi_instance.create_tag_configuration("ExampleCreateatagconfigurationreturnsCreatedresponse",body)
/**
* 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:"ExampleCreateatagconfigurationreturnsCreatedresponse",attributes:{tags:["app","datacenter"],metricType:"gauge",},},},metricName:"ExampleCreateatagconfigurationreturnsCreatedresponse",};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" response
packagemainimport("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" response
importcom.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
*/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));
Note: This endpoint is GA for the metrics, real user monitoring (RUM) and cloud cost data sources.
Support for logs is in beta. We are gradually onboarding support for more sources. If you have any
feedback, contact Datadog support.
Query timeseries data across various data sources and
process the data by applying formulas and functions.
This endpoint requires the timeseries_query authorization scope.
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.
count
int32
The number of results to which to limit.
order
enum
Direction of sort.
Allowed enum values: asc,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]
[object <oneOf>]
List of queries to be run and used as inputs to the formulas.
Option 1
object
An individual timeseries metrics query.
data_source [required]
enum
A data source that is powered by the Metrics platform.
Allowed enum values: metrics,cloud_cost
name
string
The variable name for use in formulas.
query [required]
string
A classic metrics query string.
Option 2
object
An individual timeseries events query.
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,max,avg
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,rum
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 number of groups to return.
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,max,avg
metric
string
Metric whose calculated value should be used to define the sort order of a query's results.
order
enum
Direction of sort.
Allowed enum values: asc,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.
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
A message containing one response to a timeseries query made with timeseries formula query request.
Expand All
フィールド
種類
説明
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
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
If the type of the metric is rate or count, define the corresponding interval.
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.
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
If the type of the metric is rate or count, define the corresponding interval.
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
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')
Response object which includes a single metric’s tag configuration.
Expand All
フィールド
種類
説明
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
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.
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
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" response
packagemainimport("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 system
MetricTagConfigurationDataID:=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" response
importcom.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 system
StringMETRIC_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
*/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));
Note: This endpoint is GA for the metrics, real user monitoring (RUM) and cloud cost data sources.
Support for logs is in beta. We are gradually onboarding support for more sources. If you have any
feedback, contact Datadog support.
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 authorization scope.
A message containing one or more responses to scalar queries.
Expand All
フィールド
種類
説明
data
object
A message containing the response to a scalar query.
attributes
object
The object describing a scalar response.
columns
[object <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
string
The type of column present.
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
string
The type of column present.
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