D’envoyer des données de métriques afin de les représenter graphiquement sur les dashboards de Datadog
D’interroger vos métriques sur l’intervalle de votre choix
De modifier les configurations de tags pour les métriques
De visualiser les tags et les volumes pour les métriques
Remarque : un graphique ne peut contenir qu’un nombre défini de points. Lorsque l’intervalle d’affichage d’une métrique augmente, les points sont agrégés afin de ne pas dépasser ce nombre.
Les méthodes Post, Patch et Delete de l’API manage_tags peuvent uniquement être utilisées par un utilisateur qui dispose de l’autorisation Manage Tags for Metrics.
Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers.
If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.
Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric.
Optionally, include percentile aggregations on any distribution metric or configure custom aggregations
on any count, rate, or gauge metric.
Can only be used with application keys of users with the Manage Tags for Metrics permission.
Object for a single metric to be configure tags on.
attributes
object
Object containing the definition of a metric tag configuration to be created.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
include_percentiles
boolean
Toggle to include/exclude percentiles for a distribution metric.
Defaults to false. Can only be applied to metrics that have a metric_type of distribution.
metric_type [required]
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
tags [required]
[string]
A list of tag keys that will be queryable for your metric.
id [required]
string
The metric name for this resource.
type [required]
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
Response object which includes a single metric’s tag configuration.
Expand All
Champ
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
include_percentiles
boolean
Toggle to turn on/off percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
"""
Create a tag configuration returns "Created" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApifromdatadog_api_client.v2.model.metric_tag_configuration_create_attributesimport(MetricTagConfigurationCreateAttributes,)fromdatadog_api_client.v2.model.metric_tag_configuration_create_dataimportMetricTagConfigurationCreateDatafromdatadog_api_client.v2.model.metric_tag_configuration_create_requestimportMetricTagConfigurationCreateRequestfromdatadog_api_client.v2.model.metric_tag_configuration_metric_typesimportMetricTagConfigurationMetricTypesfromdatadog_api_client.v2.model.metric_tag_configuration_typeimportMetricTagConfigurationTypebody=MetricTagConfigurationCreateRequest(data=MetricTagConfigurationCreateData(type=MetricTagConfigurationType("manage_tags"),id="ExampleCreateatagconfigurationreturnsCreatedresponse",attributes=MetricTagConfigurationCreateAttributes(tags=["app","datacenter",],metric_type=MetricTagConfigurationMetricTypes("gauge"),),),)configuration=Configuration()configuration.unstable_operations["create_tag_configuration"]=TruewithApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.create_tag_configuration(metric_name="ExampleCreateatagconfigurationreturnsCreatedresponse",body=body)print(response)
# Create a tag configuration returns "Created" responserequire"datadog_api_client"DatadogAPIClient::V2.configuredo|config|config.unstable_operations[:create_tag_configuration]=trueendapi_instance=DatadogAPIClient::V2::MetricsAPI.newbody=DatadogAPIClient::V2::MetricTagConfigurationCreateRequest.new({data:DatadogAPIClient::V2::MetricTagConfigurationCreateData.new({type:DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS,id:"ExampleCreateatagconfigurationreturnsCreatedresponse",attributes:DatadogAPIClient::V2::MetricTagConfigurationCreateAttributes.new({tags:["app","datacenter",],metric_type:DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE,}),}),})papi_instance.create_tag_configuration("ExampleCreateatagconfigurationreturnsCreatedresponse",body)
/**
* Create a tag configuration returns "Created" response
*/import{v2}from"@datadog/datadog-api-client";constconfiguration=v2.createConfiguration();configuration.unstableOperations["createTagConfiguration"]=true;constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiCreateTagConfigurationRequest={body:{data:{type:"manage_tags",id:"ExampleCreateatagconfigurationreturnsCreatedresponse",attributes:{tags:["app","datacenter"],metricType:"gauge",},},},metricName:"ExampleCreateatagconfigurationreturnsCreatedresponse",};apiInstance.createTagConfiguration(params).then((data: v2.MetricTagConfigurationResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Create a tag configuration returns "Created" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v2/datadog")funcmain(){body:=datadog.MetricTagConfigurationCreateRequest{Data:datadog.MetricTagConfigurationCreateData{Type:datadog.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,Id:"ExampleCreateatagconfigurationreturnsCreatedresponse",Attributes:&datadog.MetricTagConfigurationCreateAttributes{Tags:[]string{"app","datacenter",},MetricType:datadog.METRICTAGCONFIGURATIONMETRICTYPES_GAUGE,},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("CreateTagConfiguration",true)apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.MetricsApi.CreateTagConfiguration(ctx,"ExampleCreateatagconfigurationreturnsCreatedresponse",body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.CreateTagConfiguration`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.CreateTagConfiguration`:\n%s\n",responseContent)}
L’endpoint de métriques vous permet d’envoyer des données de série temporelle afin de les représenter graphiquement dans les dashboards de Datadog.
La limite de taille des charges utiles compressées est de 3,2 Mo (3 200 000 octets), tandis que celle des charges utiles non compressées est de 62 Mo (62 914 560 octets).
Si vous envoyez directement des métriques à l’API Datadog sans passer par DogStatsD, vous pouvez compter :
64 bits pour le timestamp
32 bits pour la valeur
20 octets pour les noms de métriques
50 octets pour la série temporelle
La charge utile totale fait environ 100 octets. Cependant, avec l’API DogStatsD, cette charge est compressée afin de réduire son poids.
If the type of the metric is rate or count, define the corresponding interval.
metric [required]
string
The name of the timeseries.
points [required]
[array]
Points relating to a metric. All points must be tuples with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
tags
[string]
A list of tags associated with the metric.
type
string
The type of the metric. Valid types are "",count, gauge, and rate.
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
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}])
L’endpoint de métriques vous permet d’envoyer des données de série temporelle afin de les représenter graphiquement dans les dashboards de Datadog.
La limite de taille des charges utiles compressées est de 3,2 Mo (3 200 000 octets), tandis que celle des charges utiles non compressées est de 62 Mo (62 914 560 octets).
Si vous envoyez directement des métriques à l’API Datadog sans passer par DogStatsD, vous pouvez compter :
64 bits pour le timestamp
32 bits pour la valeur
20 octets pour les noms de métriques
50 octets pour la série temporelle
La charge utile totale fait environ 100 octets. Cependant, avec l’API DogStatsD, cette charge est compressée afin de réduire son poids.
If the type of the metric is rate or count, define the corresponding interval.
metadata
object
Metadata for the metric.
origin
object
Metric origin information.
metric_type
int32
The origin metric type code
product
int32
The origin product code
service
int32
The origin service code
metric [required]
string
The name of the timeseries.
points [required]
[object]
Points relating to a metric. All points must be objects with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
timestamp
int64
The timestamp should be in seconds and current.
Current is defined as not more than 10 minutes in the future or more than 1 hour in the past.
value
double
The numeric value format should be a 64bit float gauge-type value.
resources
[object]
A list of resources to associate with this metric.
name
string
The name of the metric.
type
string
The type of metric.
source_type_name
string
The source type name.
tags
[string]
A list of tags associated with the metric.
type
enum
The type of metric.
Allowed enum values: 0,1,2,3,15
"""
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
*/import{v1}from"@datadog/datadog-api-client";constconfiguration=v1.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));
// Get active metrics list returns "OK" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v1/datadog")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.MetricsApi.ListActiveMetrics(ctx,9223372036854775807,*datadog.NewListActiveMetricsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListActiveMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListActiveMetrics`:\n%s\n",responseContent)}
// Get active metrics list returns "OK" response
importcom.datadog.api.v1.client.ApiClient;importcom.datadog.api.v1.client.ApiException;importcom.datadog.api.v1.client.Configuration;importcom.datadog.api.v1.client.api.MetricsApi;importcom.datadog.api.v1.client.model.MetricsListResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.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)
Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers.
If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.
Response object which includes a single metric’s tag configuration.
Expand All
Champ
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
include_percentiles
boolean
Toggle to turn on/off percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
"""
List tag configuration by name returns "Success" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApi# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=environ["METRIC_TAG_CONFIGURATION_DATA_ID"]configuration=Configuration()configuration.unstable_operations["list_tag_configuration_by_name"]=TruewithApiClient(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"DatadogAPIClient::V2.configuredo|config|config.unstable_operations[:list_tag_configuration_by_name]=trueendapi_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
*/import{v2}from"@datadog/datadog-api-client";constconfiguration=v2.createConfiguration();configuration.unstableOperations["listTagConfigurationByName"]=true;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));
// List tag configuration by name returns "Success" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v2/datadog")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()configuration.SetUnstableOperationEnabled("ListTagConfigurationByName",true)apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.MetricsApi.ListTagConfigurationByName(ctx,MetricTagConfigurationDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListTagConfigurationByName`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListTagConfigurationByName`:\n%s\n",responseContent)}
// List tag configuration by name returns "Success" response
importcom.datadog.api.v2.client.ApiClient;importcom.datadog.api.v2.client.ApiException;importcom.datadog.api.v2.client.Configuration;importcom.datadog.api.v2.client.api.MetricsApi;importcom.datadog.api.v2.client.model.MetricTagConfigurationResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("listTagConfigurationByName",true);MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the system
StringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");try{MetricTagConfigurationResponseresult=apiInstance.listTagConfigurationByName(METRIC_TAG_CONFIGURATION_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listTagConfigurationByName");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
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')
Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers.
If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.
Update the tag configuration of a metric or percentile aggregations of a distribution metric or custom aggregations
of a count, rate, or gauge metric.
Can only be used with application keys from users with the Manage Tags for Metrics 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 metrics that have a metric_type of count, rate, or gauge.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
include_percentiles
boolean
Toggle to include/exclude percentiles for a distribution metric.
Defaults to false. Can only be applied to metrics that have a metric_type of distribution.
tags
[string]
A list of tag keys that will be queryable for your metric.
id [required]
string
The metric name for this resource.
type [required]
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
Response object which includes a single metric’s tag configuration.
Expand All
Champ
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric.
By default, count and rate metrics require the (time: sum, space: sum) aggregation and
Gauge metrics require the (time: avg, space: avg) aggregation.
Additional time & space combinations are also available:
time: avg, space: avg
time: avg, space: max
time: avg, space: min
time: avg, space: sum
time: count, space: sum
time: max, space: max
time: min, space: min
time: sum, space: avg
time: sum, space: sum
Can only be applied to metrics that have a metric_type of count, rate, or gauge.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
include_percentiles
boolean
Toggle to turn on/off percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
"""
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()configuration.unstable_operations["update_tag_configuration"]=TruewithApiClient(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"DatadogAPIClient::V2.configuredo|config|config.unstable_operations[:update_tag_configuration]=trueendapi_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
*/import{v2}from"@datadog/datadog-api-client";constconfiguration=v2.createConfiguration();configuration.unstableOperations["updateTagConfiguration"]=true;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));
// Update a tag configuration returns "OK" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v2/datadog")funcmain(){// there is a valid "metric_tag_configuration" in the system
MetricTagConfigurationDataID:=os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")body:=datadog.MetricTagConfigurationUpdateRequest{Data:datadog.MetricTagConfigurationUpdateData{Type:datadog.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,Id:MetricTagConfigurationDataID,Attributes:&datadog.MetricTagConfigurationUpdateAttributes{Tags:[]string{"app",},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("UpdateTagConfiguration",true)apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.MetricsApi.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" response
importcom.datadog.api.v2.client.ApiClient;importcom.datadog.api.v2.client.ApiException;importcom.datadog.api.v2.client.Configuration;importcom.datadog.api.v2.client.api.MetricsApi;importcom.datadog.api.v2.client.model.MetricTagConfigurationResponse;importcom.datadog.api.v2.client.model.MetricTagConfigurationType;importcom.datadog.api.v2.client.model.MetricTagConfigurationUpdateAttributes;importcom.datadog.api.v2.client.model.MetricTagConfigurationUpdateData;importcom.datadog.api.v2.client.model.MetricTagConfigurationUpdateRequest;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("updateTagConfiguration",true);MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the system
StringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");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();}}}
Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers.
If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.
"""
Delete a tag configuration returns "No Content" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()configuration.unstable_operations["delete_tag_configuration"]=TruewithApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)api_instance.delete_tag_configuration(metric_name="ExampleDeleteatagconfigurationreturnsNoContentresponse",)
# Delete a tag configuration returns "No Content" responserequire"datadog_api_client"DatadogAPIClient::V2.configuredo|config|config.unstable_operations[:delete_tag_configuration]=trueendapi_instance=DatadogAPIClient::V2::MetricsAPI.newapi_instance.delete_tag_configuration("ExampleDeleteatagconfigurationreturnsNoContentresponse")
/**
* Delete a tag configuration returns "No Content" response
*/import{v2}from"@datadog/datadog-api-client";constconfiguration=v2.createConfiguration();configuration.unstableOperations["deleteTagConfiguration"]=true;constapiInstance=newv2.MetricsApi(configuration);constparams: v2.MetricsApiDeleteTagConfigurationRequest={metricName:"ExampleDeleteatagconfigurationreturnsNoContentresponse",};apiInstance.deleteTagConfiguration(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Delete a tag configuration returns "No Content" response
packagemainimport("context""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v2/datadog")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("DeleteTagConfiguration",true)apiClient:=datadog.NewAPIClient(configuration)r,err:=apiClient.MetricsApi.DeleteTagConfiguration(ctx,"ExampleDeleteatagconfigurationreturnsNoContentresponse")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" response
importcom.datadog.api.v2.client.ApiClient;importcom.datadog.api.v2.client.ApiException;importcom.datadog.api.v2.client.Configuration;importcom.datadog.api.v2.client.api.MetricsApi;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("deleteTagConfiguration",true);MetricsApiapiInstance=newMetricsApi(defaultClient);try{apiInstance.deleteTagConfiguration("ExampleDeleteatagconfigurationreturnsNoContentresponse");}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();}}}
Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers.
If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.
Returns all configured count/gauge/rate/distribution metric names
(with additional filters if specified).
This endpoint requires the metrics_read authorization scope.
Arguments
Chaînes de requête
Nom
Type
Description
filter[configured]
boolean
Filter metrics that have configured tags.
filter[tags_configured]
string
Filter tag configurations by configured tags.
filter[metric_type]
enum
Filter tag configurations by metric type. Allowed enum values: gauge, count, rate, distribution
filter[include_percentiles]
boolean
Filter distributions with additional percentile
aggregations enabled or disabled.
filter[tags]
string
Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions.
Cannot be combined with other filters.
window[seconds]
integer
The number of seconds of look back (from now) to apply to a filter[tag] query.
Defaults value is 3600 (1 hour), maximum value is 172,800 (2 days).
Response object that includes metrics and metric tag configurations.
Expand All
Champ
Type
Description
data
[object <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
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 metrics that have a metric_type of count, rate, or gauge.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
include_percentiles
boolean
Toggle to turn on/off percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
modified_at
date-time
Timestamp when the tag configuration was last modified.
tags
[string]
List of tag keys on which to group.
id
string
The metric name for this resource.
type
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
"""
List tag configurations returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()configuration.unstable_operations["list_tag_configurations"]=TruewithApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_tag_configurations()print(response)
# List tag configurations returns "Success" responserequire"datadog_api_client"DatadogAPIClient::V2.configuredo|config|config.unstable_operations[:list_tag_configurations]=trueendapi_instance=DatadogAPIClient::V2::MetricsAPI.newpapi_instance.list_tag_configurations()
/**
* List tag configurations returns "Success" response
*/import{v2}from"@datadog/datadog-api-client";constconfiguration=v2.createConfiguration();configuration.unstableOperations["listTagConfigurations"]=true;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));
// List tag configurations returns "Success" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v2/datadog")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("ListTagConfigurations",true)apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.MetricsApi.ListTagConfigurations(ctx,*datadog.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)}
Response Object that includes your query and the list of metrics retrieved.
Expand All
Champ
Type
Description
error
string
Message indicating the errors if status is not ok.
from_date
int64
Start of requested time window, milliseconds since Unix epoch.
group_by
[string]
List of tag keys on which to group.
message
string
Message indicating success if status is ok.
query
string
Query string
res_type
string
Type of response.
series
[object]
List of timeseries queried.
aggr
string
Aggregation type.
display_name
string
Display name of the metric.
end
int64
End of the time window, milliseconds since Unix epoch.
expression
string
Metric expression.
interval
int64
Number of seconds between data samples.
length
int64
Number of data samples.
metric
string
Metric name.
pointlist
[array]
List of points of the time series.
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.
First element describes the "primary unit" (for example, bytes in bytes per second),
second describes the "per unit" (for example, second in bytes per second).
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)
"""
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
*/import{v2}from"@datadog/datadog-api-client";constconfiguration=v2.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 by metric name returns "Success" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v2/datadog")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)resp,r,err:=apiClient.MetricsApi.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" response
importcom.datadog.api.v2.client.ApiClient;importcom.datadog.api.v2.client.ApiException;importcom.datadog.api.v2.client.Configuration;importcom.datadog.api.v2.client.api.MetricsApi;importcom.datadog.api.v2.client.model.MetricAllTagsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the system
StringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");try{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();}}}
View distinct metrics volumes for the given metric name.
Custom distribution metrics will return both ingested and indexed custom metric volumes.
For Metrics without Limits™ beta customers, all metrics will return both ingested/indexed volumes.
Custom metrics generated in-app from other products will return null for ingested volumes.
"""
List distinct metric volumes by metric name returns "Success" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApiconfiguration=Configuration()withApiClient(configuration)