POST https://api.ap1.datadoghq.com/api/v2/metrics/config/bulk-tagshttps://api.datadoghq.eu/api/v2/metrics/config/bulk-tagshttps://api.ddog-gov.com/api/v2/metrics/config/bulk-tagshttps://api.datadoghq.com/api/v2/metrics/config/bulk-tagshttps://api.us3.datadoghq.com/api/v2/metrics/config/bulk-tagshttps://api.us5.datadoghq.com/api/v2/metrics/config/bulk-tags
Overview
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.
Request
Body Data (required)
Response
Code Example
// Configure tags for multiple metrics returns "Accepted" response
package main
import (
"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"
)
func main() {
// 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)
if err != 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)
}
Instructions
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Configure tags for multiple metrics returns "Accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.MetricBulkConfigureTagsType;
import com.datadog.api.client.v2.model.MetricBulkTagConfigCreate;
import com.datadog.api.client.v2.model.MetricBulkTagConfigCreateAttributes;
import com.datadog.api.client.v2.model.MetricBulkTagConfigCreateRequest;
import com.datadog.api.client.v2.model.MetricBulkTagConfigResponse;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
// there is a valid "user" in the system
String USER_DATA_ATTRIBUTES_EMAIL = System.getenv("USER_DATA_ATTRIBUTES_EMAIL");
MetricBulkTagConfigCreateRequest body =
new MetricBulkTagConfigCreateRequest()
.data(
new MetricBulkTagConfigCreate()
.attributes(
new MetricBulkTagConfigCreateAttributes()
.emails(Collections.singletonList(USER_DATA_ATTRIBUTES_EMAIL))
.tags(Arrays.asList("test", "examplemetric")))
.id("system.load.1")
.type(MetricBulkConfigureTagsType.BULK_MANAGE_TAGS));
try {
MetricBulkTagConfigResponse result = apiInstance.createBulkTagsMetricsConfiguration(body);
System.out.println(result);
} catch (ApiException e) {
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();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
"""
Configure tags for multiple metrics returns "Accepted" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_bulk_configure_tags_type import MetricBulkConfigureTagsType
from datadog_api_client.v2.model.metric_bulk_tag_config_create import MetricBulkTagConfigCreate
from datadog_api_client.v2.model.metric_bulk_tag_config_create_attributes import MetricBulkTagConfigCreateAttributes
from datadog_api_client.v2.model.metric_bulk_tag_config_create_request import MetricBulkTagConfigCreateRequest
from datadog_api_client.v2.model.metric_bulk_tag_config_email_list import MetricBulkTagConfigEmailList
from datadog_api_client.v2.model.metric_bulk_tag_config_tag_name_list import MetricBulkTagConfigTagNameList
# there is a valid "user" in the system
USER_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()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.create_bulk_tags_metrics_configuration(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Configure tags for multiple metrics returns "Accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
# there is a valid "user" in the system
USER_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,
}),
})
p api_instance.create_bulk_tags_metrics_configuration(body)
Instructions
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Configure tags for multiple metrics returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::MetricBulkConfigureTagsType;
use datadog_api_client::datadogV2::model::MetricBulkTagConfigCreate;
use datadog_api_client::datadogV2::model::MetricBulkTagConfigCreateAttributes;
use datadog_api_client::datadogV2::model::MetricBulkTagConfigCreateRequest;
#[tokio::main]
async fn main() {
// there is a valid "user" in the system
let user_data_attributes_email = std::env::var("USER_DATA_ATTRIBUTES_EMAIL").unwrap();
let body = 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()]),
),
);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api.create_bulk_tags_metrics_configuration(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
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";
const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);
// there is a valid "user" in the system
const USER_DATA_ATTRIBUTES_EMAIL = process.env
.USER_DATA_ATTRIBUTES_EMAIL as string;
const params: 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));
Instructions
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"