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. 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 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]
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 non_distribution 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
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
フィールド
種類
説明
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 non_distribution 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.
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" 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:"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.comddog-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" 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" 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.comddog-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));
Note: This endpoint is GA for Metrics, Real User Monitoring (RUM), Cloud Cost Management, and Log Management data sources.
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 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
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
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 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
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,rum
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,max,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.
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
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
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
## 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.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables exportNOW="$(date +%s)" # Curl command curl-XPOST"https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/distribution_points" \
-H"Accept: application/json" \
-H"Content-Type: text/json" \
-H"DD-API-KEY: ${DD_API_KEY}" \
-d@-<<EOF{
"series": [
{
"metric": "system.load.1.dist",
"points": [[${NOW}, [1234.5]]]
}
]
}
EOF
// Submit deflate distribution points returns "Payload accepted" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){body:=datadogV1.DistributionPointsPayload{Series:[]datadogV1.DistributionPointsSeries{{Metric:"system.load.1.dist",Points:[][]datadogV1.DistributionPointItem{{{DistributionPointTimestamp:datadog.PtrFloat64(float64(time.Now().Unix()))},{DistributionPointData:&[]float64{1.0,2.0,}},},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewMetricsApi(apiClient)resp,r,err:=api.SubmitDistributionPoints(ctx,body,*datadogV1.NewSubmitDistributionPointsOptionalParameters().WithContentEncoding(datadogV1.DISTRIBUTIONPOINTSCONTENTENCODING_DEFLATE))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.SubmitDistributionPoints`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.SubmitDistributionPoints`:\n%s\n",responseContent)}
// Submit distribution points returns "Payload accepted" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){body:=datadogV1.DistributionPointsPayload{Series:[]datadogV1.DistributionPointsSeries{{Metric:"system.load.1.dist",Points:[][]datadogV1.DistributionPointItem{{{DistributionPointTimestamp:datadog.PtrFloat64(float64(time.Now().Unix()))},{DistributionPointData:&[]float64{1.0,2.0,}},},},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewMetricsApi(apiClient)resp,r,err:=api.SubmitDistributionPoints(ctx,body,*datadogV1.NewSubmitDistributionPointsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.SubmitDistributionPoints`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.SubmitDistributionPoints`:\n%s\n",responseContent)}
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.
## 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.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables exportNOW="$(date +%s)" # Curl command curl-XPOST"https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/series" \
-H"Accept: application/json" \
-H"Content-Type: text/json" \
-H"DD-API-KEY: ${DD_API_KEY}" \
-d@-<<EOF{
"series": [
{
"metric": "system.load.1",
"points": [[${NOW}, 1234.5]]
}
]
}
EOF
// Submit deflate metrics returns "Payload accepted" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){body:=datadogV1.MetricsPayload{Series:[]datadogV1.Series{{Metric:"system.load.1",Type:datadog.PtrString("gauge"),Points:[][]*float64{{datadog.PtrFloat64(float64(time.Now().Unix())),datadog.PtrFloat64(1.1),},},Tags:[]string{"test:ExampleMetric",},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewMetricsApi(apiClient)resp,r,err:=api.SubmitMetrics(ctx,body,*datadogV1.NewSubmitMetricsOptionalParameters().WithContentEncoding(datadogV1.METRICCONTENTENCODING_DEFLATE))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 returns "Payload accepted" response
packagemainimport("context""encoding/json""fmt""os""time""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){body:=datadogV1.MetricsPayload{Series:[]datadogV1.Series{{Metric:"system.load.1",Type:datadog.PtrString("gauge"),Points:[][]*float64{{datadog.PtrFloat64(float64(time.Now().Unix())),datadog.PtrFloat64(1.1),},},Tags:[]string{"test:ExampleMetric",},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewMetricsApi(apiClient)resp,r,err:=api.SubmitMetrics(ctx,body,*datadogV1.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)}
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 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
## 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" response
packagemainimport("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" response
packagemainimport("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)}
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.comddog-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
フィールド
種類
説明
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 non_distribution 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.
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" 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" 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.comddog-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));
Note: This endpoint is GA for Metrics, Real User Monitoring (RUM), Cloud Cost Management, and Log Management data sources.
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 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
An individual scalar metrics query.
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 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
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,rum
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,max,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.
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
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
[ <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.comddog-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();configuration.unstableOperations["v2.queryScalarData"]=true;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));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-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]
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 non_distribution 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
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
フィールド
種類
説明
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 non_distribution 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.
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" 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")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.comddog-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.
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" response
packagemainimport("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.comddog-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.comddog-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));
Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
This endpoint requires the metrics_read permission.
OAuth apps require the metrics_read authorization scope to access this endpoint.
引数
クエリ文字列
名前
種類
説明
filter[configured]
boolean
Filter custom metrics that have configured tags.
filter[tags_configured]
string
Filter tag configurations by configured tags.
filter[metric_type]
enum
Filter metrics by metric type. Allowed enum values: non_distribution, distribution
filter[include_percentiles]
boolean
Filter distributions with additional percentile
aggregations enabled or disabled.
filter[queried]
boolean
(Beta) Filter custom metrics that have or have not been queried in the specified window[seconds].
If no window is provided or the window is less than 2 hours, a default of 2 hours will be applied.
filter[tags]
string
Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions.
Can only be combined with the filter[queried] filter.
window[seconds]
integer
The number of seconds of look back (from now) to apply to a filter[tag] or filter[queried] query.
Default value is 3600 (1 hour), maximum value is 2,592,000 (30 days).
Response object that includes metrics and metric tag configurations.
Expand All
フィールド
種類
説明
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]
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 non_distribution 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.
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
"""
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" 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(){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.comddog-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
フィールド
種類
説明
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.comddog-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));
"""
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" 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.ListTagsByMetricName(ctx,MetricTagConfigurationDataID)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::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()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-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));
List tags and aggregations that are actively queried on dashboards, notebooks, monitors, and the Metrics Explorer for a given metric name.
This endpoint requires the metrics_read permission.
引数
パスパラメーター
名前
種類
説明
metric_name [required]
string
The name of the metric.
クエリ文字列
名前
種類
説明
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" 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(){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.comddog-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));
"""
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" 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(){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.comddog-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.
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
フィールド
種類
説明
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" 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 "user" in the system
UserDataAttributesEmail:=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.comddog-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
フィールド
種類
説明
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.comddog-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:["sue@example.com","bob@example.com"],},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
フィールド
種類
説明
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.comddog-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" 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(){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.comddog-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));