Delete tags for multiple metrics

DELETE https://api.ap1.datadoghq.com/api/v2/metrics/config/bulk-tagshttps://api.ap2.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.us2.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

Note: This endpoint is deprecated. Use Tag Indexing Rules (POST /api/v2/metrics/tag-indexing-rules) instead.

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.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Request object to bulk delete all tag configurations for metrics matching the given prefix.

attributes

object

Optional parameters for bulk deleting metric tag configurations.

emails

[string]

A list of account emails to notify when the configuration is applied.

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

default: metric_bulk_configure_tags

{
  "data": {
    "attributes": {
      "emails": [
        "sue@example.com",
        "bob@example.com"
      ]
    },
    "id": "kafka.lag",
    "type": "metric_bulk_configure_tags"
  }
}

Response

Accepted

Wrapper for a single bulk tag configuration status response.

Expand All

Field

Type

Description

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

default: metric_bulk_configure_tags

{
  "data": {
    "attributes": {
      "emails": [
        "sue@example.com",
        "bob@example.com"
      ],
      "exclude_tags_mode": false,
      "status": "Accepted",
      "tags": [
        "host",
        "pod_name",
        "is_shadow"
      ]
    },
    "id": "kafka.lag",
    "type": "metric_bulk_configure_tags"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                  ## default
# 

# Curl command
curl -X DELETE "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/metrics/config/bulk-tags" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "emails": [ "sue@example.com", "bob@example.com" ] }, "id": "kafka.lag", "type": "metric_bulk_configure_tags" } } EOF
"""
Delete tags for multiple metrics returns "Accepted" response
"""

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_delete import MetricBulkTagConfigDelete
from datadog_api_client.v2.model.metric_bulk_tag_config_delete_attributes import MetricBulkTagConfigDeleteAttributes
from datadog_api_client.v2.model.metric_bulk_tag_config_delete_request import MetricBulkTagConfigDeleteRequest
from datadog_api_client.v2.model.metric_bulk_tag_config_email_list import MetricBulkTagConfigEmailList

body = MetricBulkTagConfigDeleteRequest(
    data=MetricBulkTagConfigDelete(
        attributes=MetricBulkTagConfigDeleteAttributes(
            emails=MetricBulkTagConfigEmailList(
                [
                    "sue@example.com",
                    "bob@example.com",
                ]
            ),
        ),
        id="kafka.lag",
        type=MetricBulkConfigureTagsType.BULK_MANAGE_TAGS,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.delete_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.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Delete tags for multiple metrics returns "Accepted" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new

body = DatadogAPIClient::V2::MetricBulkTagConfigDeleteRequest.new({
  data: DatadogAPIClient::V2::MetricBulkTagConfigDelete.new({
    attributes: DatadogAPIClient::V2::MetricBulkTagConfigDeleteAttributes.new({
      emails: [
        "sue@example.com",
        "bob@example.com",
      ],
    }),
    id: "kafka.lag",
    type: DatadogAPIClient::V2::MetricBulkConfigureTagsType::BULK_MANAGE_TAGS,
  }),
})
p api_instance.delete_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.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Delete 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() {
	body := datadogV2.MetricBulkTagConfigDeleteRequest{
		Data: datadogV2.MetricBulkTagConfigDelete{
			Attributes: &datadogV2.MetricBulkTagConfigDeleteAttributes{
				Emails: []string{
					"sue@example.com",
					"bob@example.com",
				},
			},
			Id:   "kafka.lag",
			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.DeleteBulkTagsMetricsConfiguration(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.DeleteBulkTagsMetricsConfiguration`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.DeleteBulkTagsMetricsConfiguration`:\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.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Delete 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.MetricBulkTagConfigDelete;
import com.datadog.api.client.v2.model.MetricBulkTagConfigDeleteAttributes;
import com.datadog.api.client.v2.model.MetricBulkTagConfigDeleteRequest;
import com.datadog.api.client.v2.model.MetricBulkTagConfigResponse;
import java.util.Arrays;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    MetricsApi apiInstance = new MetricsApi(defaultClient);

    MetricBulkTagConfigDeleteRequest body =
        new MetricBulkTagConfigDeleteRequest()
            .data(
                new MetricBulkTagConfigDelete()
                    .attributes(
                        new MetricBulkTagConfigDeleteAttributes()
                            .emails(Arrays.asList("sue@example.com", "bob@example.com")))
                    .id("kafka.lag")
                    .type(MetricBulkConfigureTagsType.BULK_MANAGE_TAGS));

    try {
      MetricBulkTagConfigResponse result = apiInstance.deleteBulkTagsMetricsConfiguration(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#deleteBulkTagsMetricsConfiguration");
      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.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
// Delete 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::MetricBulkTagConfigDelete;
use datadog_api_client::datadogV2::model::MetricBulkTagConfigDeleteAttributes;
use datadog_api_client::datadogV2::model::MetricBulkTagConfigDeleteRequest;

#[tokio::main]
async fn main() {
    let body = MetricBulkTagConfigDeleteRequest::new(
        MetricBulkTagConfigDelete::new(
            "kafka.lag".to_string(),
            MetricBulkConfigureTagsType::BULK_MANAGE_TAGS,
        )
        .attributes(MetricBulkTagConfigDeleteAttributes::new().emails(vec![
            "sue@example.com".to_string(),
            "bob@example.com".to_string(),
        ])),
    );
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.delete_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.comap2.datadoghq.comddog-gov.comus2.ddog-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";

const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);

const params: 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));

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.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"