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.

Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers. If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.

POST https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://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 or configure custom aggregations on any count, rate, or gauge metric. Can only be used with application keys of users with the Manage Tags for Metrics permission.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

The name of the metric.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Object for a single metric to be configure tags on.

attributes

object

Object containing the definition of a metric tag configuration to be created.

aggregations

[object]

A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:

  • time: avg, space: avg
  • time: avg, space: max
  • time: avg, space: min
  • time: avg, space: sum
  • time: count, space: sum
  • time: max, space: max
  • time: min, space: min
  • time: sum, space: avg
  • time: sum, space: sum

Can only be applied to metrics that have a metric_type of count, rate, or gauge.

space [required]

enum

A space aggregation for use in query. Allowed enum values: avg,max,min,sum

time [required]

enum

A time aggregation for use in query. Allowed enum values: avg,count,max,min,sum

include_percentiles

boolean

Toggle to include/exclude percentiles for a distribution metric. Defaults to false. Can only be applied to metrics that have a metric_type of distribution.

metric_type [required]

enum

The metric's type. Allowed enum values: gauge,count,rate,distribution

tags [required]

[string]

A list of tag keys that will be queryable for your metric.

id [required]

string

The metric name for this resource.

type [required]

enum

The metric tag configuration resource type. Allowed enum values: manage_tags

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

Response

Created

Response object which includes a single metric’s tag configuration.

Expand All

Field

Type

Description

data

object

Object for a single metric tag configuration.

attributes

object

Object containing the definition of a metric tag configuration attributes.

aggregations

[object]

A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:

  • time: avg, space: avg
  • time: avg, space: max
  • time: avg, space: min
  • time: avg, space: sum
  • time: count, space: sum
  • time: max, space: max
  • time: min, space: min
  • time: sum, space: avg
  • time: sum, space: sum

Can only be applied to metrics that have a metric_type of count, rate, or gauge.

space [required]

enum

A space aggregation for use in query. Allowed enum values: avg,max,min,sum

time [required]

enum

A time aggregation for use in query. Allowed enum values: avg,count,max,min,sum

created_at

date-time

Timestamp when the tag configuration was created.

include_percentiles

boolean

Toggle to turn on/off percentile aggregations for distribution metrics. Only present when the metric_type is distribution.

metric_type

enum

The metric's type. Allowed enum values: gauge,count,rate,distribution

modified_at

date-time

Timestamp when the tag configuration was last modified.

tags

[string]

List of tag keys on which to group.

id

string

The metric name for this resource.

type

enum

