---
title: Metrics
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Metrics
---

# Metrics

The metrics endpoint allows you to:

- Post metrics data so it can be graphed on Datadog's dashboards
- Query metrics from any time period
- Modify tag configurations for metrics
- View tags and volumes for metrics

**Note**: A graph can only contain a set number of points and as the timeframe over which a metric is viewed increases, aggregation between points occurs to stay below that set number.

The Post, Patch, and Delete `manage_tags` API methods can only be performed by a user who has the `Manage Tags for Metrics` permission.

See the [Metrics page](https://docs.datadoghq.com/metrics.md) for more information.

## Create a tag configuration{% #create-a-tag-configuration %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                         |
| ----------------- | -------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tags      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/metrics/{metric_name}/tags      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/metrics/{metric_name}/tags     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags |

### Overview

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. 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 are not 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.

### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                         | Type     | Description                                                                                                                                                                                                                                                         |
| ------------ | ----------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]        | object   | Object for a single metric to be configure tags on.                                                                                                                                                                                                                 |
| data         | attributes                    | object   | Object containing the definition of a metric tag configuration to be created.                                                                                                                                                                                       |
| attributes   | aggregations                  | [object] | Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.                                                                                                                                                        |
| aggregations | space [*required*]       | enum     | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                                                                                                                                                                        |
| aggregations | time [*required*]        | enum     | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                                                                                                                                                                                   |
| attributes   | 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. |
| attributes   | 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`.                                                                                                     |
| attributes   | metric_type [*required*] | enum     | The metric's type. Allowed enum values: `gauge,count,rate,distribution`                                                                                                                                                                                             |
| attributes   | tags [*required*]        | [string] | A list of tag keys that will be queryable for your metric.                                                                                                                                                                                                          |
| data         | id [*required*]          | string   | The metric name for this resource.                                                                                                                                                                                                                                  |
| data         | type [*required*]        | enum     | The metric tag configuration resource type. Allowed enum values: `manage_tags`                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "type": "manage_tags",
    "id": "ExampleMetric",
    "attributes": {
      "tags": [
        "app",
        "datacenter"
      ],
      "metric_type": "gauge"
    }
  }
}
```

{% /tab %}

### Response

{% tab title="201" %}
Created
{% tab title="Model" %}
Response object which includes a single metric's tag configuration.

| Parent field | Field                   | Type      | Description                                                                                                                                                                                                                                                         |
| ------------ | ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                    | object    | Object for a single metric tag configuration.                                                                                                                                                                                                                       |
| data         | attributes              | object    | Object containing the definition of a metric tag configuration attributes.                                                                                                                                                                                          |
| attributes   | aggregations            | [object]  | Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.                                                                                                                                                        |
| aggregations | space [*required*] | enum      | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                                                                                                                                                                        |
| aggregations | time [*required*]  | enum      | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                                                                                                                                                                                   |
| attributes   | created_at              | date-time | Timestamp when the tag configuration was created.                                                                                                                                                                                                                   |
| attributes   | 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. |
| attributes   | include_percentiles     | boolean   | Toggle to include or exclude percentile aggregations for distribution metrics. Only present when the `metric_type` is `distribution`.                                                                                                                               |
| attributes   | metric_type             | enum      | The metric's type. Allowed enum values: `gauge,count,rate,distribution`                                                                                                                                                                                             |
| attributes   | modified_at             | date-time | Timestamp when the tag configuration was last modified.                                                                                                                                                                                                             |
| attributes   | tags                    | [string]  | List of tag keys on which to group.                                                                                                                                                                                                                                 |
| data         | id                      | string    | The metric name for this resource.                                                                                                                                                                                                                                  |
| data         | type                    | enum      | The metric tag configuration resource type. Allowed enum values: `manage_tags`                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "aggregations": [
        {
          "space": "sum",
          "time": "sum"
        }
      ],
      "created_at": "2020-03-25T09:48:37.463835Z",
      "exclude_tags_mode": false,
      "include_percentiles": true,
      "metric_type": "count",
      "modified_at": "2020-03-25T09:48:37.463835Z",
      "tags": [
        "app",
        "datacenter"
      ]
    },
    "id": "test.metric.latency",
    "type": "manage_tags"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="409" %}
Conflict
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/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": {
    "type": "manage_tags",
    "id": "ExampleMetric",
    "attributes": {
      "tags": [
        "app",
        "datacenter"
      ],
      "metric_type": "gauge"
    }
  }
}
EOF
                        
##### 

```go
// Create a tag configuration returns "Created" 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.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)

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Create a tag configuration returns "Created" 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.MetricTagConfigurationCreateAttributes;
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateData;
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateRequest;
import com.datadog.api.client.v2.model.MetricTagConfigurationMetricTypes;
import com.datadog.api.client.v2.model.MetricTagConfigurationResponse;
import com.datadog.api.client.v2.model.MetricTagConfigurationType;
import java.util.Arrays;

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

    MetricTagConfigurationCreateRequest body =
        new MetricTagConfigurationCreateRequest()
            .data(
                new MetricTagConfigurationCreateData()
                    .type(MetricTagConfigurationType.MANAGE_TAGS)
                    .id("ExampleMetric")
                    .attributes(
                        new MetricTagConfigurationCreateAttributes()
                            .tags(Arrays.asList("app", "datacenter"))
                            .metricType(MetricTagConfigurationMetricTypes.GAUGE)));

    try {
      MetricTagConfigurationResponse result =
          apiInstance.createTagConfiguration("ExampleMetric", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#createTagConfiguration");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```python
"""
Create a tag configuration returns "Created" 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_tag_configuration_create_attributes import (
    MetricTagConfigurationCreateAttributes,
)
from datadog_api_client.v2.model.metric_tag_configuration_create_data import MetricTagConfigurationCreateData
from datadog_api_client.v2.model.metric_tag_configuration_create_request import MetricTagConfigurationCreateRequest
from datadog_api_client.v2.model.metric_tag_configuration_metric_types import MetricTagConfigurationMetricTypes
from datadog_api_client.v2.model.metric_tag_configuration_type import MetricTagConfigurationType

body = MetricTagConfigurationCreateRequest(
    data=MetricTagConfigurationCreateData(
        type=MetricTagConfigurationType.MANAGE_TAGS,
        id="ExampleMetric",
        attributes=MetricTagConfigurationCreateAttributes(
            tags=[
                "app",
                "datacenter",
            ],
            metric_type=MetricTagConfigurationMetricTypes.GAUGE,
        ),
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.create_tag_configuration(metric_name="ExampleMetric", body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Create a tag configuration returns "Created" response

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

body = 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,
    }),
  }),
})
p api_instance.create_tag_configuration("ExampleMetric", body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```rust
// Create a tag configuration returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::MetricTagConfigurationCreateAttributes;
use datadog_api_client::datadogV2::model::MetricTagConfigurationCreateData;
use datadog_api_client::datadogV2::model::MetricTagConfigurationCreateRequest;
use datadog_api_client::datadogV2::model::MetricTagConfigurationMetricTypes;
use datadog_api_client::datadogV2::model::MetricTagConfigurationType;

#[tokio::main]
async fn main() {
    let body = MetricTagConfigurationCreateRequest::new(
        MetricTagConfigurationCreateData::new(
            "ExampleMetric".to_string(),
            MetricTagConfigurationType::MANAGE_TAGS,
        )
        .attributes(MetricTagConfigurationCreateAttributes::new(
            MetricTagConfigurationMetricTypes::GAUGE,
            vec!["app".to_string(), "datacenter".to_string()],
        )),
    );
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .create_tag_configuration("ExampleMetric".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Create a tag configuration returns "Created" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Get active metrics list{% #get-active-metrics-list %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                     |
| ----------------- | ------------------------------------------------ |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v1/metrics |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v1/metrics |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v1/metrics      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v1/metrics      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v1/metrics     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v1/metrics |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v1/metrics |

### Overview

Get the list of actively reporting metrics from a given time until now. This endpoint requires the `metrics_read` permission.

OAuth apps require the `metrics_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Arguments

#### Query Strings

| Name                   | Type    | Description                                                                                                                                    |
| ---------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| from [*required*] | integer | Seconds since the Unix epoch.                                                                                                                  |
| host                   | string  | Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag.                  |
| tag_filter             | string  | Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Object listing all metric names stored by Datadog since a given time.

| Field   | Type     | Description                                                      |
| ------- | -------- | ---------------------------------------------------------------- |
| from    | string   | Time when the metrics were active, seconds since the Unix epoch. |
| metrics | [string] | List of metric names.                                            |

{% /tab %}

{% tab title="Example" %}

```json
{
  "from": "string",
  "metrics": []
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Required query argumentsexport from="CHANGE_ME"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/metrics?from=${from}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Get active metrics list returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_active_metrics(
        _from=9223372036854775807,
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get active metrics list returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
p api_instance.list_active_metrics(9223372036854775807)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get active metrics list returns "OK" 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/datadogV1"
)

func main() {
	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())

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get active metrics list returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricsListResponse;

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

    try {
      MetricsListResponse result = apiInstance.listActiveMetrics(9223372036854775807L);
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
from datadog import initialize, api
import time

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Taking the last 24hours
from_time = int(time.time()) - 60 * 60 * 24 * 1

result = api.Metric.list(from_time)

print(result)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
##### 

```rust
// Get active metrics list returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::ListActiveMetricsOptionalParams;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .list_active_metrics(
            9223372036854775807,
            ListActiveMetricsOptionalParams::default(),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get active metrics list returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## Get metric metadata{% #get-metric-metadata %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                                   |
| ----------------- | -------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v1/metrics/{metric_name} |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v1/metrics/{metric_name} |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v1/metrics/{metric_name}      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v1/metrics/{metric_name}      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v1/metrics/{metric_name}     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v1/metrics/{metric_name} |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v1/metrics/{metric_name} |

### Overview

Get metadata about a specific metric. This endpoint requires the `metrics_read` permission.

OAuth apps require the `metrics_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Arguments

#### Path Parameters

| Name                          | Type   | Description                                   |
| ----------------------------- | ------ | --------------------------------------------- |
| metric_name [*required*] | string | Name of the metric for which to get metadata. |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Object with all metric related metadata.

| Field           | Type   | Description                                                       |
| --------------- | ------ | ----------------------------------------------------------------- |
| description     | string | Metric description.                                               |
| integration     | string | Name of the integration that sent the metric if applicable.       |
| per_unit        | string | Per unit of the metric such as `second` in `bytes per second`.    |
| short_name      | string | A more human-readable and abbreviated version of the metric name. |
| statsd_interval | int64  | StatsD flush interval of the metric in seconds if applicable.     |
| type            | string | Metric type such as `gauge` or `rate`.                            |
| unit            | string | Primary unit of the metric such as `byte` or `operation`.         |

{% /tab %}

{% tab title="Example" %}

```json
{
  "description": "string",
  "integration": "string",
  "per_unit": "second",
  "short_name": "string",
  "statsd_interval": "integer",
  "type": "count",
  "unit": "byte"
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="CHANGE_ME"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Get metric metadata returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.get_metric_metadata(
        metric_name="metric_name",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get metric metadata returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
p api_instance.get_metric_metadata("metric_name")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```ruby
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 metric
result = dog.get_metadata('system.net.bytes_sent')
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get metric metadata returns "OK" 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/datadogV1"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewMetricsApi(apiClient)
	resp, r, err := api.GetMetricMetadata(ctx, "metric_name")

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.GetMetricMetadata`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get metric metadata returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricMetadata;

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

    try {
      MetricMetadata result = apiInstance.getMetricMetadata("metric_name");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#getMetricMetadata");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

metric = 'system.cpu.idle'

api.Metadata.get(metric_name=metric)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
##### 

```rust
// Get metric metadata returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.get_metric_metadata("metric_name".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get metric metadata returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## List tag configuration by name{% #list-tag-configuration-by-name %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                        |
| ----------------- | ------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tags      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/tags      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/tags     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags |

### Overview

Returns the tag configuration for the given metric name. This endpoint requires the `metrics_read` permission.

OAuth apps require the `metrics_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object which includes a single metric's tag configuration.

| Parent field | Field                   | Type      | Description                                                                                                                                                                                                                                                         |
| ------------ | ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                    | object    | Object for a single metric tag configuration.                                                                                                                                                                                                                       |
| data         | attributes              | object    | Object containing the definition of a metric tag configuration attributes.                                                                                                                                                                                          |
| attributes   | aggregations            | [object]  | Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.                                                                                                                                                        |
| aggregations | space [*required*] | enum      | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                                                                                                                                                                        |
| aggregations | time [*required*]  | enum      | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                                                                                                                                                                                   |
| attributes   | created_at              | date-time | Timestamp when the tag configuration was created.                                                                                                                                                                                                                   |
| attributes   | 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. |
| attributes   | include_percentiles     | boolean   | Toggle to include or exclude percentile aggregations for distribution metrics. Only present when the `metric_type` is `distribution`.                                                                                                                               |
| attributes   | metric_type             | enum      | The metric's type. Allowed enum values: `gauge,count,rate,distribution`                                                                                                                                                                                             |
| attributes   | modified_at             | date-time | Timestamp when the tag configuration was last modified.                                                                                                                                                                                                             |
| attributes   | tags                    | [string]  | List of tag keys on which to group.                                                                                                                                                                                                                                 |
| data         | id                      | string    | The metric name for this resource.                                                                                                                                                                                                                                  |
| data         | type                    | enum      | The metric tag configuration resource type. Allowed enum values: `manage_tags`                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "aggregations": [
        {
          "space": "sum",
          "time": "sum"
        }
      ],
      "created_at": "2020-03-25T09:48:37.463835Z",
      "exclude_tags_mode": false,
      "include_percentiles": true,
      "metric_type": "count",
      "modified_at": "2020-03-25T09:48:37.463835Z",
      "tags": [
        "app",
        "datacenter"
      ]
    },
    "id": "test.metric.latency",
    "type": "manage_tags"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
List tag configuration by name returns "Success" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

# there is a valid "metric_tag_configuration" in the system
METRIC_TAG_CONFIGURATION_DATA_ID = environ["METRIC_TAG_CONFIGURATION_DATA_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_tag_configuration_by_name(
        metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# List tag configuration by name returns "Success" response

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

# there is a valid "metric_tag_configuration" in the system
METRIC_TAG_CONFIGURATION_DATA_ID = ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]
p api_instance.list_tag_configuration_by_name(METRIC_TAG_CONFIGURATION_DATA_ID)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// List tag configuration by name returns "Success" 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 "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)

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// List tag configuration by name returns "Success" 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.MetricTagConfigurationResponse;

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

    // there is a valid "metric_tag_configuration" in the system
    String METRIC_TAG_CONFIGURATION_DATA_ID = System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");

    try {
      MetricTagConfigurationResponse result =
          apiInstance.listTagConfigurationByName(METRIC_TAG_CONFIGURATION_DATA_ID);
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// List tag configuration by name returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    // there is a valid "metric_tag_configuration" in the system
    let metric_tag_configuration_data_id =
        std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .list_tag_configuration_by_name(metric_tag_configuration_data_id.clone())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * List tag configuration by name returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

// there is a valid "metric_tag_configuration" in the system
const METRIC_TAG_CONFIGURATION_DATA_ID = process.env
  .METRIC_TAG_CONFIGURATION_DATA_ID as string;

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## Edit metric metadata{% #edit-metric-metadata %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                                   |
| ----------------- | -------------------------------------------------------------- |
| ap1.datadoghq.com | PUT https://api.ap1.datadoghq.com/api/v1/metrics/{metric_name} |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v1/metrics/{metric_name} |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v1/metrics/{metric_name}      |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v1/metrics/{metric_name}      |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v1/metrics/{metric_name}     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v1/metrics/{metric_name} |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v1/metrics/{metric_name} |

### Overview

Edit metadata of a specific metric. Find out more about [supported types](https://docs.datadoghq.com/developers/metrics.md). This endpoint requires the `metrics_metadata_write` permission.

### Arguments

#### Path Parameters

| Name                          | Type   | Description                                    |
| ----------------------------- | ------ | ---------------------------------------------- |
| metric_name [*required*] | string | Name of the metric for which to edit metadata. |

### Request

#### Body Data (required)

New metadata.

{% tab title="Model" %}

| Field           | Type   | Description                                                       |
| --------------- | ------ | ----------------------------------------------------------------- |
| description     | string | Metric description.                                               |
| integration     | string | Name of the integration that sent the metric if applicable.       |
| per_unit        | string | Per unit of the metric such as `second` in `bytes per second`.    |
| short_name      | string | A more human-readable and abbreviated version of the metric name. |
| statsd_interval | int64  | StatsD flush interval of the metric in seconds if applicable.     |
| type            | string | Metric type such as `gauge` or `rate`.                            |
| unit            | string | Primary unit of the metric such as `byte` or `operation`.         |

{% /tab %}

{% tab title="Example" %}

```json
{
  "description": "string",
  "per_unit": "second",
  "short_name": "string",
  "statsd_interval": "integer",
  "type": "count",
  "unit": "byte"
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Object with all metric related metadata.

| Field           | Type   | Description                                                       |
| --------------- | ------ | ----------------------------------------------------------------- |
| description     | string | Metric description.                                               |
| integration     | string | Name of the integration that sent the metric if applicable.       |
| per_unit        | string | Per unit of the metric such as `second` in `bytes per second`.    |
| short_name      | string | A more human-readable and abbreviated version of the metric name. |
| statsd_interval | int64  | StatsD flush interval of the metric in seconds if applicable.     |
| type            | string | Metric type such as `gauge` or `rate`.                            |
| unit            | string | Primary unit of the metric such as `byte` or `operation`.         |

{% /tab %}

{% tab title="Example" %}

```json
{
  "description": "string",
  "integration": "string",
  "per_unit": "second",
  "short_name": "string",
  "statsd_interval": "integer",
  "type": "count",
  "unit": "byte"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="CHANGE_ME"\# Curl commandcurl -X PUT "https://api.ap1.datadoghq.com"https://api.ap2.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/metrics/${metric_name}" \
-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
{}
EOF
                
##### 

```python
"""
Edit metric metadata returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.metric_metadata import MetricMetadata

