View indexed and ingested tags for a given metric name.
Results are filtered by the window[seconds] parameter, which defaults to 14400 (4 hours).
This endpoint requires the metrics_read permission.
OAuth apps require the metrics_read authorization scope to access this endpoint.
Arguments
Path Parameters
Name
Type
Description
metric_name [required]
string
The name of the metric.
Query Strings
Name
Type
Description
window[seconds]
integer
The number of seconds of look back (from now) to query for tag data.
Default value is 14400 (4 hours), minimum value is 14400 (4 hours).
filter[tags]
string
Filter results to tags from data points that have the specified tags.
For example, filter[tags]=env:staging,host:123 returns tags only from data points with both env:staging and host:123.
filter[match]
string
Filter returned tags to those matching a substring.
For example, filter[match]=env returns tags like env:prod, environment:staging, etc.
filter[include_tag_values]
boolean
Whether to include tag values in the response.
Defaults to true.
filter[allow_partial]
boolean
Whether to allow partial results.
Defaults to false.
"""
List tags by metric name returns "Success" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.metrics_apiimportMetricsApi# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=environ["METRIC_TAG_CONFIGURATION_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=MetricsApi(api_client)response=api_instance.list_tags_by_metric_name(metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,)print(response)
# List tags by metric name returns "Success" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::MetricsAPI.new# there is a valid "metric_tag_configuration" in the systemMETRIC_TAG_CONFIGURATION_DATA_ID=ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]papi_instance.list_tags_by_metric_name(METRIC_TAG_CONFIGURATION_DATA_ID)
// List tags by metric name returns "Success" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "metric_tag_configuration" in the systemMetricTagConfigurationDataID:=os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewMetricsApi(apiClient)resp,r,err:=api.ListTagsByMetricName(ctx,MetricTagConfigurationDataID,*datadogV2.NewListTagsByMetricNameOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `MetricsApi.ListTagsByMetricName`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `MetricsApi.ListTagsByMetricName`:\n%s\n",responseContent)}
// List tags by metric name returns "Success" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.MetricsApi;importcom.datadog.api.client.v2.model.MetricAllTagsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();MetricsApiapiInstance=newMetricsApi(defaultClient);// there is a valid "metric_tag_configuration" in the systemStringMETRIC_TAG_CONFIGURATION_DATA_ID=System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");try{MetricAllTagsResponseresult=apiInstance.listTagsByMetricName(METRIC_TAG_CONFIGURATION_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling MetricsApi#listTagsByMetricName");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// List tags by metric name returns "Success" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_metrics::ListTagsByMetricNameOptionalParams;usedatadog_api_client::datadogV2::api_metrics::MetricsAPI;#[tokio::main]asyncfnmain(){// there is a valid "metric_tag_configuration" in the system
letmetric_tag_configuration_data_id=std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=MetricsAPI::with_config(configuration);letresp=api.list_tags_by_metric_name(metric_tag_configuration_data_id.clone(),ListTagsByMetricNameOptionalParams::default(),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* List tags by metric name returns "Success" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.MetricsApi(configuration);// there is a valid "metric_tag_configuration" in the system
constMETRIC_TAG_CONFIGURATION_DATA_ID=process.env.METRIC_TAG_CONFIGURATION_DATA_IDasstring;constparams: v2.MetricsApiListTagsByMetricNameRequest={metricName: METRIC_TAG_CONFIGURATION_DATA_ID,};apiInstance.listTagsByMetricName(params).then((data: v2.MetricAllTagsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));