The metric tag configuration resource type. Allowed enum values: manage_tags

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

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Conflict

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Path parameters
export metric_name="dist.http.endpoint.request"
# Curl command curl -X POST "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "aggregations": [ { "space": "sum", "time": "sum" } ], "metric_type": "count", "tags": [ "app", "datacenter" ] }, "id": "test.metric.latency", "type": "manage_tags" } } EOF
"""
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="ExampleCreateatagconfigurationreturnsCreatedresponse",
        attributes=MetricTagConfigurationCreateAttributes(
            tags=[
                "app",
                "datacenter",
            ],
            metric_type=MetricTagConfigurationMetricTypes("gauge"),
        ),
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_tag_configuration"] = True
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    response = api_instance.create_tag_configuration(
        metric_name="ExampleCreateatagconfigurationreturnsCreatedresponse", body=body
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Create a tag configuration returns "Created" response

require "datadog_api_client"
DatadogAPIClient::V2.configure do |config|
  config.unstable_operations[:create_tag_configuration] = true
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new

body = DatadogAPIClient::V2::MetricTagConfigurationCreateRequest.new({
  data: DatadogAPIClient::V2::MetricTagConfigurationCreateData.new({
    type: DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS,
    id: "ExampleCreateatagconfigurationreturnsCreatedresponse",
    attributes: DatadogAPIClient::V2::MetricTagConfigurationCreateAttributes.new({
      tags: [
        "app",
        "datacenter",
      ],
      metric_type: DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE,
    }),
  }),
})
p api_instance.create_tag_configuration("ExampleCreateatagconfigurationreturnsCreatedresponse", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Create a tag configuration returns "Created" response
 */

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

const configuration = v2.createConfiguration();
configuration.unstableOperations["createTagConfiguration"] = true;
const apiInstance = new v2.MetricsApi(configuration);

const params: v2.MetricsApiCreateTagConfigurationRequest = {
  body: {
    data: {
      type: "manage_tags",
      id: "ExampleCreateatagconfigurationreturnsCreatedresponse",
      attributes: {
        tags: ["app", "datacenter"],
        metricType: "gauge",
      },
    },
  },
  metricName: "ExampleCreateatagconfigurationreturnsCreatedresponse",
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// Create a tag configuration returns "Created" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	body := datadog.MetricTagConfigurationCreateRequest{
		Data: datadog.MetricTagConfigurationCreateData{
			Type: datadog.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,
			Id:   "ExampleCreateatagconfigurationreturnsCreatedresponse",
			Attributes: &datadog.MetricTagConfigurationCreateAttributes{
				Tags: []string{
					"app",
					"datacenter",
				},
				MetricType: datadog.METRICTAGCONFIGURATIONMETRICTYPES_GAUGE,
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("CreateTagConfiguration", true)
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.CreateTagConfiguration(ctx, "ExampleCreateatagconfigurationreturnsCreatedresponse", body)

	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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Create a tag configuration returns "Created" response

import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.api.MetricsApi;
import com.datadog.api.v2.client.model.MetricTagConfigurationCreateAttributes;
import com.datadog.api.v2.client.model.MetricTagConfigurationCreateData;
import com.datadog.api.v2.client.model.MetricTagConfigurationCreateRequest;
import com.datadog.api.v2.client.model.MetricTagConfigurationMetricTypes;
import com.datadog.api.v2.client.model.MetricTagConfigurationResponse;
import com.datadog.api.v2.client.model.MetricTagConfigurationType;
import java.util.Arrays;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("createTagConfiguration", true);
    MetricsApi apiInstance = new MetricsApi(defaultClient);

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

    try {
      MetricTagConfigurationResponse result =
          apiInstance.createTagConfiguration(
              "ExampleCreateatagconfigurationreturnsCreatedresponse", 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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

POST https://api.datadoghq.eu/api/v1/serieshttps://api.ddog-gov.com/api/v1/serieshttps://api.datadoghq.com/api/v1/serieshttps://api.us3.datadoghq.com/api/v1/serieshttps://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)

Expand All

Field

Type

Description

series [required]

[object]

A list of time series to submit to Datadog.

host

string

The name of the host that produced the metric.

interval

int64

If the type of the metric is rate or count, define the corresponding interval.

metric [required]

string

The name of the timeseries.

points [required]

[array]

Points relating to a metric. All points must be tuples with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.

tags

[string]

A list of tags associated with the metric.

type

string

The type of the metric. Valid types are "",count, gauge, and rate.

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

Response

Payload accepted

The payload accepted for intake.

Expand All

Field

Type

Description

status

string

The status of the intake payload.

{
  "status": "ok"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Authentication error

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Request timeout

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Payload too large

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables
export NOW="$(date +%s)"
# Curl command curl -X POST "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 "Content-Type: text/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -d @- << EOF { "series": [ { "metric": "system.load.1", "points": [[${NOW}, 1234.5]] } ] } EOF
"""
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:ExampleSubmitmetricsreturnsPayloadacceptedresponse",
            ],
        ),
    ],
)

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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
# 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:ExampleSubmitmetricsreturnsPayloadacceptedresponse",
      ],
    }),
  ],
})
p api_instance.submit_metrics(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
/**
 * Submit metrics returns "Payload accepted" response
 */

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

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

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

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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
// Submit metrics returns "Payload accepted" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

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

func main() {
	body := datadog.MetricsPayload{
		Series: []datadog.Series{
			{
				Metric: "system.load.1",
				Type:   datadog.PtrString("gauge"),
				Points: [][]*float64{
					{
						datadog.PtrFloat64(float64(time.Now().Unix())),
						datadog.PtrFloat64(1.1),
					},
				},
				Tags: []string{
					"test:ExampleSubmitmetricsreturnsPayloadacceptedresponse",
				},
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.SubmitMetrics(ctx, body, *datadog.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
// Submit metrics returns "Payload accepted" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MetricsApi;
import com.datadog.api.v1.client.model.IntakePayloadAccepted;
import com.datadog.api.v1.client.model.MetricsPayload;
import com.datadog.api.v1.client.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 = Configuration.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:ExampleSubmitmetricsreturnsPayloadacceptedresponse"))));

    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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" python "example.py"

POST https://api.datadoghq.eu/api/v2/serieshttps://api.ddog-gov.com/api/v2/serieshttps://api.datadoghq.com/api/v2/serieshttps://api.us3.datadoghq.com/api/v2/serieshttps://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.

Arguments

Header Parameters

Name

Type

Description

Content-Encoding

string

HTTP header used to compress the media-type.

Request

Body Data (required)

Expand All

Field

Type

Description

series [required]

[object]

A list of time series to submit to Datadog.

interval

int64

If the type of the metric is rate or count, define the corresponding interval.

metadata

object

Metadata for the metric.

origin

object

Metric origin information.

metric_type

int32

The origin metric type code

product

int32

The origin product code

service

int32

The origin service code

metric [required]

string

The name of the timeseries.

points [required]

[object]

Points relating to a metric. All points must be objects with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.

timestamp

int64

The timestamp should be in seconds and current. Current is defined as not more than 10 minutes in the future or more than 1 hour in the past.

value

double

The numeric value format should be a 64bit float gauge-type value.

resources

[object]

A list of resources to associate with this metric.

name

string

The name of the metric.

type

string

The type of metric.

source_type_name

string

The source type name.

tags

[string]

A list of tags associated with the metric.

type

enum

The type of metric. Allowed enum values: 0,1,2,3,15

unit

string

The unit of point value.

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

Response

Payload accepted

The payload accepted for intake.

Expand All

Field

Type

Description

status

string

The status of the intake payload.

{
  "status": "ok"
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Authentication error

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Request timeout

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Payload too large

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables
export NOW="$(date +%s)"
# Curl command curl -X POST "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -d @- << EOF { "series": [ { "metric": "system.load.1", "points": [ {} ] } ] } EOF
"""
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_series import MetricSeries

body = MetricPayload(
    series=[
        MetricSeries(
            metric="system.load.1",
            type=MetricIntakeType(0),
            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(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
# 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,
        }),
      ],
    }),
  ],
})
p api_instance.submit_metrics(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
/**
 * Submit metrics returns "Payload accepted" response
 */

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

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

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

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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
// Submit metrics returns "Payload accepted" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

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

func main() {
	body := datadog.MetricPayload{
		Series: []datadog.MetricSeries{
			{
				Metric: "system.load.1",
				Type:   datadog.METRICINTAKETYPE_UNSPECIFIED.Ptr(),
				Points: []datadog.MetricPoint{
					{
						Timestamp: datadog.PtrInt64(time.Now().Unix()),
						Value:     datadog.PtrFloat64(0.7),
					},
				},
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.SubmitMetrics(ctx, body, *datadog.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
// Submit metrics returns "Payload accepted" response
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.api.MetricsApi;
import com.datadog.api.v2.client.model.IntakePayloadAccepted;
import com.datadog.api.v2.client.model.MetricIntakeType;
import com.datadog.api.v2.client.model.MetricPayload;
import com.datadog.api.v2.client.model.MetricPoint;
import com.datadog.api.v2.client.model.MetricSeries;
import java.time.OffsetDateTime;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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);
      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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/metricshttps://api.ddog-gov.com/api/v1/metricshttps://api.datadoghq.com/api/v1/metricshttps://api.us3.datadoghq.com/api/v1/metricshttps://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 authorization scope.

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

OK

Object listing all metric names stored by Datadog since a given time.

Expand All

Field

Type

Description

from

string

Time when the metrics were active, seconds since the Unix epoch.

metrics

[string]

List of metric names.

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

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Required query arguments
export from="CHANGE_ME"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get active metrics list returns "OK" response
 */

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

const configuration = v1.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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get active metrics list returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.ListActiveMetrics(ctx, 9223372036854775807, *datadog.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get active metrics list returns "OK" response

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

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers. If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.

GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags

Overview

Returns the tag configuration for the given metric name.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

The name of the metric.

Response

Success

Response object which includes a single metric’s tag configuration.

Expand All

Field

Type

Description

data

object

Object for a single metric tag configuration.

attributes

object

Object containing the definition of a metric tag configuration attributes.

aggregations

[object]

A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:

  • time: avg, space: avg
  • time: avg, space: max
  • time: avg, space: min
  • time: avg, space: sum
  • time: count, space: sum
  • time: max, space: max
  • time: min, space: min
  • time: sum, space: avg
  • time: sum, space: sum

Can only be applied to metrics that have a metric_type of count, rate, or gauge.

space [required]

enum

A space aggregation for use in query. Allowed enum values: avg,max,min,sum

time [required]

enum

A time aggregation for use in query. Allowed enum values: avg,count,max,min,sum

created_at

date-time

Timestamp when the tag configuration was created.

include_percentiles

boolean

Toggle to turn on/off percentile aggregations for distribution metrics. Only present when the metric_type is distribution.

metric_type

enum

The metric's type. Allowed enum values: gauge,count,rate,distribution

modified_at

date-time

Timestamp when the tag configuration was last modified.

tags

[string]

List of tag keys on which to group.

id

string

The metric name for this resource.

type

enum

The metric tag configuration resource type. Allowed enum values: manage_tags

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Path parameters
export metric_name="dist.http.endpoint.request"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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()
configuration.unstable_operations["list_tag_configuration_by_name"] = True
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# List tag configuration by name returns "Success" response

require "datadog_api_client"
DatadogAPIClient::V2.configure do |config|
  config.unstable_operations[:list_tag_configuration_by_name] = true
end
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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * List tag configuration by name returns "Success" response
 */

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

const configuration = v2.createConfiguration();
configuration.unstableOperations["listTagConfigurationByName"] = true;
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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// List tag configuration by name returns "Success" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

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()
	configuration.SetUnstableOperationEnabled("ListTagConfigurationByName", true)
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// List tag configuration by name returns "Success" response

import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.api.MetricsApi;
import com.datadog.api.v2.client.model.MetricTagConfigurationResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("listTagConfigurationByName", true);
    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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/metrics/{metric_name}https://api.ddog-gov.com/api/v1/metrics/{metric_name}https://api.datadoghq.com/api/v1/metrics/{metric_name}https://api.us3.datadoghq.com/api/v1/metrics/{metric_name}https://api.us5.datadoghq.com/api/v1/metrics/{metric_name}

Overview

Get metadata about a specific metric. This endpoint requires the metrics_read authorization scope.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

Name of the metric for which to get metadata.

Response

OK

Object with all metric related metadata.

Expand All

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.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Path parameters
export metric_name="CHANGE_ME"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Get metric metadata returns "OK" response
 */

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

const configuration = v1.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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Get metric metadata returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get metric metadata returns "OK" response

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

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

PUT https://api.datadoghq.eu/api/v1/metrics/{metric_name}https://api.ddog-gov.com/api/v1/metrics/{metric_name}https://api.datadoghq.com/api/v1/metrics/{metric_name}https://api.us3.datadoghq.com/api/v1/metrics/{metric_name}https://api.us5.datadoghq.com/api/v1/metrics/{metric_name}

Overview

Edit metadata of a specific metric. Find out more about supported types.

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.

Expand All

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.

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

Response

OK

Object with all metric related metadata.

Expand All

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.

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

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Path parameters
export metric_name="CHANGE_ME"
# Curl command curl -X PUT "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF {} EOF
"""
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Edit metric metadata returns "OK" response
 */

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

const configuration = v1.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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// Edit metric metadata returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	body := datadog.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)
	resp, r, err := apiClient.MetricsApi.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Edit metric metadata returns "OK" response

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

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers. If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.

PATCH https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://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. Can only be used with application keys from users with the Manage Tags for Metrics permission.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

The name of the metric.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Object for a single tag configuration to be edited.

attributes

object

Object containing the definition of a metric tag configuration to be updated.

aggregations

[object]

A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:

  • time: avg, space: avg
  • time: avg, space: max
  • time: avg, space: min
  • time: avg, space: sum
  • time: count, space: sum
  • time: max, space: max
  • time: min, space: min
  • time: sum, space: avg
  • time: sum, space: sum

Can only be applied to metrics that have a metric_type of count, rate, or gauge.

space [required]

enum

A space aggregation for use in query. Allowed enum values: avg,max,min,sum

time [required]

enum

A time aggregation for use in query. Allowed enum values: avg,count,max,min,sum

include_percentiles

boolean

Toggle to include/exclude percentiles for a distribution metric. Defaults to false. Can only be applied to metrics that have a metric_type of distribution.

tags

[string]

A list of tag keys that will be queryable for your metric.

id [required]

string

The metric name for this resource.

type [required]

enum

The metric tag configuration resource type. Allowed enum values: manage_tags

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

Response

OK

Response object which includes a single metric’s tag configuration.

Expand All

Field

Type

Description

data

object

Object for a single metric tag configuration.

attributes

object

Object containing the definition of a metric tag configuration attributes.

aggregations

[object]

A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:

  • time: avg, space: avg
  • time: avg, space: max
  • time: avg, space: min
  • time: avg, space: sum
  • time: count, space: sum
  • time: max, space: max
  • time: min, space: min
  • time: sum, space: avg
  • time: sum, space: sum

Can only be applied to metrics that have a metric_type of count, rate, or gauge.

space [required]

enum

A space aggregation for use in query. Allowed enum values: avg,max,min,sum

time [required]

enum

A time aggregation for use in query. Allowed enum values: avg,count,max,min,sum

created_at

date-time

Timestamp when the tag configuration was created.

include_percentiles

boolean

Toggle to turn on/off percentile aggregations for distribution metrics. Only present when the metric_type is distribution.

metric_type

enum

The metric's type. Allowed enum values: gauge,count,rate,distribution

modified_at

date-time

Timestamp when the tag configuration was last modified.

tags

[string]

List of tag keys on which to group.

id

string

The metric name for this resource.

type

enum

The metric tag configuration resource type. Allowed enum values: manage_tags

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

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Unprocessable Entity

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Path parameters
export metric_name="dist.http.endpoint.request"
# Curl command curl -X PATCH "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "aggregations": [ { "space": "sum", "time": "sum" } ] }, "id": "test.metric.latency", "type": "manage_tags" } } EOF
"""
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()
configuration.unstable_operations["update_tag_configuration"] = True
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Update a tag configuration returns "OK" response

require "datadog_api_client"
DatadogAPIClient::V2.configure do |config|
  config.unstable_operations[:update_tag_configuration] = true
end
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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Update a tag configuration returns "OK" response
 */

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

const configuration = v2.createConfiguration();
configuration.unstableOperations["updateTagConfiguration"] = true;
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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// Update a tag configuration returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	// there is a valid "metric_tag_configuration" in the system
	MetricTagConfigurationDataID := os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")

	body := datadog.MetricTagConfigurationUpdateRequest{
		Data: datadog.MetricTagConfigurationUpdateData{
			Type: datadog.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,
			Id:   MetricTagConfigurationDataID,
			Attributes: &datadog.MetricTagConfigurationUpdateAttributes{
				Tags: []string{
					"app",
				},
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("UpdateTagConfiguration", true)
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.UpdateTagConfiguration(ctx, MetricTagConfigurationDataID, body)

	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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Update a tag configuration returns "OK" response

import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.api.MetricsApi;
import com.datadog.api.v2.client.model.MetricTagConfigurationResponse;
import com.datadog.api.v2.client.model.MetricTagConfigurationType;
import com.datadog.api.v2.client.model.MetricTagConfigurationUpdateAttributes;
import com.datadog.api.v2.client.model.MetricTagConfigurationUpdateData;
import com.datadog.api.v2.client.model.MetricTagConfigurationUpdateRequest;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("updateTagConfiguration", true);
    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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/searchhttps://api.ddog-gov.com/api/v1/searchhttps://api.datadoghq.com/api/v1/searchhttps://api.us3.datadoghq.com/api/v1/searchhttps://api.us5.datadoghq.com/api/v1/search

Overview

Search for metrics from the last 24 hours in Datadog.

Arguments

Query Strings

Name

Type

Description

q [required]

string

Query string to search metrics upon. Can optionally be prefixed with metrics:.

Response

OK

Object containing the list of metrics matching the search query.

Expand All

Field

Type

Description

results

object

Search result.

metrics

[string]

List of metrics that match the search query.

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

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Required query arguments
export q="CHANGE_ME"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Search metrics returns "OK" response
 */

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

const configuration = v1.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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Search metrics returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Search metrics returns "OK" response

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

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers. If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.

DELETE https://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://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.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

The name of the metric.

Response

No Content

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Path parameters
export metric_name="dist.http.endpoint.request"
# Curl command curl -X DELETE "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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()
configuration.unstable_operations["delete_tag_configuration"] = True
with ApiClient(configuration) as api_client:
    api_instance = MetricsApi(api_client)
    api_instance.delete_tag_configuration(
        metric_name="ExampleDeleteatagconfigurationreturnsNoContentresponse",
    )

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Delete a tag configuration returns "No Content" response

require "datadog_api_client"
DatadogAPIClient::V2.configure do |config|
  config.unstable_operations[:delete_tag_configuration] = true
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
api_instance.delete_tag_configuration("ExampleDeleteatagconfigurationreturnsNoContentresponse")

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Delete a tag configuration returns "No Content" response
 */

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

const configuration = v2.createConfiguration();
configuration.unstableOperations["deleteTagConfiguration"] = true;
const apiInstance = new v2.MetricsApi(configuration);

const params: v2.MetricsApiDeleteTagConfigurationRequest = {
  metricName: "ExampleDeleteatagconfigurationreturnsNoContentresponse",
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// Delete a tag configuration returns "No Content" response

package main

import (
	"context"
	"fmt"
	"os"

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("DeleteTagConfiguration", true)
	apiClient := datadog.NewAPIClient(configuration)
	r, err := apiClient.MetricsApi.DeleteTagConfiguration(ctx, "ExampleDeleteatagconfigurationreturnsNoContentresponse")

	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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Delete a tag configuration returns "No Content" response

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

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("deleteTagConfiguration", true);
    MetricsApi apiInstance = new MetricsApi(defaultClient);

    try {
      apiInstance.deleteTagConfiguration("ExampleDeleteatagconfigurationreturnsNoContentresponse");
    } 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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"

Note: Use of this endpoint for count/gauge/rate metric types is only accessible for Metrics without Limits™ beta customers. If you’re interested in Metrics without Limits™, please contact your Customer Success Manager.

GET https://api.datadoghq.eu/api/v2/metricshttps://api.ddog-gov.com/api/v2/metricshttps://api.datadoghq.com/api/v2/metricshttps://api.us3.datadoghq.com/api/v2/metricshttps://api.us5.datadoghq.com/api/v2/metrics

Overview

Returns all configured count/gauge/rate/distribution metric names (with additional filters if specified). This endpoint requires the metrics_read authorization scope.

Arguments

Query Strings

Name

Type

Description

filter[configured]

boolean

Filter metrics that have configured tags.

filter[tags_configured]

string

Filter tag configurations by configured tags.

filter[metric_type]

enum

Filter tag configurations by metric type.
Allowed enum values: gauge, count, rate, distribution

filter[include_percentiles]

boolean

Filter distributions with additional percentile aggregations enabled or disabled.

filter[tags]

string

Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters.

window[seconds]

integer

The number of seconds of look back (from now) to apply to a filter[tag] query. Defaults value is 3600 (1 hour), maximum value is 172,800 (2 days).

Response

Success

Response object that includes metrics and metric tag configurations.

Expand All

Field

Type

Description

data

[object <oneOf>]

Array of metrics and metric tag configurations.

Option 1

object

Object for a single metric tag configuration.

id

string

The metric name for this resource.

type

enum

The metric resource type. Allowed enum values: metrics

Option 2

object

Object for a single metric tag configuration.

attributes

object

Object containing the definition of a metric tag configuration attributes.

aggregations

[object]

A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:

  • time: avg, space: avg
  • time: avg, space: max
  • time: avg, space: min
  • time: avg, space: sum
  • time: count, space: sum
  • time: max, space: max
  • time: min, space: min
  • time: sum, space: avg
  • time: sum, space: sum

Can only be applied to metrics that have a metric_type of count, rate, or gauge.

space [required]

enum

A space aggregation for use in query. Allowed enum values: avg,max,min,sum

time [required]

enum

A time aggregation for use in query. Allowed enum values: avg,count,max,min,sum

created_at

date-time

Timestamp when the tag configuration was created.

include_percentiles

boolean

Toggle to turn on/off percentile aggregations for distribution metrics. Only present when the metric_type is distribution.

metric_type

enum

The metric's type. Allowed enum values: gauge,count,rate,distribution

modified_at

date-time

Timestamp when the tag configuration was last modified.

tags

[string]

List of tag keys on which to group.

id

string

The metric name for this resource.

type

enum

The metric tag configuration resource type. Allowed enum values: manage_tags

{
  "data": [
    {
      "id": "test.metric.latency",
      "type": "metrics"
    }
  ]
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Curl command
curl -X GET "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 "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
List tag configurations returns "Success" response
"""

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

configuration = Configuration()
configuration.unstable_operations["list_tag_configurations"] = True
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# List tag configurations returns "Success" response

require "datadog_api_client"
DatadogAPIClient::V2.configure do |config|
  config.unstable_operations[:list_tag_configurations] = true
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
p api_instance.list_tag_configurations()

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * List tag configurations returns "Success" response
 */

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

const configuration = v2.createConfiguration();
configuration.unstableOperations["listTagConfigurations"] = true;
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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// List tag configurations returns "Success" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("ListTagConfigurations", true)
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.ListTagConfigurations(ctx, *datadog.NewListTagConfigurationsOptionalParameters())

	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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// List tag configurations returns "Success" response

import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.api.MetricsApi;
import com.datadog.api.v2.client.model.MetricsAndMetricTagConfigurationsResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("listTagConfigurations", true);
    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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v1/queryhttps://api.ddog-gov.com/api/v1/queryhttps://api.datadoghq.com/api/v1/queryhttps://api.us3.datadoghq.com/api/v1/queryhttps://api.us5.datadoghq.com/api/v1/query

Overview

Query timeseries points. This endpoint requires the timeseries_query authorization scope.

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

OK

Response Object that includes your query and the list of metrics retrieved.

Expand All

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.

aggr

string

Aggregation type.

display_name

string

Display name of the metric.

end

int64

End of the time window, milliseconds since Unix epoch.

expression

string

Metric expression.

interval

int64

Number of seconds between data samples.

length

int64

Number of data samples.

metric

string

Metric name.

pointlist

[array]

List of points of the time series.

query_index

int64

The index of the series' query within the request.

scope

string

Metric scope, comma separated list of tags.

start

int64

Start of the time window, milliseconds since Unix epoch.

tag_set

[string]

Unique tags identifying this series.

unit

[object]

Detailed information about the metric unit. First element describes the "primary unit" (for example, bytes in bytes per second), second describes the "per unit" (for example, second in bytes per second).

family

string

Unit family, allows for conversion between units of the same family, for scaling.

name

string

Unit name

plural

string

Plural form of the unit name.

scale_factor

double

Factor for scaling between units of the same family.

short_name

string

Abbreviation of the unit.

status

string

Status of the query.

to_date

int64

End of requested time window, milliseconds since Unix epoch.

{
  "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": [
        1575317847,
        0.5
      ],
      "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"
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


# Required query arguments
export from="CHANGE_ME"
export to="CHANGE_ME"
export query="CHANGE_ME"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Query timeseries points returns "OK" response
 */

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

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

const params: v1.MetricsApiQueryMetricsRequest = {
  from: new Date(new Date().getTime() / 1000 + -1 * 86400).getTime() / 1000,
  to: 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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// Query timeseries points returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.MetricsApi.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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Query timeseries points returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.MetricsApi;
import com.datadog.api.v1.client.model.MetricsQueryResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"

GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/all-tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/all-tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/all-tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/all-tagshttps://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/all-tags

Overview

View indexed tag key-value pairs for a given metric name.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

The name of the metric.

Response

Success

Response object that includes a single metric’s indexed tags.

Expand All

Field

Type

Description

data

object

Object for a single metric's indexed tags.

attributes

object

Object containing the definition of a metric's tags.

tags

[string]

List of indexed tag value pairs.

id

string

The metric name for this resource.

type

enum

The metric resource type. Allowed enum values: metrics

{
  "data": {
    "attributes": {
      "tags": [
        "sport:golf",
        "sport:football",
        "animal:dog"
      ]
    },
    "id": "test.metric.latency",
    "type": "metrics"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Path parameters
export metric_name="dist.http.endpoint.request"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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 and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * List tags by metric name returns "Success" response
 */

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

const configuration = v2.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 and then save the example to example.ts and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
// List tags by metric name returns "Success" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

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)
	resp, r, err := apiClient.MetricsApi.ListTagsByMetricName(ctx, MetricTagConfigurationDataID)

	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 and then save the example to main.go and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// List tags by metric name returns "Success" response

import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.api.MetricsApi;
import com.datadog.api.v2.client.model.MetricAllTagsResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 and then save the example to Example.java and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"

GET https://api.datadoghq.eu/api/v2/metrics/{metric_name}/volumeshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/volumeshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/volumeshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/volumeshttps://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/volumes

Overview

View distinct metrics volumes for the given metric name.

Custom distribution metrics will return both ingested and indexed custom metric volumes. For Metrics without Limits™ beta customers, all metrics will return both ingested/indexed volumes. Custom metrics generated in-app from other products will return null for ingested volumes.

Arguments

Path Parameters

Name

Type

Description

metric_name [required]

string

The name of the metric.

Response

Success

Response object which includes a single metric’s volume.

Expand All

Field

Type

Description

data

object <oneOf>

Possible response objects for a metric's volume.

Option 1

object

Object for a single metric's distinct volume.

attributes

object

Object containing the definition of a metric's distinct volume.

distinct_volume

int64

Distinct volume for the given metric.

id

string

The metric name for this resource.

type

enum

The metric distinct volume type. Allowed enum values: distinct_metric_volumes

Option 2

object

Object for a single metric's ingested and indexed volume.

attributes

object

Object containing the definition of a metric's ingested and indexed volume.

indexed_volume

int64

Indexed volume for the given metric.

ingested_volume

int64

Ingested volume for the given metric.

id

string

The metric name for this resource.

type

enum

The metric ingested and indexed volume type. Allowed enum values: metric_volumes

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

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too Many Requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


# Path parameters
export metric_name="dist.http.endpoint.request"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
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="ExampleListdistinctmetricvolumesbymetricnamereturnsSuccessresponse",
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

              
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# List distinct metric volumes by metric name returns "