body = MetricMetadata(
    per_unit="second",
    type="count",
    unit="byte",
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.update_metric_metadata(metric_name="metric_name", body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Edit metric metadata returns "OK" response

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

body = DatadogAPIClient::V1::MetricMetadata.new({
  per_unit: "second",
  type: "count",
  unit: "byte",
})
p api_instance.update_metric_metadata("metric_name", body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Edit metric metadata returns "OK" 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/datadogV1"
)

func main() {
	body := datadogV1.MetricMetadata{
		PerUnit: datadog.PtrString("second"),
		Type:    datadog.PtrString("count"),
		Unit:    datadog.PtrString("byte"),
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewMetricsApi(apiClient)
	resp, r, err := api.UpdateMetricMetadata(ctx, "metric_name", body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.UpdateMetricMetadata`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Edit metric metadata returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricMetadata;

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

    MetricMetadata body = new MetricMetadata().perUnit("second").type("count").unit("byte");

    try {
      MetricMetadata result = apiInstance.updateMetricMetadata("metric_name", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#updateMetricMetadata");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Edit metric metadata returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;
use datadog_api_client::datadogV1::model::MetricMetadata;

#[tokio::main]
async fn main() {
    let body = MetricMetadata::new()
        .per_unit("second".to_string())
        .type_("count".to_string())
        .unit("byte".to_string());
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .update_metric_metadata("metric_name".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Edit metric metadata returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Update a tag configuration{% #update-a-tag-configuration %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                          |
| ----------------- | --------------------------------------------------------------------- |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tags      |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/metrics/{metric_name}/tags      |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/metrics/{metric_name}/tags     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags |

### Overview

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.

### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                   | Type     | Description                                                                                                                                                                                                                                                         |
| ------------ | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]  | object   | Object for a single tag configuration to be edited.                                                                                                                                                                                                                 |
| data         | attributes              | object   | Object containing the definition of a metric tag configuration to be updated.                                                                                                                                                                                       |
| attributes   | aggregations            | [object] | Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.                                                                                                                                                        |
| aggregations | space [*required*] | enum     | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                                                                                                                                                                        |
| aggregations | time [*required*]  | enum     | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                                                                                                                                                                                   |
| attributes   | 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. |
| attributes   | 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`.                                                                                                     |
| attributes   | tags                    | [string] | A list of tag keys that will be queryable for your metric.                                                                                                                                                                                                          |
| data         | id [*required*]    | string   | The metric name for this resource.                                                                                                                                                                                                                                  |
| data         | type [*required*]  | enum     | The metric tag configuration resource type. Allowed enum values: `manage_tags`                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "type": "manage_tags",
    "id": "test.metric.latency",
    "attributes": {
      "tags": [
        "app"
      ]
    }
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response object which includes a single metric's tag configuration.

| Parent field | Field                   | Type      | Description                                                                                                                                                                                                                                                         |
| ------------ | ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                    | object    | Object for a single metric tag configuration.                                                                                                                                                                                                                       |
| data         | attributes              | object    | Object containing the definition of a metric tag configuration attributes.                                                                                                                                                                                          |
| attributes   | aggregations            | [object]  | Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.                                                                                                                                                        |
| aggregations | space [*required*] | enum      | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                                                                                                                                                                        |
| aggregations | time [*required*]  | enum      | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                                                                                                                                                                                   |
| attributes   | created_at              | date-time | Timestamp when the tag configuration was created.                                                                                                                                                                                                                   |
| attributes   | 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. |
| attributes   | include_percentiles     | boolean   | Toggle to include or exclude percentile aggregations for distribution metrics. Only present when the `metric_type` is `distribution`.                                                                                                                               |
| attributes   | metric_type             | enum      | The metric's type. Allowed enum values: `gauge,count,rate,distribution`                                                                                                                                                                                             |
| attributes   | modified_at             | date-time | Timestamp when the tag configuration was last modified.                                                                                                                                                                                                             |
| attributes   | tags                    | [string]  | List of tag keys on which to group.                                                                                                                                                                                                                                 |
| data         | id                      | string    | The metric name for this resource.                                                                                                                                                                                                                                  |
| data         | type                    | enum      | The metric tag configuration resource type. Allowed enum values: `manage_tags`                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "aggregations": [
        {
          "space": "sum",
          "time": "sum"
        }
      ],
      "created_at": "2020-03-25T09:48:37.463835Z",
      "exclude_tags_mode": false,
      "include_percentiles": true,
      "metric_type": "count",
      "modified_at": "2020-03-25T09:48:37.463835Z",
      "tags": [
        "app",
        "datacenter"
      ]
    },
    "id": "test.metric.latency",
    "type": "manage_tags"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="422" %}
Unprocessable Entity
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X PATCH "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/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": {
    "type": "manage_tags",
    "id": "test.metric.latency",
    "attributes": {
      "tags": [
        "app"
      ]
    }
  }
}
EOF
                        
##### 

```go
// Update a tag configuration returns "OK" 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 "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)

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Update a tag configuration returns "OK" 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.MetricTagConfigurationResponse;
import com.datadog.api.client.v2.model.MetricTagConfigurationType;
import com.datadog.api.client.v2.model.MetricTagConfigurationUpdateAttributes;
import com.datadog.api.client.v2.model.MetricTagConfigurationUpdateData;
import com.datadog.api.client.v2.model.MetricTagConfigurationUpdateRequest;
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 "metric_tag_configuration" in the system
    String METRIC_TAG_CONFIGURATION_DATA_ID = System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");

    MetricTagConfigurationUpdateRequest body =
        new MetricTagConfigurationUpdateRequest()
            .data(
                new MetricTagConfigurationUpdateData()
                    .type(MetricTagConfigurationType.MANAGE_TAGS)
                    .id(METRIC_TAG_CONFIGURATION_DATA_ID)
                    .attributes(
                        new MetricTagConfigurationUpdateAttributes()
                            .tags(Collections.singletonList("app"))));

    try {
      MetricTagConfigurationResponse result =
          apiInstance.updateTagConfiguration(METRIC_TAG_CONFIGURATION_DATA_ID, body);
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```python
"""
Update a tag configuration returns "OK" 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_tag_configuration_type import MetricTagConfigurationType
from datadog_api_client.v2.model.metric_tag_configuration_update_attributes import (
    MetricTagConfigurationUpdateAttributes,
)
from datadog_api_client.v2.model.metric_tag_configuration_update_data import MetricTagConfigurationUpdateData
from datadog_api_client.v2.model.metric_tag_configuration_update_request import MetricTagConfigurationUpdateRequest

# there is a valid "metric_tag_configuration" in the system
METRIC_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()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.update_tag_configuration(metric_name=METRIC_TAG_CONFIGURATION_DATA_ID, body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Update a tag configuration returns "OK" response

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

# there is a valid "metric_tag_configuration" in the system
METRIC_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",
      ],
    }),
  }),
})
p api_instance.update_tag_configuration(METRIC_TAG_CONFIGURATION_DATA_ID, body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```rust
// Update a tag configuration returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::MetricTagConfigurationType;
use datadog_api_client::datadogV2::model::MetricTagConfigurationUpdateAttributes;
use datadog_api_client::datadogV2::model::MetricTagConfigurationUpdateData;
use datadog_api_client::datadogV2::model::MetricTagConfigurationUpdateRequest;

#[tokio::main]
async fn main() {
    // there is a valid "metric_tag_configuration" in the system
    let metric_tag_configuration_data_id =
        std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();
    let body = MetricTagConfigurationUpdateRequest::new(
        MetricTagConfigurationUpdateData::new(
            metric_tag_configuration_data_id.clone(),
            MetricTagConfigurationType::MANAGE_TAGS,
        )
        .attributes(MetricTagConfigurationUpdateAttributes::new().tags(vec!["app".to_string()])),
    );
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .update_tag_configuration(metric_tag_configuration_data_id.clone(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Update a tag configuration returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

// there is a valid "metric_tag_configuration" in the system
const METRIC_TAG_CONFIGURATION_DATA_ID = process.env
  .METRIC_TAG_CONFIGURATION_DATA_ID as string;

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Delete a tag configuration{% #delete-a-tag-configuration %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                           |
| ----------------- | ---------------------------------------------------------------------- |
| ap1.datadoghq.com | DELETE https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| ap2.datadoghq.com | DELETE https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| app.datadoghq.eu  | DELETE https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tags      |
| app.ddog-gov.com  | DELETE https://api.ddog-gov.com/api/v2/metrics/{metric_name}/tags      |
| app.datadoghq.com | DELETE https://api.datadoghq.com/api/v2/metrics/{metric_name}/tags     |
| us3.datadoghq.com | DELETE https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tags |
| us5.datadoghq.com | DELETE https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags |

### Overview

Deletes a metric's tag configuration. Can only be used with application keys from users with the `Manage Tags for Metrics` permission. Note: This operation is irreversible. This endpoint requires the `metric_tags_write` permission.

### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Response

{% tab title="204" %}
No Content
{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X DELETE "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/tags" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Delete a tag configuration returns "No Content" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    api_instance.delete_tag_configuration(
        metric_name="ExampleMetric",
    )
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Delete a tag configuration returns "No Content" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
api_instance.delete_tag_configuration("ExampleMetric")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Delete a tag configuration returns "No Content" response

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMetricsApi(apiClient)
	r, err := api.DeleteTagConfiguration(ctx, "ExampleMetric")

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Delete a tag configuration returns "No Content" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;

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

    try {
      apiInstance.deleteTagConfiguration("ExampleMetric");
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Delete a tag configuration returns "No Content" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .delete_tag_configuration("ExampleMetric".to_string())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Delete a tag configuration returns "No Content" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Search metrics{% #search-metrics %}

| Datadog site      | API endpoint                                    |
| ----------------- | ----------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v1/search |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v1/search |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v1/search      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v1/search      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v1/search     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v1/search |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v1/search |

### Overview



**Note**: This endpoint is deprecated. Use `/api/v2/metrics` instead.

Search for metrics from the last 24 hours in Datadog.
This endpoint requires the `metrics_read` permission.
OAuth apps require the `metrics_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Arguments

#### Query Strings

| Name                | Type   | Description                                                                      |
| ------------------- | ------ | -------------------------------------------------------------------------------- |
| q [*required*] | string | Query string to search metrics upon. Can optionally be prefixed with `metrics:`. |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Object containing the list of metrics matching the search query.

| Parent field | Field   | Type     | Description                                  |
| ------------ | ------- | -------- | -------------------------------------------- |
|              | results | object   | Search result.                               |
| results      | metrics | [string] | List of metrics that match the search query. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "results": {
    "metrics": []
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Required query argumentsexport q="CHANGE_ME"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/search?q=${q}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Search metrics returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_metrics(
        q="q",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Search metrics returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
p api_instance.list_metrics("q")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```ruby
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

dog.search("metrics:test")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Search metrics returns "OK" 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/datadogV1"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewMetricsApi(apiClient)
	resp, r, err := api.ListMetrics(ctx, "q")

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.ListMetrics`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Search metrics returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricSearchResponse;

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

    try {
      MetricSearchResponse result = apiInstance.listMetrics("q");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#listMetrics");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Search metrics returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.list_metrics("q".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Search metrics returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
## Get a list of metrics{% #get-a-list-of-metrics %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                     |
| ----------------- | ------------------------------------------------ |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics |

### Overview

Get a list of actively reporting metrics for your organization. Pagination is optional using the `page[cursor]` and `page[size]` query parameters. This endpoint requires the `metrics_read` permission.

OAuth apps require the `metrics_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Arguments

#### Query Strings

| Name                             | Type    | Description                                                                                                                                                                                                                                                                 |
| -------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter[configured]               | boolean | Only return custom metrics that have been configured with Metrics Without Limits.                                                                                                                                                                                           |
| filter[tags_configured]          | string  | Only return metrics that have the given tag key(s) in their Metrics Without Limits configuration (included or excluded).                                                                                                                                                    |
| filter[metric_type]              | enum    | Only return metrics of the given metric type.Allowed enum values: `non_distribution, distribution`                                                                                                                                                                          |
| filter[include_percentiles]      | boolean | Only return distribution metrics that have percentile aggregations enabled (true) or disabled (false).                                                                                                                                                                      |
| filter[queried]                  | boolean | Only return metrics that have been queried (true) or not queried (false) in the look back window. Set the window with `filter[queried][window][seconds]`; if omitted, a default window is used.                                                                             |
| filter[queried][window][seconds] | integer | Only return metrics that have been queried or not queried in the specified window. Dependent on being sent with `filter[queried]`. The default value is 2,592,000 seconds (30 days), the maximum value is 15,552,000 seconds (180 days), and the minimum value is 1 second. |
| filter[tags]                     | string  | Only return metrics that were submitted with tags matching this expression. You can use AND, OR, IN, and wildcards (for example, service:web*).                                                                                                                             |
| filter[related_assets]           | boolean | Only return metrics that are used in at least one dashboard, monitor, notebook, or SLO.                                                                                                                                                                                     |
| window[seconds]                  | integer | Only return metrics that have been actively reporting in the specified window. The default value is 3600 seconds (1 hour), the maximum value is 2,592,000 seconds (30 days), and the minimum value is 1 second.                                                             |
| page[size]                       | integer | Maximum number of results per page. Use with `page[cursor]` for pagination. The default value is 10000, the maximum value is 10000, and the minimum value is 1.                                                                                                             |
| page[cursor]                     | string  | Cursor for pagination. Use `page[size]` to opt-in to pagination and get the first page; for subsequent pages, use the value from `meta.pagination.next_cursor` in the response. Pagination is complete when `next_cursor` is null.                                          |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object that includes metrics and metric tag configurations.

| Parent field | Field                   | Type            | Description                                                                                                                                                                                                                                                         |
| ------------ | ----------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                    | [ <oneOf>] | Array of metrics and metric tag configurations.                                                                                                                                                                                                                     |
| data         | Option 1                | object          | Object for a single metric tag configuration.                                                                                                                                                                                                                       |
| Option 1     | id                      | string          | The metric name for this resource.                                                                                                                                                                                                                                  |
| Option 1     | type                    | enum            | The metric resource type. Allowed enum values: `metrics`                                                                                                                                                                                                            |
| data         | Option 2                | object          | Object for a single metric tag configuration.                                                                                                                                                                                                                       |
| Option 2     | attributes              | object          | Object containing the definition of a metric tag configuration attributes.                                                                                                                                                                                          |
| attributes   | aggregations            | [object]        | Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.                                                                                                                                                        |
| aggregations | space [*required*] | enum            | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                                                                                                                                                                        |
| aggregations | time [*required*]  | enum            | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                                                                                                                                                                                   |
| attributes   | created_at              | date-time       | Timestamp when the tag configuration was created.                                                                                                                                                                                                                   |
| attributes   | 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. |
| attributes   | include_percentiles     | boolean         | Toggle to include or exclude percentile aggregations for distribution metrics. Only present when the `metric_type` is `distribution`.                                                                                                                               |
| attributes   | metric_type             | enum            | The metric's type. Allowed enum values: `gauge,count,rate,distribution`                                                                                                                                                                                             |
| attributes   | modified_at             | date-time       | Timestamp when the tag configuration was last modified.                                                                                                                                                                                                             |
| attributes   | tags                    | [string]        | List of tag keys on which to group.                                                                                                                                                                                                                                 |
| Option 2     | id                      | string          | The metric name for this resource.                                                                                                                                                                                                                                  |
| Option 2     | type                    | enum            | The metric tag configuration resource type. Allowed enum values: `manage_tags`                                                                                                                                                                                      |
|              | links                   | object          | Pagination links. Only present if pagination query parameters were provided.                                                                                                                                                                                        |
| links        | first                   | string          | Link to the first page.                                                                                                                                                                                                                                             |
| links        | last                    | string          | Link to the last page.                                                                                                                                                                                                                                              |
| links        | next                    | string          | Link to the next page.                                                                                                                                                                                                                                              |
| links        | prev                    | string          | Link to previous page.                                                                                                                                                                                                                                              |
| links        | self                    | string          | Link to current page.                                                                                                                                                                                                                                               |
|              | meta                    | object          | Response metadata object.                                                                                                                                                                                                                                           |
| meta         | pagination              | object          | Paging attributes. Only present if pagination query parameters were provided.                                                                                                                                                                                       |
| pagination   | cursor                  | string          | The cursor used to get the current results, if any.                                                                                                                                                                                                                 |
| pagination   | limit                   | int32           | Number of results returned                                                                                                                                                                                                                                          |
| pagination   | next_cursor             | string          | The cursor used to get the next results, if any.                                                                                                                                                                                                                    |
| pagination   | type                    | enum            | Type of metric pagination. Allowed enum values: `cursor_limit`                                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "id": "test.metric.latency",
      "type": "metrics"
    }
  ],
  "links": {
    "first": "string",
    "last": "string",
    "next": "string",
    "prev": "string",
    "self": "string"
  },
  "meta": {
    "pagination": {
      "cursor": "string",
      "limit": "integer",
      "next_cursor": "string",
      "type": "cursor_limit"
    }
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Get a list of metrics returns "Success" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_tag_configurations()

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get a list of metrics returns "Success" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
p api_instance.list_tag_configurations()
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get a list of metrics returns "Success" 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() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMetricsApi(apiClient)
	resp, r, err := api.ListTagConfigurations(ctx, *datadogV2.NewListTagConfigurationsOptionalParameters())

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get a list of metrics returns "Success" 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.MetricsAndMetricTagConfigurationsResponse;

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

    try {
      MetricsAndMetricTagConfigurationsResponse result = apiInstance.listTagConfigurations();
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Get a list of metrics returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::ListTagConfigurationsOptionalParams;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .list_tag_configurations(ListTagConfigurationsOptionalParams::default())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get a list of metrics returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

apiInstance
  .listTagConfigurations()
  .then((data: v2.MetricsAndMetricTagConfigurationsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## Query timeseries points{% #query-timeseries-points %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                   |
| ----------------- | ---------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v1/query |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v1/query |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v1/query      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v1/query      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v1/query     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v1/query |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v1/query |

### Overview

Query timeseries points. This endpoint requires the `timeseries_query` permission.

OAuth apps require the `timeseries_query` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Arguments

#### Query Strings

| Name                    | Type    | Description                                                     |
| ----------------------- | ------- | --------------------------------------------------------------- |
| from [*required*]  | integer | Start of the queried time period, seconds since the Unix epoch. |
| to [*required*]    | integer | End of the queried time period, seconds since the Unix epoch.   |
| query [*required*] | string  | Query string.                                                   |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response Object that includes your query and the list of metrics retrieved.

| Parent field | Field        | 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.                                                                                                                                                                                                                                                                     |
| series       | aggr         | string   | Aggregation type.                                                                                                                                                                                                                                                                               |
| series       | display_name | string   | Display name of the metric.                                                                                                                                                                                                                                                                     |
| series       | end          | int64    | End of the time window, milliseconds since Unix epoch.                                                                                                                                                                                                                                          |
| series       | expression   | string   | Metric expression.                                                                                                                                                                                                                                                                              |
| series       | interval     | int64    | Number of milliseconds between data samples.                                                                                                                                                                                                                                                    |
| series       | length       | int64    | Number of data samples.                                                                                                                                                                                                                                                                         |
| series       | metric       | string   | Metric name.                                                                                                                                                                                                                                                                                    |
| series       | pointlist    | [array]  | List of points of the timeseries in milliseconds.                                                                                                                                                                                                                                               |
| series       | query_index  | int64    | The index of the series' query within the request.                                                                                                                                                                                                                                              |
| series       | scope        | string   | Metric scope, comma separated list of tags.                                                                                                                                                                                                                                                     |
| series       | start        | int64    | Start of the time window, milliseconds since Unix epoch.                                                                                                                                                                                                                                        |
| series       | tag_set      | [string] | Unique tags identifying this series.                                                                                                                                                                                                                                                            |
| 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. |
| unit         | family       | string   | Unit family, allows for conversion between units of the same family, for scaling.                                                                                                                                                                                                               |
| unit         | name         | string   | Unit name                                                                                                                                                                                                                                                                                       |
| unit         | plural       | string   | Plural form of the unit name.                                                                                                                                                                                                                                                                   |
| unit         | scale_factor | double   | Factor for scaling between units of the same family.                                                                                                                                                                                                                                            |
| unit         | 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.                                                                                                                                                                                                                                    |

{% /tab %}

{% tab title="Example" %}

```json
{
  "error": "string",
  "from_date": "integer",
  "group_by": [],
  "message": "string",
  "query": "string",
  "res_type": "time_series",
  "series": [
    {
      "aggr": "avg",
      "display_name": "system.cpu.idle",
      "end": "integer",
      "expression": "system.cpu.idle{host:foo,env:test}",
      "interval": "integer",
      "length": "integer",
      "metric": "system.cpu.idle",
      "pointlist": [
        [
          1681683300000,
          77.62145685254418
        ]
      ],
      "query_index": "integer",
      "scope": "host:foo,env:test",
      "start": "integer",
      "tag_set": [],
      "unit": [
        {
          "family": "time",
          "name": "minute",
          "plural": "minutes",
          "scale_factor": 60,
          "short_name": "min"
        }
      ]
    }
  ],
  "status": "ok",
  "to_date": "integer"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Required query argumentsexport from="CHANGE_ME"export to="CHANGE_ME"export query="CHANGE_ME"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/query?from=${from}&to=${to}&query=${query}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Query timeseries points returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.query_metrics(
        _from=int((datetime.now() + relativedelta(days=-1)).timestamp()),
        to=int(datetime.now().timestamp()),
        query="system.cpu.idle{*}",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Query timeseries points returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
p api_instance.query_metrics((Time.now + -1 * 86400).to_i, Time.now.to_i, "system.cpu.idle{*}")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```ruby
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 hour
from = Time.now - 3600
to = Time.now
query = 'system.cpu.idle{*}by{host}'

dog.get_points(query, from, to)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Query timeseries points returns "OK" response

package main

import (
	"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"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewMetricsApi(apiClient)
	resp, r, err := api.QueryMetrics(ctx, time.Now().AddDate(0, 0, -1).Unix(), time.Now().Unix(), "system.cpu.idle{*}")

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryMetrics`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Query timeseries points returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricsQueryResponse;
import java.time.OffsetDateTime;

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

    try {
      MetricsQueryResponse result =
          apiInstance.queryMetrics(
              OffsetDateTime.now().plusDays(-1).toInstant().getEpochSecond(),
              OffsetDateTime.now().toInstant().getEpochSecond(),
              "system.cpu.idle{*}");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#queryMetrics");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
from datadog import initialize, api
import time

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

now = int(time.time())

query = 'system.cpu.idle{*}by{host}'
print(api.Metric.query(start=now - 3600, end=now, query=query))
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
##### 

```rust
// Query timeseries points returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .query_metrics(1636542671, 1636629071, "system.cpu.idle{*}".to_string())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Query timeseries points returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

const params: v1.MetricsApiQueryMetricsRequest = {
  from: Math.round(
    new Date(new Date().getTime() + -1 * 86400 * 1000).getTime() / 1000
  ),
  to: Math.round(new Date().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));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## List tags by metric name{% #list-tags-by-metric-name %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                            |
| ----------------- | ----------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/all-tags |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/all-tags |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/all-tags      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/all-tags      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/all-tags     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/all-tags |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/all-tags |

### Overview

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](https://docs.datadoghq.com/api/latest/scopes.md#metrics) 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.                                                                                                                                              |
| page[limit]                | integer | Maximum number of results to return.                                                                                                                                                              |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object that includes a single metric's indexed and ingested tags.

| Parent field | Field         | Type     | Description                                                               |
| ------------ | ------------- | -------- | ------------------------------------------------------------------------- |
|              | data          | object   | Object for a single metric's indexed and ingested tags.                   |
| data         | attributes    | object   | Object containing the definition of a metric's indexed and ingested tags. |
| attributes   | ingested_tags | [string] | List of ingested tags that are not indexed.                               |
| attributes   | tags          | [string] | List of indexed tags.                                                     |
| data         | id            | string   | The metric name for this resource.                                        |
| data         | type          | enum     | The metric resource type. Allowed enum values: `metrics`                  |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "ingested_tags": [
        "env:prod",
        "service:web",
        "version:1.0"
      ],
      "tags": [
        "sport:golf",
        "sport:football",
        "animal:dog"
      ]
    },
    "id": "test.metric.latency",
    "type": "metrics"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/all-tags" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
List tags by metric name returns "Success" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

# there is a valid "metric_tag_configuration" in the system
METRIC_TAG_CONFIGURATION_DATA_ID = environ["METRIC_TAG_CONFIGURATION_DATA_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_tags_by_metric_name(
        metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# List tags by metric name returns "Success" response

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

# there is a valid "metric_tag_configuration" in the system
METRIC_TAG_CONFIGURATION_DATA_ID = ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]
p api_instance.list_tags_by_metric_name(METRIC_TAG_CONFIGURATION_DATA_ID)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// List tags by metric name returns "Success" 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 "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, *datadogV2.NewListTagsByMetricNameOptionalParameters())

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// List tags by metric name returns "Success" 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.MetricAllTagsResponse;

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

    // there is a valid "metric_tag_configuration" in the system
    String METRIC_TAG_CONFIGURATION_DATA_ID = System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");

    try {
      MetricAllTagsResponse result =
          apiInstance.listTagsByMetricName(METRIC_TAG_CONFIGURATION_DATA_ID);
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// List tags by metric name returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::ListTagsByMetricNameOptionalParams;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    // there is a valid "metric_tag_configuration" in the system
    let metric_tag_configuration_data_id =
        std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .list_tags_by_metric_name(
            metric_tag_configuration_data_id.clone(),
            ListTagsByMetricNameOptionalParams::default(),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * List tags by metric name returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

// there is a valid "metric_tag_configuration" in the system
const METRIC_TAG_CONFIGURATION_DATA_ID = process.env
  .METRIC_TAG_CONFIGURATION_DATA_ID as string;

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## Submit metrics{% #submit-metrics %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                     |
| ----------------- | ------------------------------------------------ |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v1/series |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v1/series |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v1/series      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v1/series      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v1/series     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v1/series |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v1/series |

### Overview



The metrics end-point allows you to post time-series data that can be graphed on Datadog's dashboards. The maximum payload size is 3.2 megabytes (3200000 bytes). Compressed payloads must have a decompressed size of less than 62 megabytes (62914560 bytes).

If you're submitting metrics directly to the Datadog API without using DogStatsD, expect:

- 64 bits for the timestamp
- 64 bits for the value
- 40 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes. However, with the DogStatsD API, compression is applied, which reduces the payload size.



### Arguments

#### Header Parameters

| Name             | Type   | Description                                  |
| ---------------- | ------ | -------------------------------------------- |
| Content-Encoding | string | HTTP header used to compress the media-type. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                    | Type     | Description                                                                                                                                                                                                                                        |
| ------------ | ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | series [*required*] | [object] | A list of timeseries to submit to Datadog.                                                                                                                                                                                                         |
| series       | host                     | string   | The name of the host that produced the metric.                                                                                                                                                                                                     |
| series       | interval                 | int64    | If the type of the metric is rate or count, define the corresponding interval in seconds.                                                                                                                                                          |
| series       | metric [*required*] | string   | The name of the timeseries.                                                                                                                                                                                                                        |
| series       | 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. |
| series       | tags                     | [string] | A list of tags associated with the metric.                                                                                                                                                                                                         |
| series       | type                     | string   | The type of the metric. Valid types are "",`count`, `gauge`, and `rate`.                                                                                                                                                                           |

{% /tab %}

{% tab title="Example" %}
##### 

```json
{
  "series": [
    {
      "metric": "system.load.1",
      "type": "gauge",
      "points": [
        [
          1636629071,
          1.1
        ]
      ],
      "tags": [
        "test:ExampleMetric"
      ]
    }
  ]
}
```

##### 

```json
{
  "series": [
    {
      "metric": "system.load.1",
      "type": "gauge",
      "points": [
        [
          1636629071,
          1.1
        ]
      ],
      "tags": [
        "test:ExampleMetric"
      ]
    }
  ]
}
```

{% /tab %}

### Response

{% tab title="202" %}
Payload accepted
{% tab title="Model" %}
The payload accepted for intake.

| Field  | Type   | Description                       |
| ------ | ------ | --------------------------------- |
| status | string | The status of the intake payload. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "status": "ok"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Authentication error
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="408" %}
Request timeout
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="413" %}
Payload too large
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \## 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 variablesexport NOW="$(date +%s)"\# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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
                        
##### 

```go
// Submit deflate metrics returns "Payload accepted" response

package main

import (
	"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"
)

func main() {
	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))

	if err != 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)
}
```

##### 

```go
// Submit metrics returns "Payload accepted" response

package main

import (
	"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"
)

func main() {
	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())

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
##### 

```java
// Submit deflate metrics returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.api.MetricsApi.SubmitMetricsOptionalParameters;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import com.datadog.api.client.v1.model.MetricContentEncoding;
import com.datadog.api.client.v1.model.MetricsPayload;
import com.datadog.api.client.v1.model.Series;
import java.time.OffsetDateTime;
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);

    MetricsPayload body =
        new MetricsPayload()
            .series(
                Collections.singletonList(
                    new Series()
                        .metric("system.load.1")
                        .type("gauge")
                        .points(
                            Collections.singletonList(
                                Arrays.asList(
                                    Long.valueOf(OffsetDateTime.now().toInstant().getEpochSecond())
                                        .doubleValue(),
                                    1.1)))
                        .tags(Collections.singletonList("test:ExampleMetric"))));

    try {
      IntakePayloadAccepted result =
          apiInstance.submitMetrics(
              body,
              new SubmitMetricsOptionalParameters().contentEncoding(MetricContentEncoding.DEFLATE));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#submitMetrics");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

##### 

```java
// Submit metrics returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import com.datadog.api.client.v1.model.MetricsPayload;
import com.datadog.api.client.v1.model.Series;
import java.time.OffsetDateTime;
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);

    MetricsPayload body =
        new MetricsPayload()
            .series(
                Collections.singletonList(
                    new Series()
                        .metric("system.load.1")
                        .type("gauge")
                        .points(
                            Collections.singletonList(
                                Arrays.asList(
                                    Long.valueOf(OffsetDateTime.now().toInstant().getEpochSecond())
                                        .doubleValue(),
                                    1.1)))
                        .tags(Collections.singletonList("test:ExampleMetric"))));

    try {
      IntakePayloadAccepted result = apiInstance.submitMetrics(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#submitMetrics");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
##### 

```python
from datadog import initialize, api
import time

options = {
    '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 metrics
api.Metric.send([{
    'metric': 'my.series',
    'points': 15
}, {
    'metric': 'my1.series',
    'points': 16
}])
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" python "example.py"
##### 

```python
"""
Submit deflate metrics returns "Payload accepted" response
"""

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.metric_content_encoding import MetricContentEncoding
from datadog_api_client.v1.model.metrics_payload import MetricsPayload
from datadog_api_client.v1.model.point import Point
from datadog_api_client.v1.model.series import Series

body = MetricsPayload(
    series=[
        Series(
            metric="system.load.1",
            type="gauge",
            points=[
                Point(
                    [
                        datetime.now().timestamp(),
                        1.1,
                    ]
                ),
            ],
            tags=[
                "test:ExampleMetric",
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.submit_metrics(content_encoding=MetricContentEncoding.DEFLATE, body=body)

    print(response)
```

##### 

```python
"""
Submit metrics returns "Payload accepted" response
"""

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.metrics_payload import MetricsPayload
from datadog_api_client.v1.model.point import Point
from datadog_api_client.v1.model.series import Series

body = MetricsPayload(
    series=[
        Series(
            metric="system.load.1",
            type="gauge",
            points=[
                Point(
                    [
                        datetime.now().timestamp(),
                        1.1,
                    ]
                ),
            ],
            tags=[
                "test:ExampleMetric",
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.submit_metrics(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
##### 

```ruby
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 values
points = [
    [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 efficient
dog.batch_metrics do
  dog.emit_point('test.api.test_metric',10)
  dog.emit_point('test.api.this_other_metric', 1)
end
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby-legacy) 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.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
##### 

```ruby
# Submit deflate metrics returns "Payload accepted" response

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

body = DatadogAPIClient::V1::MetricsPayload.new({
  series: [
    DatadogAPIClient::V1::Series.new({
      metric: "system.load.1",
      type: "gauge",
      points: [
        [
          Time.now.to_f,
          1.1,
        ],
      ],
      tags: [
        "test:ExampleMetric",
      ],
    }),
  ],
})
opts = {
  content_encoding: MetricContentEncoding::DEFLATE,
}
p api_instance.submit_metrics(body, opts)
```

##### 

```ruby
# Submit metrics returns "Payload accepted" response

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

body = DatadogAPIClient::V1::MetricsPayload.new({
  series: [
    DatadogAPIClient::V1::Series.new({
      metric: "system.load.1",
      type: "gauge",
      points: [
        [
          Time.now.to_f,
          1.1,
        ],
      ],
      tags: [
        "test:ExampleMetric",
      ],
    }),
  ],
})
p api_instance.submit_metrics(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
##### 

```rust
// Submit deflate metrics returns "Payload accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;
use datadog_api_client::datadogV1::api_metrics::SubmitMetricsOptionalParams;
use datadog_api_client::datadogV1::model::MetricContentEncoding;
use datadog_api_client::datadogV1::model::MetricsPayload;
use datadog_api_client::datadogV1::model::Series;

#[tokio::main]
async fn main() {
    let body = MetricsPayload::new(vec![Series::new(
        "system.load.1".to_string(),
        vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
    )
    .tags(vec!["test:ExampleMetric".to_string()])
    .type_("gauge".to_string())]);
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .submit_metrics(
            body,
            SubmitMetricsOptionalParams::default().content_encoding(MetricContentEncoding::DEFLATE),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

##### 

```rust
// Submit metrics returns "Payload accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;
use datadog_api_client::datadogV1::api_metrics::SubmitMetricsOptionalParams;
use datadog_api_client::datadogV1::model::MetricsPayload;
use datadog_api_client::datadogV1::model::Series;

#[tokio::main]
async fn main() {
    let body = MetricsPayload::new(vec![Series::new(
        "system.load.1".to_string(),
        vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
    )
    .tags(vec!["test:ExampleMetric".to_string()])
    .type_("gauge".to_string())]);
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .submit_metrics(body, SubmitMetricsOptionalParams::default())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" cargo run
##### 

```typescript
/**
 * Submit deflate metrics returns "Payload accepted" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

const params: v1.MetricsApiSubmitMetricsRequest = {
  body: {
    series: [
      {
        metric: "system.load.1",
        type: "gauge",
        points: [[Math.round(new Date().getTime() / 1000), 1.1]],
        tags: ["test:ExampleMetric"],
      },
    ],
  },
  contentEncoding: "deflate",
};

apiInstance
  .submitMetrics(params)
  .then((data: v1.IntakePayloadAccepted) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

##### 

```typescript
/**
 * Submit metrics returns "Payload accepted" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

const params: v1.MetricsApiSubmitMetricsRequest = {
  body: {
    series: [
      {
        metric: "system.load.1",
        type: "gauge",
        points: [[Math.round(new Date().getTime() / 1000), 1.1]],
        tags: ["test:ExampleMetric"],
      },
    ],
  },
};

apiInstance
  .submitMetrics(params)
  .then((data: v1.IntakePayloadAccepted) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
{% /tab %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                     |
| ----------------- | ------------------------------------------------ |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/series |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/series |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/series      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/series      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/series     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/series |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/series |

### Overview



The metrics end-point allows you to post time-series data that can be graphed on Datadog's dashboards. The maximum payload size is 500 kilobytes (512000 bytes). Compressed payloads must have a decompressed size of less than 5 megabytes (5242880 bytes).

If you're submitting metrics directly to the Datadog API without using DogStatsD, expect:

- 64 bits for the timestamp
- 64 bits for the value
- 20 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes.

Host name is one of the resources in the Resources field.



### Arguments

#### Header Parameters

| Name             | Type   | Description                                  |
| ---------------- | ------ | -------------------------------------------- |
| Content-Encoding | string | HTTP header used to compress the media-type. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                    | Type     | Description                                                                                                                                                                                                                                         |
| ------------ | ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | series [*required*] | [object] | A list of timeseries to submit to Datadog.                                                                                                                                                                                                          |
| series       | interval                 | int64    | If the type of the metric is rate or count, define the corresponding interval in seconds.                                                                                                                                                           |
| series       | metadata                 | object   | Metadata for the metric.                                                                                                                                                                                                                            |
| metadata     | origin                   | object   | Metric origin information.                                                                                                                                                                                                                          |
| origin       | metric_type              | int32    | The origin metric type code                                                                                                                                                                                                                         |
| origin       | product                  | int32    | The origin product code                                                                                                                                                                                                                             |
| origin       | service                  | int32    | The origin service code                                                                                                                                                                                                                             |
| series       | metric [*required*] | string   | The name of the timeseries.                                                                                                                                                                                                                         |
| series       | 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. |
| points       | 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.                                                                                                       |
| points       | value                    | double   | The numeric value format should be a 64bit float gauge-type value.                                                                                                                                                                                  |
| series       | resources                | [object] | A list of resources to associate with this metric.                                                                                                                                                                                                  |
| resources    | name                     | string   | The name of the resource.                                                                                                                                                                                                                           |
| resources    | type                     | string   | The type of the resource.                                                                                                                                                                                                                           |
| series       | source_type_name         | string   | The source type name.                                                                                                                                                                                                                               |
| series       | tags                     | [string] | A list of tags associated with the metric.                                                                                                                                                                                                          |
| series       | 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`                                                                                                             |
| series       | unit                     | string   | The unit of point value.                                                                                                                                                                                                                            |

{% /tab %}

{% tab title="Example" %}
##### 

```json
{
  "series": [
    {
      "metric": "system.load.1",
      "type": 0,
      "points": [
        {
          "timestamp": 1636629071,
          "value": 0.7
        }
      ],
      "resources": [
        {
          "name": "dummyhost",
          "type": "host"
        }
      ]
    }
  ]
}
```

##### 

```json
{
  "series": [
    {
      "metric": "system.load.1",
      "type": 0,
      "points": [
        {
          "timestamp": 1636629071,
          "value": 0.7
        }
      ]
    }
  ]
}
```

{% /tab %}

### Response

{% tab title="202" %}
Payload accepted
{% tab title="Model" %}
The payload accepted for intake.

| Field  | Type     | Description       |
| ------ | -------- | ----------------- |
| errors | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": []
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Authentication error
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="408" %}
Request timeout
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="413" %}
Payload too large
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \## Dynamic Points
# Post time-series data that can be graphed on Datadog's dashboards.
\# Template variablesexport NOW="$(date +%s)"\# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/series" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "series": [
    {
      "metric": "system.load.1",
      "type": 0,
      "points": [
        {
          "timestamp": 1636629071,
          "value": 0.7
        }
      ],
      "resources": [
        {
          "name": "dummyhost",
          "type": "host"
        }
      ]
    }
  ]
}
EOF
                        
##### 
                          \## 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.
                        
##### 

```go
// Submit metrics returns "Payload accepted" response

package main

import (
	"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"
)

func main() {
	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())

	if err != 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)
}
```

##### 

```go
// Submit metrics with compression returns "Payload accepted" response

package main

import (
	"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"
)

func main() {
	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))

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
##### 

```java
// Submit metrics returns "Payload 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.IntakePayloadAccepted;
import com.datadog.api.client.v2.model.MetricIntakeType;
import com.datadog.api.client.v2.model.MetricPayload;
import com.datadog.api.client.v2.model.MetricPoint;
import com.datadog.api.client.v2.model.MetricResource;
import com.datadog.api.client.v2.model.MetricSeries;
import java.time.OffsetDateTime;
import java.util.Collections;

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

    MetricPayload body =
        new MetricPayload()
            .series(
                Collections.singletonList(
                    new MetricSeries()
                        .metric("system.load.1")
                        .type(MetricIntakeType.UNSPECIFIED)
                        .points(
                            Collections.singletonList(
                                new MetricPoint()
                                    .timestamp(OffsetDateTime.now().toInstant().getEpochSecond())
                                    .value(0.7)))
                        .resources(
                            Collections.singletonList(
                                new MetricResource().name("dummyhost").type("host")))));

    try {
      IntakePayloadAccepted result = apiInstance.submitMetrics(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#submitMetrics");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

##### 

```java
// Submit metrics with compression returns "Payload 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.api.MetricsApi.SubmitMetricsOptionalParameters;
import com.datadog.api.client.v2.model.IntakePayloadAccepted;
import com.datadog.api.client.v2.model.MetricContentEncoding;
import com.datadog.api.client.v2.model.MetricIntakeType;
import com.datadog.api.client.v2.model.MetricPayload;
import com.datadog.api.client.v2.model.MetricPoint;
import com.datadog.api.client.v2.model.MetricSeries;
import java.time.OffsetDateTime;
import java.util.Collections;

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

    MetricPayload body =
        new MetricPayload()
            .series(
                Collections.singletonList(
                    new MetricSeries()
                        .metric("system.load.1")
                        .type(MetricIntakeType.UNSPECIFIED)
                        .points(
                            Collections.singletonList(
                                new MetricPoint()
                                    .timestamp(OffsetDateTime.now().toInstant().getEpochSecond())
                                    .value(0.7)))));

    try {
      IntakePayloadAccepted result =
          apiInstance.submitMetrics(
              body,
              new SubmitMetricsOptionalParameters().contentEncoding(MetricContentEncoding.ZSTD1));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#submitMetrics");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
##### 

```python
"""
Submit metrics returns "Payload accepted" response
"""

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_intake_type import MetricIntakeType
from datadog_api_client.v2.model.metric_payload import MetricPayload
from datadog_api_client.v2.model.metric_point import MetricPoint
from datadog_api_client.v2.model.metric_resource import MetricResource
from datadog_api_client.v2.model.metric_series import MetricSeries

body = MetricPayload(
    series=[
        MetricSeries(
            metric="system.load.1",
            type=MetricIntakeType.UNSPECIFIED,
            points=[
                MetricPoint(
                    timestamp=int(datetime.now().timestamp()),
                    value=0.7,
                ),
            ],
            resources=[
                MetricResource(
                    name="dummyhost",
                    type="host",
                ),
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.submit_metrics(body=body)

    print(response)
```

##### 

```python
"""
Submit metrics with compression returns "Payload accepted" response
"""

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_content_encoding import MetricContentEncoding
from datadog_api_client.v2.model.metric_intake_type import MetricIntakeType
from datadog_api_client.v2.model.metric_payload import MetricPayload
from datadog_api_client.v2.model.metric_point import MetricPoint
from datadog_api_client.v2.model.metric_series import MetricSeries

body = MetricPayload(
    series=[
        MetricSeries(
            metric="system.load.1",
            type=MetricIntakeType.UNSPECIFIED,
            points=[
                MetricPoint(
                    timestamp=int(datetime.now().timestamp()),
                    value=0.7,
                ),
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.submit_metrics(content_encoding=MetricContentEncoding.ZSTD1, body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
##### 

```ruby
# Submit metrics returns "Payload accepted" response

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

body = DatadogAPIClient::V2::MetricPayload.new({
  series: [
    DatadogAPIClient::V2::MetricSeries.new({
      metric: "system.load.1",
      type: DatadogAPIClient::V2::MetricIntakeType::UNSPECIFIED,
      points: [
        DatadogAPIClient::V2::MetricPoint.new({
          timestamp: Time.now.to_i,
          value: 0.7,
        }),
      ],
      resources: [
        DatadogAPIClient::V2::MetricResource.new({
          name: "dummyhost",
          type: "host",
        }),
      ],
    }),
  ],
})
p api_instance.submit_metrics(body)
```

##### 

```ruby
# Submit metrics with compression returns "Payload accepted" response

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

body = DatadogAPIClient::V2::MetricPayload.new({
  series: [
    DatadogAPIClient::V2::MetricSeries.new({
      metric: "system.load.1",
      type: DatadogAPIClient::V2::MetricIntakeType::UNSPECIFIED,
      points: [
        DatadogAPIClient::V2::MetricPoint.new({
          timestamp: Time.now.to_i,
          value: 0.7,
        }),
      ],
    }),
  ],
})
opts = {
  content_encoding: MetricContentEncoding::ZSTD1,
}
p api_instance.submit_metrics(body, opts)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
##### 

```rust
// Submit metrics returns "Payload accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::api_metrics::SubmitMetricsOptionalParams;
use datadog_api_client::datadogV2::model::MetricIntakeType;
use datadog_api_client::datadogV2::model::MetricPayload;
use datadog_api_client::datadogV2::model::MetricPoint;
use datadog_api_client::datadogV2::model::MetricResource;
use datadog_api_client::datadogV2::model::MetricSeries;

#[tokio::main]
async fn main() {
    let body = MetricPayload::new(vec![MetricSeries::new(
        "system.load.1".to_string(),
        vec![MetricPoint::new().timestamp(1636629071).value(0.7 as f64)],
    )
    .resources(vec![MetricResource::new()
        .name("dummyhost".to_string())
        .type_("host".to_string())])
    .type_(MetricIntakeType::UNSPECIFIED)]);
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .submit_metrics(body, SubmitMetricsOptionalParams::default())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

##### 

```rust
// Submit metrics with compression returns "Payload accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::api_metrics::SubmitMetricsOptionalParams;
use datadog_api_client::datadogV2::model::MetricContentEncoding;
use datadog_api_client::datadogV2::model::MetricIntakeType;
use datadog_api_client::datadogV2::model::MetricPayload;
use datadog_api_client::datadogV2::model::MetricPoint;
use datadog_api_client::datadogV2::model::MetricSeries;

#[tokio::main]
async fn main() {
    let body = MetricPayload::new(vec![MetricSeries::new(
        "system.load.1".to_string(),
        vec![MetricPoint::new().timestamp(1636629071).value(0.7 as f64)],
    )
    .type_(MetricIntakeType::UNSPECIFIED)]);
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .submit_metrics(
            body,
            SubmitMetricsOptionalParams::default().content_encoding(MetricContentEncoding::ZSTD1),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" cargo run
##### 

```typescript
/**
 * Submit metrics returns "Payload accepted" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

const params: v2.MetricsApiSubmitMetricsRequest = {
  body: {
    series: [
      {
        metric: "system.load.1",
        type: 0,
        points: [
          {
            timestamp: Math.round(new Date().getTime() / 1000),
            value: 0.7,
          },
        ],
        resources: [
          {
            name: "dummyhost",
            type: "host",
          },
        ],
      },
    ],
  },
};

apiInstance
  .submitMetrics(params)
  .then((data: v2.IntakePayloadAccepted) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

##### 

```typescript
/**
 * Submit metrics with compression returns "Payload accepted" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

const params: v2.MetricsApiSubmitMetricsRequest = {
  body: {
    series: [
      {
        metric: "system.load.1",
        type: 0,
        points: [
          {
            timestamp: Math.round(new Date().getTime() / 1000),
            value: 0.7,
          },
        ],
      },
    ],
  },
  contentEncoding: "zstd1",
};

apiInstance
  .submitMetrics(params)
  .then((data: v2.IntakePayloadAccepted) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
{% /tab %}

## List active tags and aggregations{% #list-active-tags-and-aggregations %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                                         |
| ----------------- | ------------------------------------------------------------------------------------ |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/active-configurations |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/active-configurations |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/active-configurations      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/active-configurations      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/active-configurations     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/active-configurations |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/active-configurations |

### Overview

List tags and aggregations that are actively queried on dashboards, notebooks, monitors, the Metrics Explorer, and using the API for a given metric name. This endpoint requires the `metrics_read` permission.

### 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). Default value is 604,800 (1 week), minimum value is 7200 (2 hours), maximum value is 2,630,000 (1 month). |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object that includes a single metric's actively queried tags and aggregations.

| Parent field        | Field                   | Type     | Description                                                                                                     |
| ------------------- | ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|                     | data                    | object   | Object for a single metric's actively queried tags and aggregations.                                            |
| data                | attributes              | object   | Object containing the definition of a metric's actively queried tags and aggregations.                          |
| attributes          | active_aggregations     | [object] | List of aggregation combinations that have been actively queried.                                               |
| active_aggregations | space [*required*] | enum     | A space aggregation for use in query. Allowed enum values: `avg,max,min,sum`                                    |
| active_aggregations | time [*required*]  | enum     | A time aggregation for use in query. Allowed enum values: `avg,count,max,min,sum`                               |
| attributes          | active_tags             | [string] | List of tag keys that have been actively queried.                                                               |
| data                | id                      | string   | The metric name for this resource.                                                                              |
| data                | type                    | enum     | The metric actively queried configuration resource type. Allowed enum values: `actively_queried_configurations` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "active_aggregations": [
        {
          "space": "sum",
          "time": "sum"
        }
      ],
      "active_tags": [
        "app",
        "datacenter"
      ]
    },
    "id": "test.metric.latency",
    "type": "actively_queried_configurations"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/active-configurations" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
List active tags and aggregations returns "Success" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_active_metric_configurations(
        metric_name="static_test_metric_donotdelete",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# List active tags and aggregations returns "Success" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
p api_instance.list_active_metric_configurations("static_test_metric_donotdelete")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// List active tags and aggregations returns "Success" 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() {
	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())

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// List active tags and aggregations returns "Success" 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.MetricSuggestedTagsAndAggregationsResponse;

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

    try {
      MetricSuggestedTagsAndAggregationsResponse result =
          apiInstance.listActiveMetricConfigurations("static_test_metric_donotdelete");
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// List active tags and aggregations returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::ListActiveMetricConfigurationsOptionalParams;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .list_active_metric_configurations(
            "static_test_metric_donotdelete".to_string(),
            ListActiveMetricConfigurationsOptionalParams::default(),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * List active tags and aggregations returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Submit distribution points{% #submit-distribution-points %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                                  |
| ----------------- | ------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v1/distribution_points |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v1/distribution_points |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v1/distribution_points      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v1/distribution_points      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v1/distribution_points     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v1/distribution_points |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v1/distribution_points |

### Overview

The distribution points end-point allows you to post distribution data that can be graphed on Datadog's dashboards.

### Arguments

#### Header Parameters

| Name             | Type   | Description                                  |
| ---------------- | ------ | -------------------------------------------- |
| Content-Encoding | string | HTTP header used to compress the media-type. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                    | Type     | Description                                                                                                                                                                          |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|              | series [*required*] | [object] | A list of distribution points series to submit to Datadog.                                                                                                                           |
| series       | host                     | string   | The name of the host that produced the distribution point metric.                                                                                                                    |
| series       | metric [*required*] | string   | The name of the distribution points metric.                                                                                                                                          |
| series       | 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. |
| series       | tags                     | [string] | A list of tags associated with the distribution point metric.                                                                                                                        |
| series       | type                     | enum     | The type of the distribution point. Allowed enum values: `distribution`                                                                                                              |

{% /tab %}

{% tab title="Example" %}
##### 

```json
{
  "series": [
    {
      "metric": "system.load.1.dist",
      "points": [
        [
          1636629071,
          [
            1.0,
            2.0
          ]
        ]
      ]
    }
  ]
}
```

##### 

```json
{
  "series": [
    {
      "metric": "system.load.1.dist",
      "points": [
        [
          1636629071,
          [
            1.0,
            2.0
          ]
        ]
      ]
    }
  ]
}
```

{% /tab %}

### Response

{% tab title="202" %}
Payload accepted
{% tab title="Model" %}
The payload accepted for intake.

| Field  | Type   | Description                       |
| ------ | ------ | --------------------------------- |
| status | string | The status of the intake payload. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "status": "ok"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Authentication error
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="408" %}
Request timeout
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="413" %}
Payload too large
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \## 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 variablesexport NOW="$(date +%s)"\# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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
                        
##### 

```go
// Submit deflate distribution points returns "Payload accepted" response

package main

import (
	"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"
)

func main() {
	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))

	if err != 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)
}
```

##### 

```go
// Submit distribution points returns "Payload accepted" response

package main

import (
	"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"
)

func main() {
	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())

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
##### 

```java
// Submit deflate distribution points returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.api.MetricsApi.SubmitDistributionPointsOptionalParameters;
import com.datadog.api.client.v1.model.DistributionPointItem;
import com.datadog.api.client.v1.model.DistributionPointsContentEncoding;
import com.datadog.api.client.v1.model.DistributionPointsPayload;
import com.datadog.api.client.v1.model.DistributionPointsSeries;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import java.time.OffsetDateTime;
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);

    DistributionPointsPayload body =
        new DistributionPointsPayload()
            .series(
                Collections.singletonList(
                    new DistributionPointsSeries()
                        .metric("system.load.1.dist")
                        .points(
                            Collections.singletonList(
                                Arrays.asList(
                                    new DistributionPointItem(
                                        Long.valueOf(
                                                OffsetDateTime.now().toInstant().getEpochSecond())
                                            .doubleValue()),
                                    new DistributionPointItem(Arrays.asList(1.0, 2.0)))))));

    try {
      IntakePayloadAccepted result =
          apiInstance.submitDistributionPoints(
              body,
              new SubmitDistributionPointsOptionalParameters()
                  .contentEncoding(DistributionPointsContentEncoding.DEFLATE));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#submitDistributionPoints");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

##### 

```java
// Submit distribution points returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.DistributionPointItem;
import com.datadog.api.client.v1.model.DistributionPointsPayload;
import com.datadog.api.client.v1.model.DistributionPointsSeries;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import java.time.OffsetDateTime;
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);

    DistributionPointsPayload body =
        new DistributionPointsPayload()
            .series(
                Collections.singletonList(
                    new DistributionPointsSeries()
                        .metric("system.load.1.dist")
                        .points(
                            Collections.singletonList(
                                Arrays.asList(
                                    new DistributionPointItem(
                                        Long.valueOf(
                                                OffsetDateTime.now().toInstant().getEpochSecond())
                                            .doubleValue()),
                                    new DistributionPointItem(Arrays.asList(1.0, 2.0)))))));

    try {
      IntakePayloadAccepted result = apiInstance.submitDistributionPoints(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#submitDistributionPoints");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
##### 

```python
"""
Submit deflate distribution points returns "Payload accepted" response
"""

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.distribution_point import DistributionPoint
from datadog_api_client.v1.model.distribution_points_content_encoding import DistributionPointsContentEncoding
from datadog_api_client.v1.model.distribution_points_payload import DistributionPointsPayload
from datadog_api_client.v1.model.distribution_points_series import DistributionPointsSeries

body = DistributionPointsPayload(
    series=[
        DistributionPointsSeries(
            metric="system.load.1.dist",
            points=[
                DistributionPoint(
                    [
                        datetime.now().timestamp(),
                        [1.0, 2.0],
                    ]
                ),
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.submit_distribution_points(
        content_encoding=DistributionPointsContentEncoding.DEFLATE, body=body
    )

    print(response)
```

##### 

```python
"""
Submit distribution points returns "Payload accepted" response
"""

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.distribution_point import DistributionPoint
from datadog_api_client.v1.model.distribution_points_payload import DistributionPointsPayload
from datadog_api_client.v1.model.distribution_points_series import DistributionPointsSeries

body = DistributionPointsPayload(
    series=[
        DistributionPointsSeries(
            metric="system.load.1.dist",
            points=[
                DistributionPoint(
                    [
                        datetime.now().timestamp(),
                        [1.0, 2.0],
                    ]
                ),
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.submit_distribution_points(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
##### 

```ruby
# Submit deflate distribution points returns "Payload accepted" response

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

body = DatadogAPIClient::V1::DistributionPointsPayload.new({
  series: [
    DatadogAPIClient::V1::DistributionPointsSeries.new({
      metric: "system.load.1.dist",
      points: [
        [
          Time.now,
          [
            1.0,
            2.0,
          ],
        ],
      ],
    }),
  ],
})
opts = {
  content_encoding: DistributionPointsContentEncoding::DEFLATE,
}
p api_instance.submit_distribution_points(body, opts)
```

##### 

```ruby
# Submit distribution points returns "Payload accepted" response

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

body = DatadogAPIClient::V1::DistributionPointsPayload.new({
  series: [
    DatadogAPIClient::V1::DistributionPointsSeries.new({
      metric: "system.load.1.dist",
      points: [
        [
          Time.now,
          [
            1.0,
            2.0,
          ],
        ],
      ],
    }),
  ],
})
p api_instance.submit_distribution_points(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
##### 

```rust
// Submit deflate distribution points returns "Payload accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;
use datadog_api_client::datadogV1::api_metrics::SubmitDistributionPointsOptionalParams;
use datadog_api_client::datadogV1::model::DistributionPointItem;
use datadog_api_client::datadogV1::model::DistributionPointsContentEncoding;
use datadog_api_client::datadogV1::model::DistributionPointsPayload;
use datadog_api_client::datadogV1::model::DistributionPointsSeries;

#[tokio::main]
async fn main() {
    let body = DistributionPointsPayload::new(vec![DistributionPointsSeries::new(
        "system.load.1.dist".to_string(),
        vec![vec![
            DistributionPointItem::DistributionPointTimestamp(1636629071.0 as f64),
            DistributionPointItem::DistributionPointData(vec![1.0, 2.0]),
        ]],
    )]);
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .submit_distribution_points(
            body,
            SubmitDistributionPointsOptionalParams::default()
                .content_encoding(DistributionPointsContentEncoding::DEFLATE),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

##### 

```rust
// Submit distribution points returns "Payload accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_metrics::MetricsAPI;
use datadog_api_client::datadogV1::api_metrics::SubmitDistributionPointsOptionalParams;
use datadog_api_client::datadogV1::model::DistributionPointItem;
use datadog_api_client::datadogV1::model::DistributionPointsPayload;
use datadog_api_client::datadogV1::model::DistributionPointsSeries;

#[tokio::main]
async fn main() {
    let body = DistributionPointsPayload::new(vec![DistributionPointsSeries::new(
        "system.load.1.dist".to_string(),
        vec![vec![
            DistributionPointItem::DistributionPointTimestamp(1636629071.0 as f64),
            DistributionPointItem::DistributionPointData(vec![1.0, 2.0]),
        ]],
    )]);
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .submit_distribution_points(body, SubmitDistributionPointsOptionalParams::default())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" cargo run
##### 

```typescript
/**
 * Submit deflate distribution points returns "Payload accepted" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

const params: v1.MetricsApiSubmitDistributionPointsRequest = {
  body: {
    series: [
      {
        metric: "system.load.1.dist",
        points: [[Math.round(new Date().getTime() / 1000), [1.0, 2.0]]],
      },
    ],
  },
  contentEncoding: "deflate",
};

apiInstance
  .submitDistributionPoints(params)
  .then((data: v1.IntakePayloadAccepted) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

##### 

```typescript
/**
 * Submit distribution points returns "Payload accepted" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

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

const params: v1.MetricsApiSubmitDistributionPointsRequest = {
  body: {
    series: [
      {
        metric: "system.load.1.dist",
        points: [[Math.round(new Date().getTime() / 1000), [1.0, 2.0]]],
      },
    ],
  },
};

apiInstance
  .submitDistributionPoints(params)
  .then((data: v1.IntakePayloadAccepted) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
{% /tab %}

## List distinct metric volumes by metric name{% #list-distinct-metric-volumes-by-metric-name %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                           |
| ----------------- | ---------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/volumes |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/volumes |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/volumes      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/volumes      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/volumes     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/volumes |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/volumes |

### Overview



View distinct metrics volumes for the given metric name.

Custom metrics generated in-app from other products will return `null` for ingested volumes.



### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object which includes a single metric's volume.

| Parent field | Field           | Type          | Description                                                                        |
| ------------ | --------------- | ------------- | ---------------------------------------------------------------------------------- |
|              | data            |  <oneOf> | Possible response objects for a metric's volume.                                   |
| data         | Option 1        | object        | Object for a single metric's distinct volume.                                      |
| Option 1     | attributes      | object        | Object containing the definition of a metric's distinct volume.                    |
| attributes   | distinct_volume | int64         | Distinct volume for the given metric.                                              |
| Option 1     | id              | string        | The metric name for this resource.                                                 |
| Option 1     | type            | enum          | The metric distinct volume type. Allowed enum values: `distinct_metric_volumes`    |
| data         | Option 2        | object        | Object for a single metric's ingested and indexed volume.                          |
| Option 2     | attributes      | object        | Object containing the definition of a metric's ingested and indexed volume.        |
| attributes   | indexed_volume  | int64         | Indexed volume for the given metric.                                               |
| attributes   | ingested_volume | int64         | Ingested volume for the given metric.                                              |
| Option 2     | id              | string        | The metric name for this resource.                                                 |
| Option 2     | type            | enum          | The metric ingested and indexed volume type. Allowed enum values: `metric_volumes` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "distinct_volume": 10
    },
    "id": "test.metric.latency",
    "type": "distinct_metric_volumes"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/volumes" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
List distinct metric volumes by metric name returns "Success" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_volumes_by_metric_name(
        metric_name="static_test_metric_donotdelete",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# List distinct metric volumes by metric name returns "Success" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
p api_instance.list_volumes_by_metric_name("static_test_metric_donotdelete")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// List distinct metric volumes by metric name returns "Success" 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() {
	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")

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// List distinct metric volumes by metric name returns "Success" 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.MetricVolumesResponse;

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

    try {
      MetricVolumesResponse result =
          apiInstance.listVolumesByMetricName("static_test_metric_donotdelete");
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// List distinct metric volumes by metric name returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .list_volumes_by_metric_name("static_test_metric_donotdelete".to_string())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * List distinct metric volumes by metric name returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Configure tags for multiple metrics{% #configure-tags-for-multiple-metrics %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                       |
| ----------------- | ------------------------------------------------------------------ |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/metrics/config/bulk-tags |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/metrics/config/bulk-tags |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/metrics/config/bulk-tags      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/metrics/config/bulk-tags      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/metrics/config/bulk-tags     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/metrics/config/bulk-tags |
| us5.datadoghq.com | POST https://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. This endpoint requires the `metric_tags_write` permission.

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                                | Type     | Description                                                                                                                                                                                                                                                                       |
| ------------ | ------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]               | object   | Request object to bulk configure tags for metrics matching the given prefix.                                                                                                                                                                                                      |
| data         | attributes                           | object   | Optional parameters for bulk creating metric tag configurations.                                                                                                                                                                                                                  |
| attributes   | emails                               | [string] | A list of account emails to notify when the configuration is applied.                                                                                                                                                                                                             |
| attributes   | 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.                                         |
| attributes   | include_actively_queried_tags_window | double   | When provided, all tags that have been actively queried are configured (and, therefore, remain queryable) for each metric that matches the given prefix. Minimum value is 1 second, and maximum value is 7,776,000 seconds (90 days).                                             |
| attributes   | override_existing_configurations     | boolean  | When set to true, the configuration overrides any existing configurations for the given metric with the new set of tags in this configuration request. If false, old configurations are kept and are merged with the set of tags in this configuration request. Defaults to true. |
| attributes   | tags                                 | [string] | A list of tag names to apply to the configuration.                                                                                                                                                                                                                                |
| data         | id [*required*]                 | string   | A text prefix to match against metric names.                                                                                                                                                                                                                                      |
| data         | type [*required*]               | enum     | The metric bulk configure tags resource. Allowed enum values: `metric_bulk_configure_tags`                                                                                                                                                                                        |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "emails": [
        "string"
      ],
      "tags": [
        "test",
        "examplemetric"
      ]
    },
    "id": "system.load.1",
    "type": "metric_bulk_configure_tags"
  }
}
```

{% /tab %}

### Response

{% tab title="202" %}
Accepted
{% tab title="Model" %}
Wrapper for a single bulk tag configuration status response.

| Parent field | 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.                                                                                                 |
| data         | attributes             | object   | Optional attributes for the status of a bulk tag configuration request.                                                                                                                                                |
| attributes   | emails                 | [string] | A list of account emails to notify when the configuration is applied.                                                                                                                                                  |
| attributes   | 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. |
| attributes   | status                 | string   | The status of the request.                                                                                                                                                                                             |
| attributes   | tags                   | [string] | A list of tag names to apply to the configuration.                                                                                                                                                                     |
| data         | id [*required*]   | string   | A text prefix to match against metric names.                                                                                                                                                                           |
| data         | type [*required*] | enum     | The metric bulk configure tags resource. Allowed enum values: `metric_bulk_configure_tags`                                                                                                                             |

{% /tab %}

{% tab title="Example" %}

```json
{
  "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"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/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": [
        "string"
      ],
      "tags": [
        "test",
        "examplemetric"
      ]
    },
    "id": "system.load.1",
    "type": "metric_bulk_configure_tags"
  }
}
EOF
                        
##### 

```go
// 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](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// 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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```python
"""
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](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# 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](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```rust
// 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](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * 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](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Delete tags for multiple metrics{% #delete-tags-for-multiple-metrics %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                         |
| ----------------- | -------------------------------------------------------------------- |
| ap1.datadoghq.com | DELETE https://api.ap1.datadoghq.com/api/v2/metrics/config/bulk-tags |
| ap2.datadoghq.com | DELETE https://api.ap2.datadoghq.com/api/v2/metrics/config/bulk-tags |
| app.datadoghq.eu  | DELETE https://api.datadoghq.eu/api/v2/metrics/config/bulk-tags      |
| app.ddog-gov.com  | DELETE https://api.ddog-gov.com/api/v2/metrics/config/bulk-tags      |
| app.datadoghq.com | DELETE https://api.datadoghq.com/api/v2/metrics/config/bulk-tags     |
| us3.datadoghq.com | DELETE https://api.us3.datadoghq.com/api/v2/metrics/config/bulk-tags |
| us5.datadoghq.com | DELETE https://api.us5.datadoghq.com/api/v2/metrics/config/bulk-tags |

### Overview

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)



{% tab title="Model" %}

| Parent field | Field                  | Type     | Description                                                                                 |
| ------------ | ---------------------- | -------- | ------------------------------------------------------------------------------------------- |
|              | data [*required*] | object   | Request object to bulk delete all tag configurations for metrics matching the given prefix. |
| data         | attributes             | object   | Optional parameters for bulk deleting metric tag configurations.                            |
| attributes   | emails                 | [string] | A list of account emails to notify when the configuration is applied.                       |
| data         | id [*required*]   | string   | A text prefix to match against metric names.                                                |
| data         | type [*required*] | enum     | The metric bulk configure tags resource. Allowed enum values: `metric_bulk_configure_tags`  |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

### Response

{% tab title="202" %}
Accepted
{% tab title="Model" %}
Wrapper for a single bulk tag configuration status response.

| Parent field | 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.                                                                                                 |
| data         | attributes             | object   | Optional attributes for the status of a bulk tag configuration request.                                                                                                                                                |
| attributes   | emails                 | [string] | A list of account emails to notify when the configuration is applied.                                                                                                                                                  |
| attributes   | 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. |
| attributes   | status                 | string   | The status of the request.                                                                                                                                                                                             |
| attributes   | tags                   | [string] | A list of tag names to apply to the configuration.                                                                                                                                                                     |
| data         | id [*required*]   | string   | A text prefix to match against metric names.                                                                                                                                                                           |
| data         | type [*required*] | enum     | The metric bulk configure tags resource. Allowed enum values: `metric_bulk_configure_tags`                                                                                                                             |

{% /tab %}

{% tab title="Example" %}

```json
{
  "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"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Curl commandcurl -X DELETE "https://api.ap1.datadoghq.com"https://api.ap2.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/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": {
    "id": "kafka.lag",
    "type": "metric_bulk_configure_tags"
  }
}
EOF
                
##### 

```python
"""
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](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# 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](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// 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](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// 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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// 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](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * 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](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Tag Configuration Cardinality Estimator{% #tag-configuration-cardinality-estimator %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                            |
| ----------------- | ----------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/estimate |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/estimate |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/estimate      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/estimate      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/estimate     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/estimate |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/estimate |

### Overview

Returns the estimated cardinality for a metric with a given tag, percentile and number of aggregations configuration using Metrics without Limits™.

### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

#### Query Strings

| Name                     | Type    | Description                                                                                                                 |
| ------------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| filter[groups]           | string  | Filtered tag keys that the metric is configured to query with.                                                              |
| filter[hours_ago]        | integer | The number of hours of look back (from now) to estimate cardinality with. If unspecified, it defaults to 0 hours.           |
| filter[num_aggregations] | integer | Deprecated. Number of aggregations has no impact on volume.                                                                 |
| filter[pct]              | boolean | A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators. |
| filter[timespan_h]       | integer | A window, in hours, from the look back to estimate cardinality with. The minimum and default is 1 hour.                     |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object that includes metric cardinality estimates.

| Parent field | Field                   | Type      | Description                                                                                                                                                                                                                                                                                                                              |
| ------------ | ----------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                    | object    | Object for a metric cardinality estimate.                                                                                                                                                                                                                                                                                                |
| data         | attributes              | object    | Object containing the definition of a metric estimate attribute.                                                                                                                                                                                                                                                                         |
| attributes   | 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` |
| attributes   | estimated_at            | date-time | Timestamp when the cardinality estimate was requested.                                                                                                                                                                                                                                                                                   |
| attributes   | estimated_output_series | int64     | Estimated cardinality of the metric based on the queried configuration.                                                                                                                                                                                                                                                                  |
| data         | id                      | string    | The metric name for this resource.                                                                                                                                                                                                                                                                                                       |
| data         | type                    | enum      | The metric estimate resource type. Allowed enum values: `metric_cardinality_estimate`                                                                                                                                                                                                                                                    |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "estimate_type": "distribution",
      "estimated_at": "2022-04-27T09:48:37.463835Z",
      "estimated_output_series": 50
    },
    "id": "test.metric.latency",
    "type": "metric_cardinality_estimate"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
API error response.
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
API error response.
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
API error response.
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/estimate" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Tag Configuration Cardinality Estimator returns "Success" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.estimate_metrics_output_series(
        metric_name="system.cpu.idle",
        filter_groups="app,host",
        filter_num_aggregations=4,
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Tag Configuration Cardinality Estimator returns "Success" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
opts = {
  filter_groups: "app,host",
  filter_num_aggregations: 4,
}
p api_instance.estimate_metrics_output_series("system.cpu.idle", opts)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Tag Configuration Cardinality Estimator returns "Success" 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() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMetricsApi(apiClient)
	resp, r, err := api.EstimateMetricsOutputSeries(ctx, "system.cpu.idle", *datadogV2.NewEstimateMetricsOutputSeriesOptionalParameters().WithFilterGroups("app,host").WithFilterNumAggregations(4))

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.EstimateMetricsOutputSeries`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Tag Configuration Cardinality Estimator returns "Success" 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.api.MetricsApi.EstimateMetricsOutputSeriesOptionalParameters;
import com.datadog.api.client.v2.model.MetricEstimateResponse;

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

    try {
      MetricEstimateResponse result =
          apiInstance.estimateMetricsOutputSeries(
              "system.cpu.idle",
              new EstimateMetricsOutputSeriesOptionalParameters()
                  .filterGroups("app,host")
                  .filterNumAggregations(4));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#estimateMetricsOutputSeries");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Tag Configuration Cardinality Estimator returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::EstimateMetricsOutputSeriesOptionalParams;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .estimate_metrics_output_series(
            "system.cpu.idle".to_string(),
            EstimateMetricsOutputSeriesOptionalParams::default()
                .filter_groups("app,host".to_string())
                .filter_num_aggregations(4),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Tag Configuration Cardinality Estimator returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Related Assets to a Metric{% #related-assets-to-a-metric %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                          |
| ----------------- | --------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/assets |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/assets |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/assets      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/assets      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/assets     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/assets |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/assets |

### Overview

Returns dashboards, monitors, notebooks, and SLOs that a metric is stored in, if any. Updated every 24 hours.

### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object that includes related dashboards, monitors, notebooks, and SLOs.

| Parent field  | Field                  | Type            | Description                                                                                |
| ------------- | ---------------------- | --------------- | ------------------------------------------------------------------------------------------ |
|               | data                   | object          | Metric assets response data.                                                               |
| data          | id [*required*]   | string          | The metric name for this resource.                                                         |
| data          | relationships          | object          | Relationships to assets related to the metric.                                             |
| relationships | dashboards             | object          | An object containing the list of dashboards that can be referenced in the `included` data. |
| dashboards    | data                   | [object]        | A list of dashboards that can be referenced in the `included` data.                        |
| data          | id                     | string          | The related dashboard's ID.                                                                |
| data          | type                   | enum            | Dashboard resource type. Allowed enum values: `dashboards`                                 |
| relationships | monitors               | object          | A object containing the list of monitors that can be referenced in the `included` data.    |
| monitors      | data                   | [object]        | A list of monitors that can be referenced in the `included` data.                          |
| data          | id                     | string          | The related monitor's ID.                                                                  |
| data          | type                   | enum            | Monitor resource type. Allowed enum values: `monitors`                                     |
| relationships | notebooks              | object          | An object containing the list of notebooks that can be referenced in the `included` data.  |
| notebooks     | data                   | [object]        | A list of notebooks that can be referenced in the `included` data.                         |
| data          | id                     | string          | The related notebook's ID.                                                                 |
| data          | type                   | enum            | Notebook resource type. Allowed enum values: `notebooks`                                   |
| relationships | slos                   | object          | An object containing a list of SLOs that can be referenced in the `included` data.         |
| slos          | data                   | [object]        | A list of SLOs that can be referenced in the `included` data.                              |
| data          | id                     | string          | The SLO ID.                                                                                |
| data          | type                   | enum            | SLO resource type. Allowed enum values: `slos`                                             |
| data          | type [*required*] | enum            | The metric resource type. Allowed enum values: `metrics`                                   |
|               | included               | [ <oneOf>] | Array of objects related to the metric assets.                                             |
| included      | Option 1               | object          | A dashboard object with title and popularity.                                              |
| Option 1      | attributes             | object          | Attributes related to the dashboard, including title, popularity, and url.                 |
| attributes    | popularity             | double          | Value from 0 to 5 that ranks popularity of the dashboard.                                  |
| attributes    | tags                   | [string]        | List of tag keys used in the asset.                                                        |
| attributes    | title                  | string          | Title of the asset.                                                                        |
| attributes    | url                    | string          | URL path of the asset.                                                                     |
| Option 1      | id [*required*]   | string          | The related dashboard's ID.                                                                |
| Option 1      | type [*required*] | enum            | Dashboard resource type. Allowed enum values: `dashboards`                                 |
| included      | Option 2               | object          | A monitor object with title.                                                               |
| Option 2      | attributes             | object          | Assets related to the object, including title, url, and tags.                              |
| attributes    | tags                   | [string]        | List of tag keys used in the asset.                                                        |
| attributes    | title                  | string          | Title of the asset.                                                                        |
| attributes    | url                    | string          | URL path of the asset.                                                                     |
| Option 2      | id [*required*]   | string          | The related monitor's ID.                                                                  |
| Option 2      | type [*required*] | enum            | Monitor resource type. Allowed enum values: `monitors`                                     |
| included      | Option 3               | object          | A notebook object with title.                                                              |
| Option 3      | attributes             | object          | Assets related to the object, including title, url, and tags.                              |
| attributes    | tags                   | [string]        | List of tag keys used in the asset.                                                        |
| attributes    | title                  | string          | Title of the asset.                                                                        |
| attributes    | url                    | string          | URL path of the asset.                                                                     |
| Option 3      | id [*required*]   | string          | The related notebook's ID.                                                                 |
| Option 3      | type [*required*] | enum            | Notebook resource type. Allowed enum values: `notebooks`                                   |
| included      | Option 4               | object          | A SLO object with title.                                                                   |
| Option 4      | attributes             | object          | Assets related to the object, including title, url, and tags.                              |
| attributes    | tags                   | [string]        | List of tag keys used in the asset.                                                        |
| attributes    | title                  | string          | Title of the asset.                                                                        |
| attributes    | url                    | string          | URL path of the asset.                                                                     |
| Option 4      | id [*required*]   | string          | The SLO ID.                                                                                |
| Option 4      | type [*required*] | enum            | SLO resource type. Allowed enum values: `slos`                                             |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "id": "test.metric.latency",
    "relationships": {
      "dashboards": {
        "data": [
          {
            "id": "xxx-yyy-zzz",
            "type": "dashboards"
          }
        ]
      },
      "monitors": {
        "data": [
          {
            "id": "1775073",
            "type": "monitors"
          }
        ]
      },
      "notebooks": {
        "data": [
          {
            "id": "12345",
            "type": "notebooks"
          }
        ]
      },
      "slos": {
        "data": [
          {
            "id": "9ffef113b389520db54391d67d652dfb",
            "type": "slos"
          }
        ]
      }
    },
    "type": "metrics"
  },
  "included": [
    {
      "attributes": {
        "popularity": "number",
        "tags": [
          "env",
          "service",
          "host",
          "datacenter"
        ],
        "title": "string",
        "url": "string"
      },
      "id": "xxx-yyy-zzz",
      "type": "dashboards"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
API error response.
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
API error response.
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="404" %}
API error response.
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/assets" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Related Assets to a Metric returns "Success" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.list_metric_assets(
        metric_name="system.cpu.user",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Related Assets to a Metric returns "Success" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
p api_instance.list_metric_assets("system.cpu.user")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Related Assets to a Metric returns "Success" 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() {
	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")

	if err != 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)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Related Assets to a Metric returns "Success" 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.MetricAssetsResponse;

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

    try {
      MetricAssetsResponse result = apiInstance.listMetricAssets("system.cpu.user");
      System.out.println(result);
    } catch (ApiException e) {
      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();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Related Assets to a Metric returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.list_metric_assets("system.cpu.user".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Related Assets to a Metric returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## Get tag key cardinality details{% #get-tag-key-cardinality-details %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                                     |
| ----------------- | -------------------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tag-cardinalities |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/tag-cardinalities |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tag-cardinalities      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/metrics/{metric_name}/tag-cardinalities      |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/metrics/{metric_name}/tag-cardinalities     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tag-cardinalities |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tag-cardinalities |

### Overview

Returns the cardinality details of tags for a specific metric. This endpoint requires the `metrics_read` permission.

### Arguments

#### Path Parameters

| Name                          | Type   | Description             |
| ----------------------------- | ------ | ----------------------- |
| metric_name [*required*] | string | The name of the metric. |

### Response

{% tab title="200" %}
Success
{% tab title="Model" %}
Response object that includes an array of objects representing the cardinality details of a metric's tags.

| Parent field | Field             | Type     | Description                                                                                                            |
| ------------ | ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
|              | data              | [object] | A list of tag cardinalities associated with the given metric.                                                          |
| data         | attributes        | object   | An object containing properties related to the tag key                                                                 |
| attributes   | cardinality_delta | int64    | This describes the recent change in the tag keys cardinality                                                           |
| data         | id                | string   | The name of the tag key.                                                                                               |
| data         | type              | string   | This describes the endpoint action.                                                                                    |
|              | meta              | object   | Response metadata object.                                                                                              |
| meta         | metric_name       | string   | The name of metric for which the tag cardinalities are returned. This matches the metric name provided in the request. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "attributes": {
        "cardinality_delta": "integer"
      },
      "id": "string",
      "type": "string"
    }
  ],
  "meta": {
    "metric_name": "string"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too Many Requests
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parametersexport metric_name="dist.http.endpoint.request"\# Curl commandcurl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/metrics/${metric_name}/tag-cardinalities" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
                
##### 

```python
"""
Get tag key cardinality details returns "Success" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.get_metric_tag_cardinality_details(
        metric_name="metric_name",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Get tag key cardinality details returns "Success" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
p api_instance.get_metric_tag_cardinality_details("metric_name")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Get tag key cardinality details returns "Success" 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() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMetricsApi(apiClient)
	resp, r, err := api.GetMetricTagCardinalityDetails(ctx, "metric_name")

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.GetMetricTagCardinalityDetails`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Get tag key cardinality details returns "Success" 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.MetricTagCardinalitiesResponse;

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

    try {
      MetricTagCardinalitiesResponse result =
          apiInstance.getMetricTagCardinalityDetails("dist.http.endpoint.request");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#getMetricTagCardinalityDetails");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Get tag key cardinality details returns "Success" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api
        .get_metric_tag_cardinality_details("metric_name".to_string())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Get tag key cardinality details returns "Success" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

const params: v2.MetricsApiGetMetricTagCardinalityDetailsRequest = {
  metricName: "metric_name",
};

apiInstance
  .getMetricTagCardinalityDetails(params)
  .then((data: v2.MetricTagCardinalitiesResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}

## Query timeseries data across multiple products{% #query-timeseries-data-across-multiple-products %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                               |
| ----------------- | ---------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/query/timeseries |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/query/timeseries |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/query/timeseries      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/query/timeseries      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/query/timeseries     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/query/timeseries |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/query/timeseries |

### Overview

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](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                            | Type            | Description                                                                                                                                                                                                                                                                                                                           |
| ------------ | -------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]           | object          | A single timeseries query to be executed.                                                                                                                                                                                                                                                                                             |
| data         | attributes [*required*]     | object          | The object describing a timeseries formula request.                                                                                                                                                                                                                                                                                   |
| attributes   | formulas                         | [object]        | List of formulas to be calculated and returned as responses.                                                                                                                                                                                                                                                                          |
| formulas     | formula [*required*]        | string          | Formula string, referencing one or more queries with their name property.                                                                                                                                                                                                                                                             |
| formulas     | 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.                                                                                                                                                                             |
| limit        | count                            | int32           | The number of results to which to limit.                                                                                                                                                                                                                                                                                              |
| limit        | order                            | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| attributes   | from [*required*]           | int64           | Start date (inclusive) of the query in milliseconds since the Unix epoch.                                                                                                                                                                                                                                                             |
| attributes   | 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.                                                                                                                          |
| attributes   | queries [*required*]        | [ <oneOf>] | List of queries to be run and used as inputs to the formulas.                                                                                                                                                                                                                                                                         |
| queries      | Option 1                         | object          | A query against Datadog custom metrics or Cloud Cost data sources.                                                                                                                                                                                                                                                                    |
| Option 1     | data_source [*required*]    | enum            | A data source that is powered by the Metrics platform. Allowed enum values: `metrics,cloud_cost`                                                                                                                                                                                                                                      |
| Option 1     | name                             | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 1     | query [*required*]          | string          | A classic metrics query string.                                                                                                                                                                                                                                                                                                       |
| queries      | Option 2                         | object          | An individual timeseries query for logs, RUM, traces, CI pipelines, security signals, and other event-based data sources. Use this query type for any data source powered by the Events Platform. See the data_source field for the full list of supported sources.                                                                   |
| Option 2     | compute [*required*]        | object          | The instructions for what to compute for this query.                                                                                                                                                                                                                                                                                  |
| compute      | 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`                                                                                                                                                                                  |
| compute      | interval                         | int64           | Interval for compute in milliseconds.                                                                                                                                                                                                                                                                                                 |
| compute      | metric                           | string          | The "measure" attribute on which to perform the computation.                                                                                                                                                                                                                                                                          |
| Option 2     | data_source [*required*]    | enum            | A data source that is powered by the Events Platform. Allowed enum values: `logs,spans,network,rum,security_signals,profiles,audit,events,ci_tests,ci_pipelines`                                                                                                                                                                      |
| Option 2     | group_by                         | [object]        | The list of facets on which to split results.                                                                                                                                                                                                                                                                                         |
| group_by     | facet [*required*]          | string          | The facet by which to split groups.                                                                                                                                                                                                                                                                                                   |
| group_by     | 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.                                                                                                                                                                |
| group_by     | sort                             | object          | The dimension by which to sort a query's results.                                                                                                                                                                                                                                                                                     |
| sort         | 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`                                                                                                                                                                                  |
| sort         | metric                           | string          | The metric's calculated value which should be used to define the sort order of a query's results.                                                                                                                                                                                                                                     |
| sort         | order                            | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| sort         | type                             | enum            | The type of sort to use on the calculated value. Allowed enum values: `alphabetical,measure`                                                                                                                                                                                                                                          |
| Option 2     | indexes                          | [string]        | The indexes in which to search.                                                                                                                                                                                                                                                                                                       |
| Option 2     | name                             | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 2     | search                           | object          | Configuration of the search/filter for an events query.                                                                                                                                                                                                                                                                               |
| search       | query                            | string          | The search/filter string for an events query.                                                                                                                                                                                                                                                                                         |
| queries      | Option 3                         | object          | A query for APM resource statistics such as latency, error rate, and hit count, grouped by resource name.                                                                                                                                                                                                                             |
| Option 3     | data_source [*required*]    | enum            | A data source for APM resource statistics queries. Allowed enum values: `apm_resource_stats`                                                                                                                                                                                                                                          |
| Option 3     | env [*required*]            | string          | The environment to query.                                                                                                                                                                                                                                                                                                             |
| Option 3     | group_by                         | [string]        | Tag keys to group results by.                                                                                                                                                                                                                                                                                                         |
| Option 3     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 3     | operation_name                   | string          | The APM operation name.                                                                                                                                                                                                                                                                                                               |
| Option 3     | primary_tag_name                 | string          | Name of the second primary tag used within APM. Required when `primary_tag_value` is specified. See [https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog](https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope.md#add-a-second-primary-tag-in-datadog)      |
| Option 3     | primary_tag_value                | string          | Value of the second primary tag by which to filter APM data. `primary_tag_name` must also be specified.                                                                                                                                                                                                                               |
| Option 3     | resource_name                    | string          | The resource name to filter by.                                                                                                                                                                                                                                                                                                       |
| Option 3     | service [*required*]        | string          | The service name to filter by.                                                                                                                                                                                                                                                                                                        |
| Option 3     | stat [*required*]           | enum            | The APM resource statistic to query. Allowed enum values: `error_rate,errors,hits,latency_avg,latency_max,latency_p50,latency_p75,latency_p90,latency_p95,latency_p99`                                                                                                                                                                |
| queries      | Option 4                         | object          | A query for APM trace metrics such as hits, errors, and latency percentiles, aggregated across services.                                                                                                                                                                                                                              |
| Option 4     | data_source [*required*]    | enum            | A data source for APM metrics queries. Allowed enum values: `apm_metrics`                                                                                                                                                                                                                                                             |
| Option 4     | group_by                         | [string]        | Optional fields to group the query results by.                                                                                                                                                                                                                                                                                        |
| Option 4     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 4     | operation_mode                   | string          | Optional operation mode to aggregate across operation names.                                                                                                                                                                                                                                                                          |
| Option 4     | operation_name                   | string          | Name of operation on service. If not provided, the primary operation name is used.                                                                                                                                                                                                                                                    |
| Option 4     | peer_tags                        | [string]        | Tags to query for a specific downstream entity (peer.service, peer.db_instance, peer.s3, peer.s3.bucket, etc.).                                                                                                                                                                                                                       |
| Option 4     | query_filter                     | string          | Additional filters for the query using metrics query syntax (for example, env, primary_tag).                                                                                                                                                                                                                                          |
| Option 4     | resource_hash                    | string          | The resource hash for exact matching.                                                                                                                                                                                                                                                                                                 |
| Option 4     | resource_name                    | string          | The full name of a specific resource to filter by.                                                                                                                                                                                                                                                                                    |
| Option 4     | service                          | string          | The service name to filter by.                                                                                                                                                                                                                                                                                                        |
| Option 4     | span_kind                        | enum            | Describes the relationship between the span, its parents, and its children in a trace. Allowed enum values: `consumer,server,client,producer,internal`                                                                                                                                                                                |
| Option 4     | stat [*required*]           | enum            | The APM metric statistic to query. Allowed enum values: `error_rate,errors,errors_per_second,hits,hits_per_second,apdex,latency_avg,latency_max,latency_p50,latency_p75`                                                                                                                                                              |
| queries      | Option 5                         | object          | A query for APM dependency statistics between services, such as call latency and error rates.                                                                                                                                                                                                                                         |
| Option 5     | data_source [*required*]    | enum            | A data source for APM dependency statistics queries. Allowed enum values: `apm_dependency_stats`                                                                                                                                                                                                                                      |
| Option 5     | env [*required*]            | string          | The environment to query.                                                                                                                                                                                                                                                                                                             |
| Option 5     | is_upstream                      | boolean         | Determines whether stats for upstream or downstream dependencies should be queried.                                                                                                                                                                                                                                                   |
| Option 5     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 5     | operation_name [*required*] | string          | The APM operation name.                                                                                                                                                                                                                                                                                                               |
| Option 5     | primary_tag_name                 | string          | The name of the second primary tag used within APM; required when `primary_tag_value` is specified. See [https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog](https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope.md#add-a-second-primary-tag-in-datadog). |
| Option 5     | primary_tag_value                | string          | Filter APM data by the second primary tag. `primary_tag_name` must also be specified.                                                                                                                                                                                                                                                 |
| Option 5     | resource_name [*required*]  | string          | The resource name to filter by.                                                                                                                                                                                                                                                                                                       |
| Option 5     | service [*required*]        | string          | The service name to filter by.                                                                                                                                                                                                                                                                                                        |
| Option 5     | stat [*required*]           | enum            | The APM dependency statistic to query. Allowed enum values: `avg_duration,avg_root_duration,avg_spans_per_trace,error_rate,pct_exec_time,pct_of_traces,total_traces_count`                                                                                                                                                            |
| queries      | Option 6                         | object          | A query for SLO status, error budget, and burn rate metrics.                                                                                                                                                                                                                                                                          |
| Option 6     | additional_query_filters         | string          | Additional filters applied to the SLO query.                                                                                                                                                                                                                                                                                          |
| Option 6     | data_source [*required*]    | enum            | A data source for SLO queries. Allowed enum values: `slo`                                                                                                                                                                                                                                                                             |
| Option 6     | group_mode                       | enum            | How SLO results are grouped in the response. Allowed enum values: `overall,components`                                                                                                                                                                                                                                                |
| Option 6     | measure [*required*]        | enum            | The SLO measurement to retrieve. Allowed enum values: `good_events,bad_events,slo_status,error_budget_remaining,error_budget_remaining_history,error_budget_burndown,burn_rate,slo_status_history,good_minutes,bad_minutes`                                                                                                           |
| Option 6     | name                             | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 6     | slo_id [*required*]         | string          | The unique identifier of the SLO to query.                                                                                                                                                                                                                                                                                            |
| Option 6     | slo_query_type                   | enum            | The type of SLO definition being queried. Allowed enum values: `metric,time_slice,monitor`                                                                                                                                                                                                                                            |
| queries      | Option 7                         | object          | A query for host-level process metrics such as CPU and memory usage.                                                                                                                                                                                                                                                                  |
| Option 7     | data_source [*required*]    | enum            | A data source for process-level infrastructure metrics. Allowed enum values: `process`                                                                                                                                                                                                                                                |
| Option 7     | is_normalized_cpu                | boolean         | Whether CPU metrics should be normalized by core count.                                                                                                                                                                                                                                                                               |
| Option 7     | limit                            | int64           | Maximum number of results to return.                                                                                                                                                                                                                                                                                                  |
| Option 7     | metric [*required*]         | string          | The process metric to query.                                                                                                                                                                                                                                                                                                          |
| Option 7     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 7     | sort                             | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| Option 7     | tag_filters                      | [string]        | Tag filters to narrow down processes.                                                                                                                                                                                                                                                                                                 |
| Option 7     | text_filter                      | string          | A full-text search filter to match process names or commands.                                                                                                                                                                                                                                                                         |
| queries      | Option 8                         | object          | A query for container-level metrics such as CPU and memory usage.                                                                                                                                                                                                                                                                     |
| Option 8     | data_source [*required*]    | enum            | A data source for container-level infrastructure metrics. Allowed enum values: `container`                                                                                                                                                                                                                                            |
| Option 8     | is_normalized_cpu                | boolean         | Whether CPU metrics should be normalized by core count.                                                                                                                                                                                                                                                                               |
| Option 8     | limit                            | int64           | Maximum number of results to return.                                                                                                                                                                                                                                                                                                  |
| Option 8     | metric [*required*]         | string          | The container metric to query.                                                                                                                                                                                                                                                                                                        |
| Option 8     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 8     | sort                             | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| Option 8     | tag_filters                      | [string]        | Tag filters to narrow down containers.                                                                                                                                                                                                                                                                                                |
| Option 8     | text_filter                      | string          | A full-text search filter to match container names.                                                                                                                                                                                                                                                                                   |
| attributes   | to [*required*]             | int64           | End date (exclusive) of the query in milliseconds since the Unix epoch.                                                                                                                                                                                                                                                               |
| data         | type [*required*]           | enum            | The type of the resource. The value should always be timeseries_request. Allowed enum values: `timeseries_request`                                                                                                                                                                                                                    |

{% /tab %}

{% tab title="Example" %}
##### 

```json
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "interval": 5000,
      "queries": [
        {
          "data_source": "metrics",
          "query": "avg:datadog.estimated_usage.metrics.custom{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "timeseries_request"
  }
}
```

##### 

```json
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "interval": 5000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "timeseries_request"
  }
}
```

##### 

```json
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "interval": 5000,
      "queries": [
        {
          "data_source": "apm_metrics",
          "name": "a",
          "stat": "hits",
          "service": "web-store",
          "query_filter": "env:prod",
          "span_kind": "server",
          "group_by": [
            "resource_name"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "timeseries_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
A message containing one response to a timeseries query made with timeseries formula query request.

| Parent field | Field        | Type      | Description                                                                                                                                                                                                                                                                              |
| ------------ | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data         | object    | A message containing the response to a timeseries query.                                                                                                                                                                                                                                 |
| data         | attributes   | object    | The object describing a timeseries response.                                                                                                                                                                                                                                             |
| attributes   | series       | [object]  | Array of response series. The index here corresponds to the index in the `formulas` or `queries` array from the request.                                                                                                                                                                 |
| series       | group_tags   | [string]  | List of tags that apply to a single response value.                                                                                                                                                                                                                                      |
| series       | query_index  | int32     | The index of the query in the "formulas" array (or "queries" array if no "formulas" was specified).                                                                                                                                                                                      |
| series       | 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. |
| unit         | family       | string    | Unit family, allows for conversion between units of the same family, for scaling.                                                                                                                                                                                                        |
| unit         | name         | string    | Unit name                                                                                                                                                                                                                                                                                |
| unit         | plural       | string    | Plural form of the unit name.                                                                                                                                                                                                                                                            |
| unit         | scale_factor | double    | Factor for scaling between units of the same family.                                                                                                                                                                                                                                     |
| unit         | short_name   | string    | Abbreviation of the unit.                                                                                                                                                                                                                                                                |
| attributes   | times        | [integer] | Array of times, 1-1 match with individual values arrays.                                                                                                                                                                                                                                 |
| attributes   | values       | [array]   | Array of value-arrays. The index here corresponds to the index in the `formulas` or `queries` array from the request.                                                                                                                                                                    |
| data         | type         | enum      | The type of the resource. The value should always be timeseries_response. Allowed enum values: `timeseries_response`                                                                                                                                                                     |
|              | errors       | string    | The error generated by the request.                                                                                                                                                                                                                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "series": [
        {
          "group_tags": [
            "env:production"
          ],
          "query_index": 0,
          "unit": [
            {
              "family": "time",
              "name": "minute",
              "plural": "minutes",
              "scale_factor": 60,
              "short_name": "min"
            }
          ]
        }
      ],
      "times": [],
      "values": [
        1575317847,
        0.5
      ]
    },
    "type": "timeseries_response"
  },
  "errors": "string"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/query/timeseries" \
-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": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "interval": 5000,
      "queries": [
        {
          "data_source": "metrics",
          "query": "avg:datadog.estimated_usage.metrics.custom{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "timeseries_request"
  }
}
EOF
                        
##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/query/timeseries" \
-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": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "interval": 5000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "timeseries_request"
  }
}
EOF
                        
