The metrics endpoint allows you to:
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.
Datadog has a soft limit of 100 timeseries per host where a timeseries is defined as a unique combination of metric name and tag.
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}/tags
Create and define a list of queryable tag keys for a count/gauge/rate/distribution metric. Optionally, include percentile aggregations on any distribution metric.
Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Name
Type
Description
metric_name [required]
string
The name of the metric.
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.
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,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": {
"attributes": {
"include_percentiles": true,
"metric_type": "count",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
Created
Response object which includes a single metric’s tag configuration.
Field
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
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,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": {
"created_at": "2020-03-31T09:48:37.463835Z",
"include_percentiles": true,
"metric_type": "count",
"modified_at": "2020-03-31T09:48:37.463835Z",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Forbidden
API error response.
{
"errors": [
"Bad Request"
]
}
Conflict
API error response.
{
"errors": [
"Bad Request"
]
}
Too Many Requests
API error response.
{
"errors": [
"Bad Request"
]
}
# 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/api/v2/metrics/${metric_name}/tags" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
"data": {
"attributes": {
"metric_type": "count",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
EOF
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
metricName := "dist.http.endpoint.request" // string | The name of the metric.
body := *datadog.NewMetricTagConfigurationCreateRequest(*datadog.NewMetricTagConfigurationCreateData("test.metric.latency", datadog.MetricTagConfigurationType("manage_tags"))) // MetricTagConfigurationCreateRequest |
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("CreateTagConfiguration", true)
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.CreateTagConfiguration(ctx, metricName).Body(body).Execute()
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)
}
// response from `CreateTagConfiguration`: MetricTagConfigurationResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.CreateTagConfiguration:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String metricName = "dist.http.endpoint.request"; // String | The name of the metric.
MetricTagConfigurationCreateRequest body = new MetricTagConfigurationCreateRequest(); // MetricTagConfigurationCreateRequest |
try {
MetricTagConfigurationResponse result = apiInstance.createTagConfiguration(metricName)
.body(body)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v2 import ApiClient, ApiException, Configuration
from datadog_api_client.v2.api import metrics_api
from datadog_api_client.v2.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
configuration.unstable_operations["create_tag_configuration"] = True
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
metric_name = "dist.http.endpoint.request" # str | The name of the metric.
body = MetricTagConfigurationCreateRequest(
data=MetricTagConfigurationCreateData(
attributes=MetricTagConfigurationCreateAttributes(
include_percentiles=True,
metric_type=MetricTagConfigurationMetricTypes("count"),
tags=["app","datacenter"],
),
id="test.metric.latency",
type=MetricTagConfigurationType("manage_tags"),
),
) # MetricTagConfigurationCreateRequest |
# example passing only required values which don't have defaults set
try:
# Create a Tag Configuration
api_response = api_instance.create_tag_configuration(metric_name, body)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->create_tag_configuration: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V2.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
config.unstable_operations[:create_tag_configuration] = true
end
api_instance = DatadogAPIClient::V2::MetricsApi.new
metric_name = 'dist.http.endpoint.request' # String | The name of the metric.
body = DatadogAPIClient::V2::MetricTagConfigurationCreateRequest.new({data: DatadogAPIClient::V2::MetricTagConfigurationCreateData.new({id: 'test.metric.latency', type: DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS})}) # MetricTagConfigurationCreateRequest |
begin
# Create a Tag Configuration
result = api_instance.create_tag_configuration(metric_name, body)
p result
rescue DatadogAPIClient::V2::ApiError => e
puts "Error when calling MetricsApi->create_tag_configuration: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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}/tags
Deletes a metric’s tag configuration. Can only be used with application
keys from users with the Manage Tags for Metrics
permission.
Name
Type
Description
metric_name [required]
string
The name of the metric.
No Content
Forbidden
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too Many Requests
API error response.
{
"errors": [
"Bad Request"
]
}
# 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/api/v2/metrics/${metric_name}/tags" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
metricName := "dist.http.endpoint.request" // string | The name of the metric.
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("DeleteTagConfiguration", true)
api_client := datadog.NewAPIClient(configuration)
r, err := api_client.MetricsApi.DeleteTagConfiguration(ctx, metricName).Execute()
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)
}
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String metricName = "dist.http.endpoint.request"; // String | The name of the metric.
try {
apiInstance.deleteTagConfiguration(metricName)
.execute();
} 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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v2 import ApiClient, ApiException, Configuration
from datadog_api_client.v2.api import metrics_api
from datadog_api_client.v2.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
configuration.unstable_operations["delete_tag_configuration"] = True
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
metric_name = "dist.http.endpoint.request" # str | The name of the metric.
# example passing only required values which don't have defaults set
try:
# Delete a Tag Configuration
api_instance.delete_tag_configuration(metric_name)
except ApiException as e:
print("Exception when calling MetricsApi->delete_tag_configuration: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V2.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
config.unstable_operations[:delete_tag_configuration] = true
end
api_instance = DatadogAPIClient::V2::MetricsApi.new
metric_name = 'dist.http.endpoint.request' # String | The name of the metric.
begin
# Delete a Tag Configuration
api_instance.delete_tag_configuration(metric_name)
rescue DatadogAPIClient::V2::ApiError => e
puts "Error when calling MetricsApi->delete_tag_configuration: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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}
Edit metadata of a specific metric. Find out more about supported types.
Name
Type
Description
metric_name [required]
string
Name of the metric for which to edit metadata.
New metadata.
{
"description": "string",
"per_unit": "second",
"short_name": "string",
"statsd_interval": "integer",
"type": "count",
"unit": "byte"
}
OK
Object with all metric related metadata.
{
"description": "string",
"integration": "string",
"per_unit": "second",
"short_name": "string",
"statsd_interval": "integer",
"type": "count",
"unit": "byte"
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Not Found
Error response object.
{
"errors": [
"Bad Request"
]
}
# 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/api/v1/metrics/${metric_name}" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{}
EOF
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
metricName := "metricName_example" // string | Name of the metric for which to edit metadata.
body := *datadog.NewMetricMetadata() // MetricMetadata | New metadata.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.UpdateMetricMetadata(ctx, metricName).Body(body).Execute()
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)
}
// response from `UpdateMetricMetadata`: MetricMetadata
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.UpdateMetricMetadata:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String metricName = "metricName_example"; // String | Name of the metric for which to edit metadata.
MetricMetadata body = new MetricMetadata(); // MetricMetadata | New metadata.
try {
MetricMetadata result = apiInstance.updateMetricMetadata(metricName)
.body(body)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
metric_name = "metric_name_example" # str | Name of the metric for which to edit metadata.
body = MetricMetadata(
description="description_example",
integration="integration_example",
per_unit="second",
short_name="short_name_example",
statsd_interval=1,
type="count",
unit="byte",
) # MetricMetadata | New metadata.
# example passing only required values which don't have defaults set
try:
# Edit metric metadata
api_response = api_instance.update_metric_metadata(metric_name, body)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->update_metric_metadata: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V1.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
end
api_instance = DatadogAPIClient::V1::MetricsApi.new
metric_name = 'metric_name_example' # String | Name of the metric for which to edit metadata.
body = DatadogAPIClient::V1::MetricMetadata.new # MetricMetadata | New metadata.
begin
# Edit metric metadata
result = api_instance.update_metric_metadata(metric_name, body)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling MetricsApi->update_metric_metadata: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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/metrics
Get the list of actively reporting metrics from a given time until now.
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.
OK
Object listing all metric names stored by Datadog since a given time.
{
"from": "string",
"metrics": []
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
# 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/api/v1/metrics?from=${from}" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
from := int64(789) // int64 | Seconds since the Unix epoch.
host := "host_example" // string | Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag. (optional)
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.ListActiveMetrics(ctx).From(from).Host(host).Execute()
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)
}
// response from `ListActiveMetrics`: MetricsListResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.ListActiveMetrics:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
Long from = 56L; // Long | Seconds since the Unix epoch.
String host = "host_example"; // String | Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag.
try {
MetricsListResponse result = apiInstance.listActiveMetrics()
.from(from)
.host(host)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
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)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python "example.py"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
_from = 1 # int | Seconds since the Unix epoch.
host = "host_example" # str | Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag. (optional)
# example passing only required values which don't have defaults set
try:
# Get active metrics list
api_response = api_instance.list_active_metrics(_from)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->list_active_metrics: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get active metrics list
api_response = api_instance.list_active_metrics(_from, host=host)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->list_active_metrics: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V1.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
end
api_instance = DatadogAPIClient::V1::MetricsApi.new
from = 789 # Integer | Seconds since the Unix epoch.
opts = {
host: 'host_example' # String | Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag.
}
begin
# Get active metrics list
result = api_instance.list_active_metrics(from, opts)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling MetricsApi->list_active_metrics: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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}
Get metadata about a specific metric.
Name
Type
Description
metric_name [required]
string
Name of the metric for which to get metadata.
OK
Object with all metric related metadata.
{
"description": "string",
"integration": "string",
"per_unit": "second",
"short_name": "string",
"statsd_interval": "integer",
"type": "count",
"unit": "byte"
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Not Found
Error response object.
{
"errors": [
"Bad Request"
]
}
# 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/api/v1/metrics/${metric_name}" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
metricName := "metricName_example" // string | Name of the metric for which to get metadata.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.GetMetricMetadata(ctx, metricName).Execute()
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)
}
// response from `GetMetricMetadata`: MetricMetadata
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.GetMetricMetadata:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String metricName = "metricName_example"; // String | Name of the metric for which to get metadata.
try {
MetricMetadata result = apiInstance.getMetricMetadata(metricName)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
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)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python "example.py"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
metric_name = "metric_name_example" # str | Name of the metric for which to get metadata.
# example passing only required values which don't have defaults set
try:
# Get metric metadata
api_response = api_instance.get_metric_metadata(metric_name)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->get_metric_metadata: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
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')
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V1.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
end
api_instance = DatadogAPIClient::V1::MetricsApi.new
metric_name = 'metric_name_example' # String | Name of the metric for which to get metadata.
begin
# Get metric metadata
result = api_instance.get_metric_metadata(metric_name)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling MetricsApi->get_metric_metadata: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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}/tags
Returns the tag configuration for the given metric name.
Name
Type
Description
metric_name [required]
string
The name of the metric.
Success
Response object which includes a single metric’s tag configuration.
Field
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
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,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": {
"created_at": "2020-03-31T09:48:37.463835Z",
"include_percentiles": true,
"metric_type": "count",
"modified_at": "2020-03-31T09:48:37.463835Z",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
Forbidden
API error response.
{
"errors": [
"Bad Request"
]
}
Not Found
API error response.
{
"errors": [
"Bad Request"
]
}
Too Many Requests
API error response.
{
"errors": [
"Bad Request"
]
}
# 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/api/v2/metrics/${metric_name}/tags" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
metricName := "dist.http.endpoint.request" // string | The name of the metric.
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("ListTagConfigurationByName", true)
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.ListTagConfigurationByName(ctx, metricName).Execute()
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)
}
// response from `ListTagConfigurationByName`: MetricTagConfigurationResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.ListTagConfigurationByName:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String metricName = "dist.http.endpoint.request"; // String | The name of the metric.
try {
MetricTagConfigurationResponse result = apiInstance.listTagConfigurationByName(metricName)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v2 import ApiClient, ApiException, Configuration
from datadog_api_client.v2.api import metrics_api
from datadog_api_client.v2.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
configuration.unstable_operations["list_tag_configuration_by_name"] = True
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
metric_name = "dist.http.endpoint.request" # str | The name of the metric.
# example passing only required values which don't have defaults set
try:
# List Tag Configuration by Name
api_response = api_instance.list_tag_configuration_by_name(metric_name)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->list_tag_configuration_by_name: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V2.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
config.unstable_operations[:list_tag_configuration_by_name] = true
end
api_instance = DatadogAPIClient::V2::MetricsApi.new
metric_name = 'dist.http.endpoint.request' # String | The name of the metric.
begin
# List Tag Configuration by Name
result = api_instance.list_tag_configuration_by_name(metric_name)
p result
rescue DatadogAPIClient::V2::ApiError => e
puts "Error when calling MetricsApi->list_tag_configuration_by_name: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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/metrics
Returns all configured count/gauge/rate/distribution metric names (with additional filters if specified).
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]
string
Filter tag configurations by metric type.
filter[include_percentiles]
boolean
Filter distributions with additional percentile aggregations enabled or disabled.
Success
Response object that includes metrics and metric tag configurations.
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.
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,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": []
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Forbidden
API error response.
{
"errors": [
"Bad Request"
]
}
Too Many Requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com/api/v2/metrics" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
filterConfigured := true // bool | Filter metrics that have configured tags. (optional)
filterTagsConfigured := "app" // string | Filter tag configurations by configured tags. (optional)
filterMetricType := datadog.MetricTagConfigurationMetricTypes("gauge") // MetricTagConfigurationMetricTypes | Filter tag configurations by metric type. (optional) (default to "gauge")
filterIncludePercentiles := true // bool | Filter distributions with additional percentile aggregations enabled or disabled. (optional)
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("ListTagConfigurations", true)
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.ListTagConfigurations(ctx).FilterConfigured(filterConfigured).FilterTagsConfigured(filterTagsConfigured).FilterMetricType(filterMetricType).FilterIncludePercentiles(filterIncludePercentiles).Execute()
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)
}
// response from `ListTagConfigurations`: MetricsAndMetricTagConfigurationsResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.ListTagConfigurations:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
Boolean filterConfigured = true; // Boolean | Filter metrics that have configured tags.
String filterTagsConfigured = "app"; // String | Filter tag configurations by configured tags.
MetricTagConfigurationMetricTypes filterMetricType = MetricTagConfigurationMetricTypes.fromValue("gauge"); // MetricTagConfigurationMetricTypes | Filter tag configurations by metric type.
Boolean filterIncludePercentiles = true; // Boolean | Filter distributions with additional percentile aggregations enabled or disabled.
try {
MetricsAndMetricTagConfigurationsResponse result = apiInstance.listTagConfigurations()
.filterConfigured(filterConfigured)
.filterTagsConfigured(filterTagsConfigured)
.filterMetricType(filterMetricType)
.filterIncludePercentiles(filterIncludePercentiles)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v2 import ApiClient, ApiException, Configuration
from datadog_api_client.v2.api import metrics_api
from datadog_api_client.v2.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
configuration.unstable_operations["list_tag_configurations"] = True
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
filter_configured = True # bool | Filter metrics that have configured tags. (optional)
filter_tags_configured = "app" # str | Filter tag configurations by configured tags. (optional)
filter_metric_type = MetricTagConfigurationMetricTypes("count") # MetricTagConfigurationMetricTypes | Filter tag configurations by metric type. (optional)
filter_include_percentiles = True # bool | Filter distributions with additional percentile aggregations enabled or disabled. (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# List Tag Configurations
api_response = api_instance.list_tag_configurations(filter_configured=filter_configured, filter_tags_configured=filter_tags_configured, filter_metric_type=filter_metric_type, filter_include_percentiles=filter_include_percentiles)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->list_tag_configurations: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V2.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
config.unstable_operations[:list_tag_configurations] = true
end
api_instance = DatadogAPIClient::V2::MetricsApi.new
opts = {
filter_configured: true, # Boolean | Filter metrics that have configured tags.
filter_tags_configured: 'app', # String | Filter tag configurations by configured tags.
filter_metric_type: DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE, # MetricTagConfigurationMetricTypes | Filter tag configurations by metric type.
filter_include_percentiles: true # Boolean | Filter distributions with additional percentile aggregations enabled or disabled.
}
begin
# List Tag Configurations
result = api_instance.list_tag_configurations(opts)
p result
rescue DatadogAPIClient::V2::ApiError => e
puts "Error when calling MetricsApi->list_tag_configurations: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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/query
Query timeseries points.
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.
OK
Response Object that includes your query and the list of metrics retrieved.
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.
scope
string
Metric scope, comma separated list of tags.
start
int64
Start of the time window, milliseconds since Unix epoch.
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
],
"scope": "host:foo,env:test",
"start": "integer",
"unit": [
{
"family": "time",
"name": "minute",
"plural": "minutes",
"scale_factor": 60,
"short_name": "min"
}
]
}
],
"status": "ok",
"to_date": "integer"
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
# 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/api/v1/query?from=${from}&to=${to}&query=${query}" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
from := int64(789) // int64 | Start of the queried time period, seconds since the Unix epoch.
to := int64(789) // int64 | End of the queried time period, seconds since the Unix epoch.
query := "query_example" // string | Query string.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.QueryMetrics(ctx).From(from).To(to).Query(query).Execute()
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)
}
// response from `QueryMetrics`: MetricsQueryResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.QueryMetrics:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
Long from = 56L; // Long | Start of the queried time period, seconds since the Unix epoch.
Long to = 56L; // Long | End of the queried time period, seconds since the Unix epoch.
String query = "query_example"; // String | Query string.
try {
MetricsQueryResponse result = apiInstance.queryMetrics()
.from(from)
.to(to)
.query(query)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
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))
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python "example.py"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
_from = 1 # int | Start of the queried time period, seconds since the Unix epoch.
to = 1 # int | End of the queried time period, seconds since the Unix epoch.
query = "query_example" # str | Query string.
# example passing only required values which don't have defaults set
try:
# Query timeseries points
api_response = api_instance.query_metrics(_from, to, query)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->query_metrics: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
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)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V1.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
end
api_instance = DatadogAPIClient::V1::MetricsApi.new
from = 789 # Integer | Start of the queried time period, seconds since the Unix epoch.
to = 789 # Integer | End of the queried time period, seconds since the Unix epoch.
query = 'query_example' # String | Query string.
begin
# Query timeseries points
result = api_instance.query_metrics(from, to, query)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling MetricsApi->query_metrics: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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/search
Search for metrics from the last 24 hours in Datadog.
Name
Type
Description
q [required]
string
Query string to search metrics upon. Must be prefixed with metrics:
.
OK
Object containing the list of metrics matching the search query.
Field
Type
Description
results
object
Search result.
metrics
[string]
List of metrics that match the search query.
{
"results": {
"metrics": []
}
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
# 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/api/v1/search?q=${q}" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
q := "q_example" // string | Query string to search metrics upon. Must be prefixed with `metrics:`.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.ListMetrics(ctx).Q(q).Execute()
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)
}
// response from `ListMetrics`: MetricSearchResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.ListMetrics:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String q = "q_example"; // String | Query string to search metrics upon. Must be prefixed with `metrics:`.
try {
MetricSearchResponse result = apiInstance.listMetrics()
.q(q)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
q = "q_example" # str | Query string to search metrics upon. Must be prefixed with `metrics:`.
# example passing only required values which don't have defaults set
try:
# Search metrics
api_response = api_instance.list_metrics(q)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->list_metrics: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
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")
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V1.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
end
api_instance = DatadogAPIClient::V1::MetricsApi.new
q = 'q_example' # String | Query string to search metrics upon. Must be prefixed with `metrics:`.
begin
# Search metrics
result = api_instance.list_metrics(q)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling MetricsApi->list_metrics: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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/series
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). Compressed payloads must have a decompressed size of up to 62 megabytes (62914560).
If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect
Field
Type
Description
series
[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 either count
, gauge
, or rate
.
{
"series": [
{
"host": "test.example.com",
"interval": 20,
"metric": "system.load.1",
"points": [
[
1575317847,
0.5
]
],
"tags": [
"environment:test"
],
"type": "rate"
}
]
}
Payload accepted
The payload accepted for intake.
{
"status": "ok"
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Authentication error
Error response object.
{
"errors": [
"Bad Request"
]
}
Request timeout
Error response object.
{
"errors": [
"Bad Request"
]
}
Payload too large
Error response object.
{
"errors": [
"Bad Request"
]
}
## Dynamic Points
# TODO.
# 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/api/v1/series?api_key=${DD_CLIENT_API_KEY}" \
-H "Content-Type: application/json" \
-d @- << EOF
{
"series": [
{
"metric": "system.load.1",
"points": [
[
"${NOW}",
"1234.5"
]
]
}
]
}
EOF
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
}])
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python "example.py"
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
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"
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}/tags
Update the tag configuration of a metric or percentile aggregations of a distribution metric. Can only be used with
application keys from users with the Manage Tags for Metrics
permission.
Name
Type
Description
metric_name [required]
string
The name of the metric.
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.
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": {
"attributes": {
"include_percentiles": true,
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
OK
Response object which includes a single metric’s tag configuration.
Field
Type
Description
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
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,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": {
"created_at": "2020-03-31T09:48:37.463835Z",
"include_percentiles": true,
"metric_type": "count",
"modified_at": "2020-03-31T09:48:37.463835Z",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Forbidden
API error response.
{
"errors": [
"Bad Request"
]
}
Unprocessable Entity
API error response.
{
"errors": [
"Bad Request"
]
}
Too Many Requests
API error response.
{
"errors": [
"Bad Request"
]
}
# 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/api/v2/metrics/${metric_name}/tags" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
"data": {
"id": "test.metric.latency",
"type": "manage_tags"
}
}
EOF
package main
import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)
func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)
if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}
metricName := "dist.http.endpoint.request" // string | The name of the metric.
body := *datadog.NewMetricTagConfigurationUpdateRequest(*datadog.NewMetricTagConfigurationUpdateData("test.metric.latency", datadog.MetricTagConfigurationType("manage_tags"))) // MetricTagConfigurationUpdateRequest |
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("UpdateTagConfiguration", true)
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.MetricsApi.UpdateTagConfiguration(ctx, metricName).Body(body).Execute()
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)
}
// response from `UpdateTagConfiguration`: MetricTagConfigurationResponse
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from MetricsApi.UpdateTagConfiguration:\n%s\n", response_content)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
go "main.go"
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.MetricsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure the Datadog site to send API calls to
HashMap<String, String> serverVariables = new HashMap<String, String>();
String site = System.getenv("DD_SITE");
if (site != null) {
serverVariables.put("site", site);
defaultClient.setServerVariables(serverVariables);
}
// Configure API key authorization:
HashMap<String, String> secrets = new HashMap<String, String>();
secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
defaultClient.configureApiKeys(secrets);
MetricsApi apiInstance = new MetricsApi(defaultClient);
String metricName = "dist.http.endpoint.request"; // String | The name of the metric.
MetricTagConfigurationUpdateRequest body = new MetricTagConfigurationUpdateRequest(); // MetricTagConfigurationUpdateRequest |
try {
MetricTagConfigurationResponse result = apiInstance.updateTagConfiguration(metricName)
.body(body)
.execute();
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
java "Example.java"
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v2 import ApiClient, ApiException, Configuration
from datadog_api_client.v2.api import metrics_api
from datadog_api_client.v2.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()
# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
configuration.unstable_operations["update_tag_configuration"] = True
# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = metrics_api.MetricsApi(api_client)
metric_name = "dist.http.endpoint.request" # str | The name of the metric.
body = MetricTagConfigurationUpdateRequest(
data=MetricTagConfigurationUpdateData(
attributes=MetricTagConfigurationUpdateAttributes(
include_percentiles=True,
tags=["app","datacenter"],
),
id="test.metric.latency",
type=MetricTagConfigurationType("manage_tags"),
),
) # MetricTagConfigurationUpdateRequest |
# example passing only required values which don't have defaults set
try:
# Update a Tag Configuration
api_response = api_instance.update_tag_configuration(metric_name, body)
pprint(api_response)
except ApiException as e:
print("Exception when calling MetricsApi->update_tag_configuration: %s\n" % e)
First install the library and its dependencies and then save the example to example.py
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
python3 "example.py"
require 'time'
require 'datadog_api_client'
DatadogAPIClient::V2.configure do |config|
# Defining the site is optional and defaults to datadoghq.com
config.server_variables['site'] = ENV["DD_SITE"] if ENV.key? 'DD_SITE'
# setup authorization
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
config.unstable_operations[:update_tag_configuration] = true
end
api_instance = DatadogAPIClient::V2::MetricsApi.new
metric_name = 'dist.http.endpoint.request' # String | The name of the metric.
body = DatadogAPIClient::V2::MetricTagConfigurationUpdateRequest.new({data: DatadogAPIClient::V2::MetricTagConfigurationUpdateData.new({id: 'test.metric.latency', type: DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS})}) # MetricTagConfigurationUpdateRequest |
begin
# Update a Tag Configuration
result = api_instance.update_tag_configuration(metric_name, body)
p result
rescue DatadogAPIClient::V2::ApiError => e
puts "Error when calling MetricsApi->update_tag_configuration: #{e}"
end
First install the library and its dependencies and then save the example to example.rb
and run following commands:
export DD_SITE="https://api.datadoghq.euhttps://api.ddog-gov.comhttps://api.datadoghq.comhttps://api.us3.datadoghq.com"
rb "example.rb"