##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/query/timeseries" \
-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": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "interval": 5000,
      "queries": [
        {
          "data_source": "apm_metrics",
          "name": "a",
          "stat": "hits",
          "service": "web-store",
          "query_filter": "env:prod",
          "span_kind": "server",
          "group_by": [
            "resource_name"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "timeseries_request"
  }
}
EOF
                        
##### 

```go
// Timeseries cross product query returns "OK" 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.TimeseriesFormulaQueryRequest{
		Data: datadogV2.TimeseriesFormulaRequest{
			Attributes: datadogV2.TimeseriesFormulaRequestAttributes{
				Formulas: []datadogV2.QueryFormula{
					{
						Formula: "a",
						Limit: &datadogV2.FormulaLimit{
							Count: datadog.PtrInt32(10),
							Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
						},
					},
				},
				From:     1636625471000,
				Interval: datadog.PtrInt64(5000),
				Queries: []datadogV2.TimeseriesQuery{
					datadogV2.TimeseriesQuery{
						MetricsTimeseriesQuery: &datadogV2.MetricsTimeseriesQuery{
							DataSource: datadogV2.METRICSDATASOURCE_METRICS,
							Query:      "avg:datadog.estimated_usage.metrics.custom{*}",
							Name:       datadog.PtrString("a"),
						}},
				},
				To: 1636629071000,
			},
			Type: datadogV2.TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMetricsApi(apiClient)
	resp, r, err := api.QueryTimeseriesData(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryTimeseriesData`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Timeseries cross product query returns "OK" 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.FormulaLimit;
import com.datadog.api.client.v2.model.MetricsDataSource;
import com.datadog.api.client.v2.model.MetricsTimeseriesQuery;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryResponse;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestAttributes;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestType;
import com.datadog.api.client.v2.model.TimeseriesQuery;
import java.util.Collections;

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

    TimeseriesFormulaQueryRequest body =
        new TimeseriesFormulaQueryRequest()
            .data(
                new TimeseriesFormulaRequest()
                    .attributes(
                        new TimeseriesFormulaRequestAttributes()
                            .formulas(
                                Collections.singletonList(
                                    new QueryFormula()
                                        .formula("a")
                                        .limit(
                                            new FormulaLimit()
                                                .count(10)
                                                .order(QuerySortOrder.DESC))))
                            .from(1636625471000L)
                            .interval(5000L)
                            .queries(
                                Collections.singletonList(
                                    new TimeseriesQuery(
                                        new MetricsTimeseriesQuery()
                                            .dataSource(MetricsDataSource.METRICS)
                                            .query("avg:datadog.estimated_usage.metrics.custom{*}")
                                            .name("a"))))
                            .to(1636629071000L))
                    .type(TimeseriesFormulaRequestType.TIMESERIES_REQUEST));

    try {
      TimeseriesFormulaQueryResponse result = apiInstance.queryTimeseriesData(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#queryTimeseriesData");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
"""
Timeseries cross product query returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.metrics_data_source import MetricsDataSource
from datadog_api_client.v2.model.metrics_timeseries_query import MetricsTimeseriesQuery
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.timeseries_formula_query_request import TimeseriesFormulaQueryRequest
from datadog_api_client.v2.model.timeseries_formula_request import TimeseriesFormulaRequest
from datadog_api_client.v2.model.timeseries_formula_request_attributes import TimeseriesFormulaRequestAttributes
from datadog_api_client.v2.model.timeseries_formula_request_queries import TimeseriesFormulaRequestQueries
from datadog_api_client.v2.model.timeseries_formula_request_type import TimeseriesFormulaRequestType

body = TimeseriesFormulaQueryRequest(
    data=TimeseriesFormulaRequest(
        attributes=TimeseriesFormulaRequestAttributes(
            formulas=[
                QueryFormula(
                    formula="a",
                    limit=FormulaLimit(
                        count=10,
                        order=QuerySortOrder.DESC,
                    ),
                ),
            ],
            _from=1636625471000,
            interval=5000,
            queries=TimeseriesFormulaRequestQueries(
                [
                    MetricsTimeseriesQuery(
                        data_source=MetricsDataSource.METRICS,
                        query="avg:datadog.estimated_usage.metrics.custom{*}",
                        name="a",
                    ),
                ]
            ),
            to=1636629071000,
        ),
        type=TimeseriesFormulaRequestType.TIMESERIES_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.query_timeseries_data(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Timeseries cross product query returns "OK" response

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

body = DatadogAPIClient::V2::TimeseriesFormulaQueryRequest.new({
  data: DatadogAPIClient::V2::TimeseriesFormulaRequest.new({
    attributes: DatadogAPIClient::V2::TimeseriesFormulaRequestAttributes.new({
      formulas: [
        DatadogAPIClient::V2::QueryFormula.new({
          formula: "a",
          limit: DatadogAPIClient::V2::FormulaLimit.new({
            count: 10,
            order: DatadogAPIClient::V2::QuerySortOrder::DESC,
          }),
        }),
      ],
      from: 1636625471000,
      interval: 5000,
      queries: [
        DatadogAPIClient::V2::MetricsTimeseriesQuery.new({
          data_source: DatadogAPIClient::V2::MetricsDataSource::METRICS,
          query: "avg:datadog.estimated_usage.metrics.custom{*}",
          name: "a",
        }),
      ],
      to: 1636629071000,
    }),
    type: DatadogAPIClient::V2::TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
  }),
})
p api_instance.query_timeseries_data(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```rust
// Timeseries cross product query returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::FormulaLimit;
use datadog_api_client::datadogV2::model::MetricsDataSource;
use datadog_api_client::datadogV2::model::MetricsTimeseriesQuery;
use datadog_api_client::datadogV2::model::QueryFormula;
use datadog_api_client::datadogV2::model::QuerySortOrder;
use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes;
use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType;
use datadog_api_client::datadogV2::model::TimeseriesQuery;

#[tokio::main]
async fn main() {
    let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new(
        TimeseriesFormulaRequestAttributes::new(
            1636625471000,
            vec![TimeseriesQuery::MetricsTimeseriesQuery(Box::new(
                MetricsTimeseriesQuery::new(
                    MetricsDataSource::METRICS,
                    "avg:datadog.estimated_usage.metrics.custom{*}".to_string(),
                )
                .name("a".to_string()),
            ))],
            1636629071000,
        )
        .formulas(vec![QueryFormula::new("a".to_string())
            .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))])
        .interval(5000),
        TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
    ));
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.query_timeseries_data(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Timeseries cross product query returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

const params: v2.MetricsApiQueryTimeseriesDataRequest = {
  body: {
    data: {
      attributes: {
        formulas: [
          {
            formula: "a",
            limit: {
              count: 10,
              order: "desc",
            },
          },
        ],
        from: 1636625471000,
        interval: 5000,
        queries: [
          {
            dataSource: "metrics",
            query: "avg:datadog.estimated_usage.metrics.custom{*}",
            name: "a",
          },
        ],
        to: 1636629071000,
      },
      type: "timeseries_request",
    },
  },
};

apiInstance
  .queryTimeseriesData(params)
  .then((data: v2.TimeseriesFormulaQueryResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}

## Query scalar data across multiple products{% #query-scalar-data-across-multiple-products %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                           |
| ----------------- | ------------------------------------------------------ |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/query/scalar |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/query/scalar |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/query/scalar      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/query/scalar      |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/query/scalar     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/query/scalar |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/query/scalar |

### Overview

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](https://docs.datadoghq.com/api/latest/scopes.md#metrics) to access this endpoint.



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                            | Type            | Description                                                                                                                                                                                                                                                                                                                           |
| ------------ | -------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]           | object          | A single scalar query to be executed.                                                                                                                                                                                                                                                                                                 |
| data         | attributes [*required*]     | object          | The object describing a scalar formula request.                                                                                                                                                                                                                                                                                       |
| attributes   | formulas                         | [object]        | List of formulas to be calculated and returned as responses.                                                                                                                                                                                                                                                                          |
| formulas     | formula [*required*]        | string          | Formula string, referencing one or more queries with their name property.                                                                                                                                                                                                                                                             |
| formulas     | 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.                                                                                                                                                                             |
| limit        | count                            | int32           | The number of results to which to limit.                                                                                                                                                                                                                                                                                              |
| limit        | order                            | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| attributes   | from [*required*]           | int64           | Start date (inclusive) of the query in milliseconds since the Unix epoch.                                                                                                                                                                                                                                                             |
| attributes   | queries [*required*]        | [ <oneOf>] | List of queries to be run and used as inputs to the formulas.                                                                                                                                                                                                                                                                         |
| queries      | Option 1                         | object          | A query against Datadog custom metrics or Cloud Cost data sources.                                                                                                                                                                                                                                                                    |
| Option 1     | 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`                                                                                                                                                                                       |
| Option 1     | data_source [*required*]    | enum            | A data source that is powered by the Metrics platform. Allowed enum values: `metrics,cloud_cost`                                                                                                                                                                                                                                      |
| Option 1     | name                             | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 1     | query [*required*]          | string          | A classic metrics query string.                                                                                                                                                                                                                                                                                                       |
| queries      | Option 2                         | object          | An individual scalar query for logs, RUM, traces, CI pipelines, security signals, and other event-based data sources. Use this query type for any data source powered by the Events Platform. See the data_source field for the full list of supported sources.                                                                       |
| Option 2     | compute [*required*]        | object          | The instructions for what to compute for this query.                                                                                                                                                                                                                                                                                  |
| compute      | 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`                                                                                                                                                                                  |
| compute      | interval                         | int64           | Interval for compute in milliseconds.                                                                                                                                                                                                                                                                                                 |
| compute      | metric                           | string          | The "measure" attribute on which to perform the computation.                                                                                                                                                                                                                                                                          |
| Option 2     | data_source [*required*]    | enum            | A data source that is powered by the Events Platform. Allowed enum values: `logs,spans,network,rum,security_signals,profiles,audit,events,ci_tests,ci_pipelines`                                                                                                                                                                      |
| Option 2     | group_by                         | [object]        | The list of facets on which to split results.                                                                                                                                                                                                                                                                                         |
| group_by     | facet [*required*]          | string          | The facet by which to split groups.                                                                                                                                                                                                                                                                                                   |
| group_by     | 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.                                                                                                                                                                |
| group_by     | sort                             | object          | The dimension by which to sort a query's results.                                                                                                                                                                                                                                                                                     |
| sort         | 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`                                                                                                                                                                                  |
| sort         | metric                           | string          | The metric's calculated value which should be used to define the sort order of a query's results.                                                                                                                                                                                                                                     |
| sort         | order                            | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| sort         | type                             | enum            | The type of sort to use on the calculated value. Allowed enum values: `alphabetical,measure`                                                                                                                                                                                                                                          |
| Option 2     | indexes                          | [string]        | The indexes in which to search.                                                                                                                                                                                                                                                                                                       |
| Option 2     | name                             | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 2     | search                           | object          | Configuration of the search/filter for an events query.                                                                                                                                                                                                                                                                               |
| search       | query                            | string          | The search/filter string for an events query.                                                                                                                                                                                                                                                                                         |
| queries      | Option 3                         | object          | A query for APM resource statistics such as latency, error rate, and hit count, grouped by resource name.                                                                                                                                                                                                                             |
| Option 3     | data_source [*required*]    | enum            | A data source for APM resource statistics queries. Allowed enum values: `apm_resource_stats`                                                                                                                                                                                                                                          |
| Option 3     | env [*required*]            | string          | The environment to query.                                                                                                                                                                                                                                                                                                             |
| Option 3     | group_by                         | [string]        | Tag keys to group results by.                                                                                                                                                                                                                                                                                                         |
| Option 3     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 3     | operation_name                   | string          | The APM operation name.                                                                                                                                                                                                                                                                                                               |
| Option 3     | primary_tag_name                 | string          | Name of the second primary tag used within APM. Required when `primary_tag_value` is specified. See [https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog](https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope.md#add-a-second-primary-tag-in-datadog)      |
| Option 3     | primary_tag_value                | string          | Value of the second primary tag by which to filter APM data. `primary_tag_name` must also be specified.                                                                                                                                                                                                                               |
| Option 3     | resource_name                    | string          | The resource name to filter by.                                                                                                                                                                                                                                                                                                       |
| Option 3     | service [*required*]        | string          | The service name to filter by.                                                                                                                                                                                                                                                                                                        |
| Option 3     | stat [*required*]           | enum            | The APM resource statistic to query. Allowed enum values: `error_rate,errors,hits,latency_avg,latency_max,latency_p50,latency_p75,latency_p90,latency_p95,latency_p99`                                                                                                                                                                |
| queries      | Option 4                         | object          | A query for APM trace metrics such as hits, errors, and latency percentiles, aggregated across services.                                                                                                                                                                                                                              |
| Option 4     | data_source [*required*]    | enum            | A data source for APM metrics queries. Allowed enum values: `apm_metrics`                                                                                                                                                                                                                                                             |
| Option 4     | group_by                         | [string]        | Optional fields to group the query results by.                                                                                                                                                                                                                                                                                        |
| Option 4     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 4     | operation_mode                   | string          | Optional operation mode to aggregate across operation names.                                                                                                                                                                                                                                                                          |
| Option 4     | operation_name                   | string          | Name of operation on service. If not provided, the primary operation name is used.                                                                                                                                                                                                                                                    |
| Option 4     | peer_tags                        | [string]        | Tags to query for a specific downstream entity (peer.service, peer.db_instance, peer.s3, peer.s3.bucket, etc.).                                                                                                                                                                                                                       |
| Option 4     | query_filter                     | string          | Additional filters for the query using metrics query syntax (for example, env, primary_tag).                                                                                                                                                                                                                                          |
| Option 4     | resource_hash                    | string          | The resource hash for exact matching.                                                                                                                                                                                                                                                                                                 |
| Option 4     | resource_name                    | string          | The full name of a specific resource to filter by.                                                                                                                                                                                                                                                                                    |
| Option 4     | service                          | string          | The service name to filter by.                                                                                                                                                                                                                                                                                                        |
| Option 4     | span_kind                        | enum            | Describes the relationship between the span, its parents, and its children in a trace. Allowed enum values: `consumer,server,client,producer,internal`                                                                                                                                                                                |
| Option 4     | stat [*required*]           | enum            | The APM metric statistic to query. Allowed enum values: `error_rate,errors,errors_per_second,hits,hits_per_second,apdex,latency_avg,latency_max,latency_p50,latency_p75`                                                                                                                                                              |
| queries      | Option 5                         | object          | A query for APM dependency statistics between services, such as call latency and error rates.                                                                                                                                                                                                                                         |
| Option 5     | data_source [*required*]    | enum            | A data source for APM dependency statistics queries. Allowed enum values: `apm_dependency_stats`                                                                                                                                                                                                                                      |
| Option 5     | env [*required*]            | string          | The environment to query.                                                                                                                                                                                                                                                                                                             |
| Option 5     | is_upstream                      | boolean         | Determines whether stats for upstream or downstream dependencies should be queried.                                                                                                                                                                                                                                                   |
| Option 5     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 5     | operation_name [*required*] | string          | The APM operation name.                                                                                                                                                                                                                                                                                                               |
| Option 5     | primary_tag_name                 | string          | The name of the second primary tag used within APM; required when `primary_tag_value` is specified. See [https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog](https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope.md#add-a-second-primary-tag-in-datadog). |
| Option 5     | primary_tag_value                | string          | Filter APM data by the second primary tag. `primary_tag_name` must also be specified.                                                                                                                                                                                                                                                 |
| Option 5     | resource_name [*required*]  | string          | The resource name to filter by.                                                                                                                                                                                                                                                                                                       |
| Option 5     | service [*required*]        | string          | The service name to filter by.                                                                                                                                                                                                                                                                                                        |
| Option 5     | stat [*required*]           | enum            | The APM dependency statistic to query. Allowed enum values: `avg_duration,avg_root_duration,avg_spans_per_trace,error_rate,pct_exec_time,pct_of_traces,total_traces_count`                                                                                                                                                            |
| queries      | Option 6                         | object          | A query for SLO status, error budget, and burn rate metrics.                                                                                                                                                                                                                                                                          |
| Option 6     | additional_query_filters         | string          | Additional filters applied to the SLO query.                                                                                                                                                                                                                                                                                          |
| Option 6     | data_source [*required*]    | enum            | A data source for SLO queries. Allowed enum values: `slo`                                                                                                                                                                                                                                                                             |
| Option 6     | group_mode                       | enum            | How SLO results are grouped in the response. Allowed enum values: `overall,components`                                                                                                                                                                                                                                                |
| Option 6     | measure [*required*]        | enum            | The SLO measurement to retrieve. Allowed enum values: `good_events,bad_events,slo_status,error_budget_remaining,error_budget_remaining_history,error_budget_burndown,burn_rate,slo_status_history,good_minutes,bad_minutes`                                                                                                           |
| Option 6     | name                             | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 6     | slo_id [*required*]         | string          | The unique identifier of the SLO to query.                                                                                                                                                                                                                                                                                            |
| Option 6     | slo_query_type                   | enum            | The type of SLO definition being queried. Allowed enum values: `metric,time_slice,monitor`                                                                                                                                                                                                                                            |
| queries      | Option 7                         | object          | A query for host-level process metrics such as CPU and memory usage.                                                                                                                                                                                                                                                                  |
| Option 7     | aggregator                       | 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`                                                                                                                                                                                       |
| Option 7     | data_source [*required*]    | enum            | A data source for process-level infrastructure metrics. Allowed enum values: `process`                                                                                                                                                                                                                                                |
| Option 7     | is_normalized_cpu                | boolean         | Whether CPU metrics should be normalized by core count.                                                                                                                                                                                                                                                                               |
| Option 7     | limit                            | int64           | Maximum number of results to return.                                                                                                                                                                                                                                                                                                  |
| Option 7     | metric [*required*]         | string          | The process metric to query.                                                                                                                                                                                                                                                                                                          |
| Option 7     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 7     | sort                             | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| Option 7     | tag_filters                      | [string]        | Tag filters to narrow down processes.                                                                                                                                                                                                                                                                                                 |
| Option 7     | text_filter                      | string          | A full-text search filter to match process names or commands.                                                                                                                                                                                                                                                                         |
| queries      | Option 8                         | object          | A query for container-level metrics such as CPU and memory usage.                                                                                                                                                                                                                                                                     |
| Option 8     | aggregator                       | 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`                                                                                                                                                                                       |
| Option 8     | data_source [*required*]    | enum            | A data source for container-level infrastructure metrics. Allowed enum values: `container`                                                                                                                                                                                                                                            |
| Option 8     | is_normalized_cpu                | boolean         | Whether CPU metrics should be normalized by core count.                                                                                                                                                                                                                                                                               |
| Option 8     | limit                            | int64           | Maximum number of results to return.                                                                                                                                                                                                                                                                                                  |
| Option 8     | metric [*required*]         | string          | The container metric to query.                                                                                                                                                                                                                                                                                                        |
| Option 8     | name [*required*]           | string          | The variable name for use in formulas.                                                                                                                                                                                                                                                                                                |
| Option 8     | sort                             | enum            | Direction of sort. Allowed enum values: `asc,desc`                                                                                                                                                                                                                                                                                    |
| Option 8     | tag_filters                      | [string]        | Tag filters to narrow down containers.                                                                                                                                                                                                                                                                                                |
| Option 8     | text_filter                      | string          | A full-text search filter to match container names.                                                                                                                                                                                                                                                                                   |
| attributes   | to [*required*]             | int64           | End date (exclusive) of the query in milliseconds since the Unix epoch.                                                                                                                                                                                                                                                               |
| data         | type [*required*]           | enum            | The type of the resource. The value should always be scalar_request. Allowed enum values: `scalar_request`                                                                                                                                                                                                                            |

{% /tab %}

{% tab title="Example" %}
##### 

```json
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
```

##### 

```json
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
```

##### 

```json
{
  "data": {
    "attributes": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_metrics",
          "name": "a",
          "stat": "hits",
          "service": "web-store",
          "query_filter": "env:prod",
          "span_kind": "server",
          "group_by": [
            "resource_name"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
A message containing one or more responses to scalar queries.

| Parent field | Field        | Type            | Description                                                                                                                                                                                                                                                                          |
| ------------ | ------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|              | data         | object          | A message containing the response to a scalar query.                                                                                                                                                                                                                                 |
| data         | attributes   | object          | The object describing a scalar response.                                                                                                                                                                                                                                             |
| attributes   | 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.                                                                                                                           |
| columns      | Option 1     | object          | A column containing the tag keys and values in a group.                                                                                                                                                                                                                              |
| Option 1     | name         | string          | The name of the tag key or group.                                                                                                                                                                                                                                                    |
| Option 1     | type         | enum            | The type of column present for groups. Allowed enum values: `group`                                                                                                                                                                                                                  |
| Option 1     | values       | [array]         | The array of tag values for each group found for the results of the formulas or queries.                                                                                                                                                                                             |
| columns      | Option 2     | object          | A column containing the numerical results for a formula or query.                                                                                                                                                                                                                    |
| Option 2     | meta         | object          | Metadata for the resulting numerical values.                                                                                                                                                                                                                                         |
| meta         | 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. |
| unit         | family       | string          | Unit family, allows for conversion between units of the same family, for scaling.                                                                                                                                                                                                    |
| unit         | name         | string          | Unit name                                                                                                                                                                                                                                                                            |
| unit         | plural       | string          | Plural form of the unit name.                                                                                                                                                                                                                                                        |
| unit         | scale_factor | double          | Factor for scaling between units of the same family.                                                                                                                                                                                                                                 |
| unit         | short_name   | string          | Abbreviation of the unit.                                                                                                                                                                                                                                                            |
| Option 2     | name         | string          | The name referencing the formula or query for this column.                                                                                                                                                                                                                           |
| Option 2     | type         | enum            | The type of column present for numbers. Allowed enum values: `number`                                                                                                                                                                                                                |
| Option 2     | values       | [number]        | The array of numerical values for one formula or query.                                                                                                                                                                                                                              |
| data         | type         | enum            | The type of the resource. The value should always be scalar_response. Allowed enum values: `scalar_response`                                                                                                                                                                         |
|              | errors       | string          | An error generated when processing a request.                                                                                                                                                                                                                                        |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "columns": [
        {
          "name": "env",
          "type": "group",
          "values": [
            [
              "staging"
            ]
          ]
        }
      ]
    },
    "type": "scalar_response"
  },
  "errors": "string"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/query/scalar" \
-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": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "aggregator": "avg",
          "data_source": "metrics",
          "query": "avg:system.cpu.user{*}",
          "name": "a"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
EOF
                        
##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/query/scalar" \
-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": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_dependency_stats",
          "name": "a",
          "env": "ci",
          "service": "cassandra",
          "stat": "avg_duration",
          "operation_name": "cassandra.query",
          "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?",
          "primary_tag_name": "datacenter",
          "primary_tag_value": "edge-eu1.prod.dog"
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
EOF
                        
##### 
                          \# Curl commandcurl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.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/v2/query/scalar" \
-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": {
      "formulas": [
        {
          "formula": "a",
          "limit": {
            "count": 10,
            "order": "desc"
          }
        }
      ],
      "from": 1636625471000,
      "queries": [
        {
          "data_source": "apm_metrics",
          "name": "a",
          "stat": "hits",
          "service": "web-store",
          "query_filter": "env:prod",
          "span_kind": "server",
          "group_by": [
            "resource_name"
          ]
        }
      ],
      "to": 1636629071000
    },
    "type": "scalar_request"
  }
}
EOF
                        
##### 

```go
// Scalar cross product query returns "OK" 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.ScalarFormulaQueryRequest{
		Data: datadogV2.ScalarFormulaRequest{
			Attributes: datadogV2.ScalarFormulaRequestAttributes{
				Formulas: []datadogV2.QueryFormula{
					{
						Formula: "a",
						Limit: &datadogV2.FormulaLimit{
							Count: datadog.PtrInt32(10),
							Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
						},
					},
				},
				From: 1636625471000,
				Queries: []datadogV2.ScalarQuery{
					datadogV2.ScalarQuery{
						MetricsScalarQuery: &datadogV2.MetricsScalarQuery{
							Aggregator: datadogV2.METRICSAGGREGATOR_AVG,
							DataSource: datadogV2.METRICSDATASOURCE_METRICS,
							Query:      "avg:system.cpu.user{*}",
							Name:       datadog.PtrString("a"),
						}},
				},
				To: 1636629071000,
			},
			Type: datadogV2.SCALARFORMULAREQUESTTYPE_SCALAR_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMetricsApi(apiClient)
	resp, r, err := api.QueryScalarData(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryScalarData`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Scalar cross product query returns "OK" 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.FormulaLimit;
import com.datadog.api.client.v2.model.MetricsAggregator;
import com.datadog.api.client.v2.model.MetricsDataSource;
import com.datadog.api.client.v2.model.MetricsScalarQuery;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.ScalarFormulaQueryRequest;
import com.datadog.api.client.v2.model.ScalarFormulaQueryResponse;
import com.datadog.api.client.v2.model.ScalarFormulaRequest;
import com.datadog.api.client.v2.model.ScalarFormulaRequestAttributes;
import com.datadog.api.client.v2.model.ScalarFormulaRequestType;
import com.datadog.api.client.v2.model.ScalarQuery;
import java.util.Collections;

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

    ScalarFormulaQueryRequest body =
        new ScalarFormulaQueryRequest()
            .data(
                new ScalarFormulaRequest()
                    .attributes(
                        new ScalarFormulaRequestAttributes()
                            .formulas(
                                Collections.singletonList(
                                    new QueryFormula()
                                        .formula("a")
                                        .limit(
                                            new FormulaLimit()
                                                .count(10)
                                                .order(QuerySortOrder.DESC))))
                            .from(1636625471000L)
                            .queries(
                                Collections.singletonList(
                                    new ScalarQuery(
                                        new MetricsScalarQuery()
                                            .aggregator(MetricsAggregator.AVG)
                                            .dataSource(MetricsDataSource.METRICS)
                                            .query("avg:system.cpu.user{*}")
                                            .name("a"))))
                            .to(1636629071000L))
                    .type(ScalarFormulaRequestType.SCALAR_REQUEST));

    try {
      ScalarFormulaQueryResponse result = apiInstance.queryScalarData(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MetricsApi#queryScalarData");
      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](https://docs.datadoghq.com/api/latest.md?code-lang=java) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
"""
Scalar cross product query returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.metrics_aggregator import MetricsAggregator
from datadog_api_client.v2.model.metrics_data_source import MetricsDataSource
from datadog_api_client.v2.model.metrics_scalar_query import MetricsScalarQuery
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.scalar_formula_query_request import ScalarFormulaQueryRequest
from datadog_api_client.v2.model.scalar_formula_request import ScalarFormulaRequest
from datadog_api_client.v2.model.scalar_formula_request_attributes import ScalarFormulaRequestAttributes
from datadog_api_client.v2.model.scalar_formula_request_queries import ScalarFormulaRequestQueries
from datadog_api_client.v2.model.scalar_formula_request_type import ScalarFormulaRequestType

body = ScalarFormulaQueryRequest(
    data=ScalarFormulaRequest(
        attributes=ScalarFormulaRequestAttributes(
            formulas=[
                QueryFormula(
                    formula="a",
                    limit=FormulaLimit(
                        count=10,
                        order=QuerySortOrder.DESC,
                    ),
                ),
            ],
            _from=1636625471000,
            queries=ScalarFormulaRequestQueries(
                [
                    MetricsScalarQuery(
                        aggregator=MetricsAggregator.AVG,
                        data_source=MetricsDataSource.METRICS,
                        query="avg:system.cpu.user{*}",
                        name="a",
                    ),
                ]
            ),
            to=1636629071000,
        ),
        type=ScalarFormulaRequestType.SCALAR_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.query_scalar_data(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Scalar cross product query returns "OK" response

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

body = DatadogAPIClient::V2::ScalarFormulaQueryRequest.new({
  data: DatadogAPIClient::V2::ScalarFormulaRequest.new({
    attributes: DatadogAPIClient::V2::ScalarFormulaRequestAttributes.new({
      formulas: [
        DatadogAPIClient::V2::QueryFormula.new({
          formula: "a",
          limit: DatadogAPIClient::V2::FormulaLimit.new({
            count: 10,
            order: DatadogAPIClient::V2::QuerySortOrder::DESC,
          }),
        }),
      ],
      from: 1636625471000,
      queries: [
        DatadogAPIClient::V2::MetricsScalarQuery.new({
          aggregator: DatadogAPIClient::V2::MetricsAggregator::AVG,
          data_source: DatadogAPIClient::V2::MetricsDataSource::METRICS,
          query: "avg:system.cpu.user{*}",
          name: "a",
        }),
      ],
      to: 1636629071000,
    }),
    type: DatadogAPIClient::V2::ScalarFormulaRequestType::SCALAR_REQUEST,
  }),
})
p api_instance.query_scalar_data(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```rust
// Scalar cross product query returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::FormulaLimit;
use datadog_api_client::datadogV2::model::MetricsAggregator;
use datadog_api_client::datadogV2::model::MetricsDataSource;
use datadog_api_client::datadogV2::model::MetricsScalarQuery;
use datadog_api_client::datadogV2::model::QueryFormula;
use datadog_api_client::datadogV2::model::QuerySortOrder;
use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest;
use datadog_api_client::datadogV2::model::ScalarFormulaRequest;
use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes;
use datadog_api_client::datadogV2::model::ScalarFormulaRequestType;
use datadog_api_client::datadogV2::model::ScalarQuery;

#[tokio::main]
async fn main() {
    let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new(
        ScalarFormulaRequestAttributes::new(
            1636625471000,
            vec![ScalarQuery::MetricsScalarQuery(Box::new(
                MetricsScalarQuery::new(
                    MetricsAggregator::AVG,
                    MetricsDataSource::METRICS,
                    "avg:system.cpu.user{*}".to_string(),
                )
                .name("a".to_string()),
            ))],
            1636629071000,
        )
        .formulas(vec![QueryFormula::new("a".to_string())
            .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]),
        ScalarFormulaRequestType::SCALAR_REQUEST,
    ));
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.query_scalar_data(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Scalar cross product query returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
