- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
メトリクスエンドポイントでは、次のことができます。
注: グラフには設定された数のポイントのみを含めることができ、 メトリクスが表示されるタイムフレームが長くなると、 ポイント間の集計が発生してその設定された数を下回ります。
manage_tags
を Post、Patch、Delete する API メソッドは
Manage Tags for Metrics
アクセス許可を持つユーザーのみが実行できます。
POST https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags
Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric.
Optionally, include percentile aggregations on any distribution metric or configure custom aggregations
on any count, rate, or gauge metric. By setting exclude_tags_mode
to true the behavior is changed
from an allow-list to a deny-list, and tags in the defined list will not be queryable.
Can only be used with application keys of users with the Manage Tags for Metrics
permission.
名前
種類
説明
metric_name [required]
string
The name of the metric.
フィールド
種類
説明
data [required]
object
Object for a single metric to be configure tags on.
attributes
object
Object containing the definition of a metric tag configuration to be created.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:
Can only be applied to metrics that have a metric_type
of count
, rate
, or gauge
.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags
property.
include_percentiles
boolean
Toggle to include/exclude percentiles for a distribution metric.
Defaults to false. Can only be applied to metrics that have a metric_type
of distribution
.
metric_type [required]
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
tags [required]
[string]
A list of tag keys that will be queryable for your metric.
default:
id [required]
string
The metric name for this resource.
type [required]
enum
The metric tag configuration resource type.
Allowed enum values: manage_tags
default: manage_tags
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
Created
Response object which includes a single metric’s tag configuration.
フィールド
種類
説明
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:
Can only be applied to metrics that have a metric_type
of count
, rate
, or gauge
.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags
property.
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type
is distribution
.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
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
default: manage_tags
{
"data": {
"attributes": {
"aggregations": [
{
"space": "sum",
"time": "sum"
}
],
"created_at": "2020-03-25T09:48:37.463835Z",
"exclude_tags_mode": false,
"include_percentiles": true,
"metric_type": "count",
"modified_at": "2020-03-25T09:48:37.463835Z",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
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.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF
// Create a tag configuration returns "Created" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.MetricTagConfigurationCreateRequest{
Data: datadogV2.MetricTagConfigurationCreateData{
Type: datadogV2.METRICTAGCONFIGURATIONTYPE_MANAGE_TAGS,
Id: "ExampleMetric",
Attributes: &datadogV2.MetricTagConfigurationCreateAttributes{
Tags: []string{
"app",
"datacenter",
},
MetricType: datadogV2.METRICTAGCONFIGURATIONMETRICTYPES_GAUGE,
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.CreateTagConfiguration(ctx, "ExampleMetric", body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.CreateTagConfiguration`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.CreateTagConfiguration`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Create a tag configuration returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateAttributes;
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateData;
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateRequest;
import com.datadog.api.client.v2.model.MetricTagConfigurationMetricTypes;
import com.datadog.api.client.v2.model.MetricTagConfigurationResponse;
import com.datadog.api.client.v2.model.MetricTagConfigurationType;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
MetricTagConfigurationCreateRequest body =
new MetricTagConfigurationCreateRequest()
.data(
new MetricTagConfigurationCreateData()
.type(MetricTagConfigurationType.MANAGE_TAGS)
.id("ExampleMetric")
.attributes(
new MetricTagConfigurationCreateAttributes()
.tags(Arrays.asList("app", "datacenter"))
.metricType(MetricTagConfigurationMetricTypes.GAUGE)));
try {
MetricTagConfigurationResponse result =
apiInstance.createTagConfiguration("ExampleMetric", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#createTagConfiguration");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
"""
Create a tag configuration returns "Created" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_tag_configuration_create_attributes import (
MetricTagConfigurationCreateAttributes,
)
from datadog_api_client.v2.model.metric_tag_configuration_create_data import MetricTagConfigurationCreateData
from datadog_api_client.v2.model.metric_tag_configuration_create_request import MetricTagConfigurationCreateRequest
from datadog_api_client.v2.model.metric_tag_configuration_metric_types import MetricTagConfigurationMetricTypes
from datadog_api_client.v2.model.metric_tag_configuration_type import MetricTagConfigurationType
body = MetricTagConfigurationCreateRequest(
data=MetricTagConfigurationCreateData(
type=MetricTagConfigurationType.MANAGE_TAGS,
id="ExampleMetric",
attributes=MetricTagConfigurationCreateAttributes(
tags=[
"app",
"datacenter",
],
metric_type=MetricTagConfigurationMetricTypes.GAUGE,
),
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.create_tag_configuration(metric_name="ExampleMetric", body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Create a tag configuration returns "Created" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::MetricTagConfigurationCreateRequest.new({
data: DatadogAPIClient::V2::MetricTagConfigurationCreateData.new({
type: DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS,
id: "ExampleMetric",
attributes: DatadogAPIClient::V2::MetricTagConfigurationCreateAttributes.new({
tags: [
"app",
"datacenter",
],
metric_type: DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE,
}),
}),
})
p api_instance.create_tag_configuration("ExampleMetric", body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
* Create a tag configuration returns "Created" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiCreateTagConfigurationRequest = {
body: {
data: {
type: "manage_tags",
id: "ExampleMetric",
attributes: {
tags: ["app", "datacenter"],
metricType: "gauge",
},
},
},
metricName: "ExampleMetric",
};
apiInstance
.createTagConfiguration(params)
.then((data: v2.MetricTagConfigurationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v1/metricshttps://api.datadoghq.eu/api/v1/metricshttps://api.ddog-gov.com/api/v1/metricshttps://api.datadoghq.com/api/v1/metricshttps://api.us3.datadoghq.com/api/v1/metricshttps://api.us5.datadoghq.com/api/v1/metrics
特定の時間から現在までアクティブに報告しているメトリクスのリストを取得します。
This endpoint requires the metrics_read
authorization scope.
名前
種類
説明
from [required]
integer
Seconds since the Unix epoch.
host
string
Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag.
tag_filter
string
Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters.
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"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Required query arguments
export from="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/metrics?from=${from}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get active metrics list returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.list_active_metrics(
_from=9223372036854775807,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get active metrics list returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
p api_instance.list_active_metrics(9223372036854775807)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get active metrics list returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMetricsApi(apiClient)
resp, r, err := api.ListActiveMetrics(ctx, 9223372036854775807, *datadogV1.NewListActiveMetricsOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.ListActiveMetrics`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.ListActiveMetrics`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get active metrics list returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricsListResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
try {
MetricsListResponse result = apiInstance.listActiveMetrics(9223372036854775807L);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#listActiveMetrics");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api
import time
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
# Taking the last 24hours
from_time = int(time.time()) - 60 * 60 * 24 * 1
result = api.Metric.list(from_time)
print(result)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
/**
* Get active metrics list returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.MetricsApi(configuration);
const params: v1.MetricsApiListActiveMetricsRequest = {
from: 9223372036854775807,
};
apiInstance
.listActiveMetrics(params)
.then((data: v1.MetricsListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
Note: This endpoint is GA for Metrics, Real User Monitoring (RUM), and Cloud Cost Management data sources. Support for logs is in beta. We are gradually onboarding support for more sources. If you have any feedback, contact Datadog Support.
POST https://api.ap1.datadoghq.com/api/v2/query/timeserieshttps://api.datadoghq.eu/api/v2/query/timeserieshttps://api.ddog-gov.com/api/v2/query/timeserieshttps://api.datadoghq.com/api/v2/query/timeserieshttps://api.us3.datadoghq.com/api/v2/query/timeserieshttps://api.us5.datadoghq.com/api/v2/query/timeseries
Query timeseries data across various data sources and
process the data by applying formulas and functions.
This endpoint requires the timeseries_query
authorization scope.
フィールド
種類
説明
data [required]
object
A single timeseries query to be executed.
attributes [required]
object
The object describing a timeseries formula request.
formulas
[object]
List of formulas to be calculated and returned as responses.
formula [required]
string
Formula string, referencing one or more queries with their name property.
limit
object
Message for specifying limits to the number of values returned by a query. This limit is only for scalar queries and has no effect on timeseries queries.
count
int32
The number of results to which to limit.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
from [required]
int64
Start date (inclusive) of the query in milliseconds since the Unix epoch.
interval
int64
A time interval in milliseconds. May be overridden by a larger interval if the query would result in too many points for the specified timeframe. Defaults to a reasonable interval for the given timeframe.
queries [required]
[ <oneOf>]
List of queries to be run and used as inputs to the formulas.
Option 1
object
An individual timeseries metrics query.
data_source [required]
enum
A data source that is powered by the Metrics platform.
Allowed enum values: metrics,cloud_cost
default: metrics
name
string
The variable name for use in formulas.
query [required]
string
A classic metrics query string.
Option 2
object
An individual timeseries events query.
compute [required]
object
The instructions for what to compute for this query.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,max,avg
default: count
interval
int64
Interval for compute in milliseconds.
metric
string
The "measure" attribute on which to perform the computation.
data_source [required]
enum
A data source that is powered by the Events Platform.
Allowed enum values: logs,rum
default: logs
group_by
[object]
The list of facets on which to split results.
facet [required]
string
The facet by which to split groups.
limit
int32
The maximum number of groups to return.
sort
object
The dimension by which to sort a query's results.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,max,avg
default: count
metric
string
The metric's calculated value which should be used to define the sort order of a query's results.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
type
enum
The type of sort to use on the calculated value.
Allowed enum values: alphabetical,measure
indexes
[string]
The indexes in which to search.
name
string
The variable name for use in formulas.
search
object
Configuration of the search/filter for an events query.
query
string
The search/filter string for an events query.
to [required]
int64
End date (exclusive) of the query in milliseconds since the Unix epoch.
type [required]
enum
The type of the resource. The value should always be timeseries_request.
Allowed enum values: timeseries_request
default: timeseries_request
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1671612804000,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:system.cpu.user{*}",
"name": "a"
}
],
"to": 1671620004000
},
"type": "timeseries_request"
}
}
OK
A message containing one response to a timeseries query made with timeseries formula query request.
フィールド
種類
説明
data
object
A message containing the response to a timeseries query.
attributes
object
The object describing a timeseries response.
series
[object]
Array of response series. The index here corresponds to the index in the formulas
or queries
array from the request.
group_tags
[string]
List of tags that apply to a single response value.
query_index
int32
The index of the query in the "formulas" array (or "queries" array if no "formulas" was specified).
unit
[object]
Detailed information about the unit.
The first element describes the "primary unit" (for example, bytes
in bytes per second
).
The second element describes the "per unit" (for example, second
in bytes per second
).
If the second element is not present, the API returns null.
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.
times
[integer]
Array of times, 1-1 match with individual values arrays.
values
[array]
Array of value-arrays. The index here corresponds to the index in the formulas
or queries
array from the request.
type
enum
The type of the resource. The value should always be timeseries_response.
Allowed enum values: timeseries_response
default: timeseries_response
errors
string
The error generated by the request.
{
"data": {
"attributes": {
"series": [
{
"group_tags": [
"env:production"
],
"query_index": 0,
"unit": [
{
"family": "time",
"name": "minute",
"plural": "minutes",
"scale_factor": 60,
"short_name": "min"
}
]
}
],
"times": [],
"values": [
1575317847,
0.5
]
},
"type": "timeseries_response"
},
"errors": "string"
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Unauthorized
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 POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/query/timeseries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1671612804000,
"interval": 5000,
"queries": [
{
"data_source": "metrics",
"query": "avg:system.cpu.user{*}",
"name": "a"
}
],
"to": 1671620004000
},
"type": "timeseries_request"
}
}
EOF
// Timeseries cross product query returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.TimeseriesFormulaQueryRequest{
Data: datadogV2.TimeseriesFormulaRequest{
Attributes: datadogV2.TimeseriesFormulaRequestAttributes{
Formulas: []datadogV2.QueryFormula{
{
Formula: "a",
Limit: &datadogV2.FormulaLimit{
Count: datadog.PtrInt32(10),
Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
},
},
},
From: 1671612804000,
Interval: datadog.PtrInt64(5000),
Queries: []datadogV2.TimeseriesQuery{
datadogV2.TimeseriesQuery{
MetricsTimeseriesQuery: &datadogV2.MetricsTimeseriesQuery{
DataSource: datadogV2.METRICSDATASOURCE_METRICS,
Query: "avg:system.cpu.user{*}",
Name: datadog.PtrString("a"),
}},
},
To: 1671620004000,
},
Type: datadogV2.TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.QueryTimeseriesData", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.QueryTimeseriesData(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryTimeseriesData`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryTimeseriesData`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Timeseries cross product query returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.FormulaLimit;
import com.datadog.api.client.v2.model.MetricsDataSource;
import com.datadog.api.client.v2.model.MetricsTimeseriesQuery;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaQueryResponse;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequest;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestAttributes;
import com.datadog.api.client.v2.model.TimeseriesFormulaRequestType;
import com.datadog.api.client.v2.model.TimeseriesQuery;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.queryTimeseriesData", true);
MetricsApi apiInstance = new MetricsApi(defaultClient);
TimeseriesFormulaQueryRequest body =
new TimeseriesFormulaQueryRequest()
.data(
new TimeseriesFormulaRequest()
.attributes(
new TimeseriesFormulaRequestAttributes()
.formulas(
Collections.singletonList(
new QueryFormula()
.formula("a")
.limit(
new FormulaLimit()
.count(10)
.order(QuerySortOrder.DESC))))
.from(1671612804000L)
.interval(5000L)
.queries(
Collections.singletonList(
new TimeseriesQuery(
new MetricsTimeseriesQuery()
.dataSource(MetricsDataSource.METRICS)
.query("avg:system.cpu.user{*}")
.name("a"))))
.to(1671620004000L))
.type(TimeseriesFormulaRequestType.TIMESERIES_REQUEST));
try {
TimeseriesFormulaQueryResponse result = apiInstance.queryTimeseriesData(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#queryTimeseriesData");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Timeseries cross product query returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.metrics_data_source import MetricsDataSource
from datadog_api_client.v2.model.metrics_timeseries_query import MetricsTimeseriesQuery
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.timeseries_formula_query_request import TimeseriesFormulaQueryRequest
from datadog_api_client.v2.model.timeseries_formula_request import TimeseriesFormulaRequest
from datadog_api_client.v2.model.timeseries_formula_request_attributes import TimeseriesFormulaRequestAttributes
from datadog_api_client.v2.model.timeseries_formula_request_queries import TimeseriesFormulaRequestQueries
from datadog_api_client.v2.model.timeseries_formula_request_type import TimeseriesFormulaRequestType
body = TimeseriesFormulaQueryRequest(
data=TimeseriesFormulaRequest(
attributes=TimeseriesFormulaRequestAttributes(
formulas=[
QueryFormula(
formula="a",
limit=FormulaLimit(
count=10,
order=QuerySortOrder.DESC,
),
),
],
_from=1671612804000,
interval=5000,
queries=TimeseriesFormulaRequestQueries(
[
MetricsTimeseriesQuery(
data_source=MetricsDataSource.METRICS,
query="avg:system.cpu.user{*}",
name="a",
),
]
),
to=1671620004000,
),
type=TimeseriesFormulaRequestType.TIMESERIES_REQUEST,
),
)
configuration = Configuration()
configuration.unstable_operations["query_timeseries_data"] = True
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.query_timeseries_data(body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Timeseries cross product query returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.query_timeseries_data".to_sym] = true
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::TimeseriesFormulaQueryRequest.new({
data: DatadogAPIClient::V2::TimeseriesFormulaRequest.new({
attributes: DatadogAPIClient::V2::TimeseriesFormulaRequestAttributes.new({
formulas: [
DatadogAPIClient::V2::QueryFormula.new({
formula: "a",
limit: DatadogAPIClient::V2::FormulaLimit.new({
count: 10,
order: DatadogAPIClient::V2::QuerySortOrder::DESC,
}),
}),
],
from: 1671612804000,
interval: 5000,
queries: [
DatadogAPIClient::V2::MetricsTimeseriesQuery.new({
data_source: DatadogAPIClient::V2::MetricsDataSource::METRICS,
query: "avg:system.cpu.user{*}",
name: "a",
}),
],
to: 1671620004000,
}),
type: DatadogAPIClient::V2::TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
}),
})
p api_instance.query_timeseries_data(body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
* Timeseries cross product query returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
configuration.unstableOperations["v2.queryTimeseriesData"] = true;
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiQueryTimeseriesDataRequest = {
body: {
data: {
attributes: {
formulas: [
{
formula: "a",
limit: {
count: 10,
order: "desc",
},
},
],
from: 1671612804000,
interval: 5000,
queries: [
{
dataSource: "metrics",
query: "avg:system.cpu.user{*}",
name: "a",
},
],
to: 1671620004000,
},
type: "timeseries_request",
},
},
};
apiInstance
.queryTimeseriesData(params)
.then((data: v2.TimeseriesFormulaQueryResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v1/distribution_pointshttps://api.datadoghq.eu/api/v1/distribution_pointshttps://api.ddog-gov.com/api/v1/distribution_pointshttps://api.datadoghq.com/api/v1/distribution_pointshttps://api.us3.datadoghq.com/api/v1/distribution_pointshttps://api.us5.datadoghq.com/api/v1/distribution_points
ディストリビューションポイントのエンドポイントでは、Datadog のダッシュボードでグラフ化できるディストリビューションデータを投稿することができます。
名前
種類
説明
Content-Encoding
string
HTTP header used to compress the media-type.
フィールド
種類
説明
series [required]
[object]
A list of distribution points series to submit to Datadog.
host
string
The name of the host that produced the distribution point metric.
metric [required]
string
The name of the distribution points metric.
points [required]
[array]
Points relating to the distribution point metric. All points must be tuples with timestamp and a list of values (cannot be a string). Timestamps should be in POSIX time in seconds.
tags
[string]
A list of tags associated with the distribution point metric.
type
enum
The type of the distribution point.
Allowed enum values: distribution
default: distribution
{
"series": [
{
"metric": "system.load.1.dist",
"points": [
[
1636629071,
[
1.0,
2.0
]
]
]
}
]
}
{
"series": [
{
"metric": "system.load.1.dist",
"points": [
[
1636629071,
[
1.0,
2.0
]
]
]
}
]
}
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"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables
export NOW="$(date +%s)"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/distribution_points" \
-H "Accept: application/json" \
-H "Content-Type: text/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"series": [
{
"metric": "system.load.1.dist",
"points": [[${NOW}, [1234.5]]]
}
]
}
EOF
// Submit deflate distribution points returns "Payload accepted" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.DistributionPointsPayload{
Series: []datadogV1.DistributionPointsSeries{
{
Metric: "system.load.1.dist",
Points: [][]datadogV1.DistributionPointItem{
{
{DistributionPointTimestamp: datadog.PtrFloat64(float64(time.Now().Unix()))},
{DistributionPointData: &[]float64{
1.0,
2.0,
}},
},
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMetricsApi(apiClient)
resp, r, err := api.SubmitDistributionPoints(ctx, body, *datadogV1.NewSubmitDistributionPointsOptionalParameters().WithContentEncoding(datadogV1.DISTRIBUTIONPOINTSCONTENTENCODING_DEFLATE))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.SubmitDistributionPoints`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.SubmitDistributionPoints`:\n%s\n", responseContent)
}
// Submit distribution points returns "Payload accepted" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.DistributionPointsPayload{
Series: []datadogV1.DistributionPointsSeries{
{
Metric: "system.load.1.dist",
Points: [][]datadogV1.DistributionPointItem{
{
{DistributionPointTimestamp: datadog.PtrFloat64(float64(time.Now().Unix()))},
{DistributionPointData: &[]float64{
1.0,
2.0,
}},
},
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMetricsApi(apiClient)
resp, r, err := api.SubmitDistributionPoints(ctx, body, *datadogV1.NewSubmitDistributionPointsOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.SubmitDistributionPoints`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.SubmitDistributionPoints`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
// Submit deflate distribution points returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.api.MetricsApi.SubmitDistributionPointsOptionalParameters;
import com.datadog.api.client.v1.model.DistributionPointItem;
import com.datadog.api.client.v1.model.DistributionPointsContentEncoding;
import com.datadog.api.client.v1.model.DistributionPointsPayload;
import com.datadog.api.client.v1.model.DistributionPointsSeries;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
DistributionPointsPayload body =
new DistributionPointsPayload()
.series(
Collections.singletonList(
new DistributionPointsSeries()
.metric("system.load.1.dist")
.points(
Collections.singletonList(
Arrays.asList(
new DistributionPointItem(
Long.valueOf(
OffsetDateTime.now().toInstant().getEpochSecond())
.doubleValue()),
new DistributionPointItem(Arrays.asList(1.0, 2.0)))))));
try {
IntakePayloadAccepted result =
apiInstance.submitDistributionPoints(
body,
new SubmitDistributionPointsOptionalParameters()
.contentEncoding(DistributionPointsContentEncoding.DEFLATE));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#submitDistributionPoints");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
// Submit distribution points returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.DistributionPointItem;
import com.datadog.api.client.v1.model.DistributionPointsPayload;
import com.datadog.api.client.v1.model.DistributionPointsSeries;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
DistributionPointsPayload body =
new DistributionPointsPayload()
.series(
Collections.singletonList(
new DistributionPointsSeries()
.metric("system.load.1.dist")
.points(
Collections.singletonList(
Arrays.asList(
new DistributionPointItem(
Long.valueOf(
OffsetDateTime.now().toInstant().getEpochSecond())
.doubleValue()),
new DistributionPointItem(Arrays.asList(1.0, 2.0)))))));
try {
IntakePayloadAccepted result = apiInstance.submitDistributionPoints(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#submitDistributionPoints");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
"""
Submit deflate distribution points returns "Payload accepted" response
"""
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.distribution_point import DistributionPoint
from datadog_api_client.v1.model.distribution_points_content_encoding import DistributionPointsContentEncoding
from datadog_api_client.v1.model.distribution_points_payload import DistributionPointsPayload
from datadog_api_client.v1.model.distribution_points_series import DistributionPointsSeries
body = DistributionPointsPayload(
series=[
DistributionPointsSeries(
metric="system.load.1.dist",
points=[
DistributionPoint(
[
datetime.now().timestamp(),
[1.0, 2.0],
]
),
],
),
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.submit_distribution_points(
content_encoding=DistributionPointsContentEncoding.DEFLATE, body=body
)
print(response)
"""
Submit distribution points returns "Payload accepted" response
"""
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.distribution_point import DistributionPoint
from datadog_api_client.v1.model.distribution_points_payload import DistributionPointsPayload
from datadog_api_client.v1.model.distribution_points_series import DistributionPointsSeries
body = DistributionPointsPayload(
series=[
DistributionPointsSeries(
metric="system.load.1.dist",
points=[
DistributionPoint(
[
datetime.now().timestamp(),
[1.0, 2.0],
]
),
],
),
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.submit_distribution_points(body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
# Submit deflate distribution points returns "Payload accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
body = DatadogAPIClient::V1::DistributionPointsPayload.new({
series: [
DatadogAPIClient::V1::DistributionPointsSeries.new({
metric: "system.load.1.dist",
points: [
[
Time.now,
[
1.0,
2.0,
],
],
],
}),
],
})
opts = {
content_encoding: DistributionPointsContentEncoding::DEFLATE,
}
p api_instance.submit_distribution_points(body, opts)
# Submit distribution points returns "Payload accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
body = DatadogAPIClient::V1::DistributionPointsPayload.new({
series: [
DatadogAPIClient::V1::DistributionPointsSeries.new({
metric: "system.load.1.dist",
points: [
[
Time.now,
[
1.0,
2.0,
],
],
],
}),
],
})
p api_instance.submit_distribution_points(body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
/**
* Submit deflate distribution points returns "Payload accepted" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.MetricsApi(configuration);
const params: v1.MetricsApiSubmitDistributionPointsRequest = {
body: {
series: [
{
metric: "system.load.1.dist",
points: [[Math.round(new Date().getTime() / 1000), [1.0, 2.0]]],
},
],
},
contentEncoding: "deflate",
};
apiInstance
.submitDistributionPoints(params)
.then((data: v1.IntakePayloadAccepted) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
/**
* Submit distribution points returns "Payload accepted" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.MetricsApi(configuration);
const params: v1.MetricsApiSubmitDistributionPointsRequest = {
body: {
series: [
{
metric: "system.load.1.dist",
points: [[Math.round(new Date().getTime() / 1000), [1.0, 2.0]]],
},
],
},
};
apiInstance
.submitDistributionPoints(params)
.then((data: v1.IntakePayloadAccepted) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v1/serieshttps://api.datadoghq.eu/api/v1/serieshttps://api.ddog-gov.com/api/v1/serieshttps://api.datadoghq.com/api/v1/serieshttps://api.us3.datadoghq.com/api/v1/serieshttps://api.us5.datadoghq.com/api/v1/series
メトリクスエンドポイントを使用して、Datadog のダッシュボードでグラフ化できる時系列データをポストできます。 ペイロードの上限は 3.2 メガバイト (3200000 バイト) です。非圧縮ペイロードの場合、サイズは 62 メガバイト (62914560 バイト) までとなります。
DogStatsD を使用せず、Datadog API に直接メトリクスを送信する場合は以下の仕様に従ってください。
名前
種類
説明
Content-Encoding
string
HTTP header used to compress the media-type.
フィールド
種類
説明
series [required]
[object]
A list of time series to submit to Datadog.
host
string
The name of the host that produced the metric.
interval
int64
If the type of the metric is rate or count, define the corresponding interval.
metric [required]
string
The name of the timeseries.
points [required]
[array]
Points relating to a metric. All points must be tuples with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
tags
[string]
A list of tags associated with the metric.
type
string
The type of the metric. Valid types are "",count
, gauge
, and rate
.
{
"series": [
{
"metric": "system.load.1",
"type": "gauge",
"points": [
[
1636629071,
1.1
]
],
"tags": [
"test:ExampleMetric"
]
}
]
}
{
"series": [
{
"metric": "system.load.1",
"type": "gauge",
"points": [
[
1636629071,
1.1
]
],
"tags": [
"test:ExampleMetric"
]
}
]
}
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"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables
export NOW="$(date +%s)"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/series" \
-H "Accept: application/json" \
-H "Content-Type: text/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"series": [
{
"metric": "system.load.1",
"points": [[${NOW}, 1234.5]]
}
]
}
EOF
// Submit deflate metrics returns "Payload accepted" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.MetricsPayload{
Series: []datadogV1.Series{
{
Metric: "system.load.1",
Type: datadog.PtrString("gauge"),
Points: [][]*float64{
{
datadog.PtrFloat64(float64(time.Now().Unix())),
datadog.PtrFloat64(1.1),
},
},
Tags: []string{
"test:ExampleMetric",
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMetricsApi(apiClient)
resp, r, err := api.SubmitMetrics(ctx, body, *datadogV1.NewSubmitMetricsOptionalParameters().WithContentEncoding(datadogV1.METRICCONTENTENCODING_DEFLATE))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.SubmitMetrics`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.SubmitMetrics`:\n%s\n", responseContent)
}
// Submit metrics returns "Payload accepted" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.MetricsPayload{
Series: []datadogV1.Series{
{
Metric: "system.load.1",
Type: datadog.PtrString("gauge"),
Points: [][]*float64{
{
datadog.PtrFloat64(float64(time.Now().Unix())),
datadog.PtrFloat64(1.1),
},
},
Tags: []string{
"test:ExampleMetric",
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMetricsApi(apiClient)
resp, r, err := api.SubmitMetrics(ctx, body, *datadogV1.NewSubmitMetricsOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.SubmitMetrics`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.SubmitMetrics`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
// Submit deflate metrics returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.api.MetricsApi.SubmitMetricsOptionalParameters;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import com.datadog.api.client.v1.model.MetricContentEncoding;
import com.datadog.api.client.v1.model.MetricsPayload;
import com.datadog.api.client.v1.model.Series;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
MetricsPayload body =
new MetricsPayload()
.series(
Collections.singletonList(
new Series()
.metric("system.load.1")
.type("gauge")
.points(
Collections.singletonList(
Arrays.asList(
Long.valueOf(OffsetDateTime.now().toInstant().getEpochSecond())
.doubleValue(),
1.1)))
.tags(Collections.singletonList("test:ExampleMetric"))));
try {
IntakePayloadAccepted result =
apiInstance.submitMetrics(
body,
new SubmitMetricsOptionalParameters().contentEncoding(MetricContentEncoding.DEFLATE));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#submitMetrics");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
// Submit metrics returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.IntakePayloadAccepted;
import com.datadog.api.client.v1.model.MetricsPayload;
import com.datadog.api.client.v1.model.Series;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
MetricsPayload body =
new MetricsPayload()
.series(
Collections.singletonList(
new Series()
.metric("system.load.1")
.type("gauge")
.points(
Collections.singletonList(
Arrays.asList(
Long.valueOf(OffsetDateTime.now().toInstant().getEpochSecond())
.doubleValue(),
1.1)))
.tags(Collections.singletonList("test:ExampleMetric"))));
try {
IntakePayloadAccepted result = apiInstance.submitMetrics(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#submitMetrics");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
from datadog import initialize, api
import time
options = {
'api_key': '<DATADOG_API_KEY>'
## EU costumers need to define 'api_host' as below
#'api_host': 'https://api.datadoghq.eu/'
}
initialize(**options)
now = time.time()
future_10s = now + 10
# Submit a single point with a timestamp of `now`
api.Metric.send(metric='page.views', points=1000)
# Submit a point with a timestamp (must be current)
api.Metric.send(metric='my.pair', points=(now, 15))
# Submit multiple points.
api.Metric.send(
metric='my.series',
points=[
(now, 15),
(future_10s, 16)
]
)
# Submit a point with a host and tags.
api.Metric.send(
metric='my.series',
points=100,
host="myhost.example.com",
tags=["version:1"]
)
# Submit multiple metrics
api.Metric.send([{
'metric': 'my.series',
'points': 15
}, {
'metric': 'my1.series',
'points': 16
}])
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" python "example.py"
"""
Submit deflate metrics returns "Payload accepted" response
"""
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.metric_content_encoding import MetricContentEncoding
from datadog_api_client.v1.model.metrics_payload import MetricsPayload
from datadog_api_client.v1.model.point import Point
from datadog_api_client.v1.model.series import Series
body = MetricsPayload(
series=[
Series(
metric="system.load.1",
type="gauge",
points=[
Point(
[
datetime.now().timestamp(),
1.1,
]
),
],
tags=[
"test:ExampleMetric",
],
),
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.submit_metrics(content_encoding=MetricContentEncoding.DEFLATE, body=body)
print(response)
"""
Submit metrics returns "Payload accepted" response
"""
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.metrics_payload import MetricsPayload
from datadog_api_client.v1.model.point import Point
from datadog_api_client.v1.model.series import Series
body = MetricsPayload(
series=[
Series(
metric="system.load.1",
type="gauge",
points=[
Point(
[
datetime.now().timestamp(),
1.1,
]
),
],
tags=[
"test:ExampleMetric",
],
),
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.submit_metrics(body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "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:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
# Submit deflate metrics returns "Payload accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
body = DatadogAPIClient::V1::MetricsPayload.new({
series: [
DatadogAPIClient::V1::Series.new({
metric: "system.load.1",
type: "gauge",
points: [
[
Time.now.to_f,
1.1,
],
],
tags: [
"test:ExampleMetric",
],
}),
],
})
opts = {
content_encoding: MetricContentEncoding::DEFLATE,
}
p api_instance.submit_metrics(body, opts)
# Submit metrics returns "Payload accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
body = DatadogAPIClient::V1::MetricsPayload.new({
series: [
DatadogAPIClient::V1::Series.new({
metric: "system.load.1",
type: "gauge",
points: [
[
Time.now.to_f,
1.1,
],
],
tags: [
"test:ExampleMetric",
],
}),
],
})
p api_instance.submit_metrics(body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
/**
* Submit deflate metrics returns "Payload accepted" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.MetricsApi(configuration);
const params: v1.MetricsApiSubmitMetricsRequest = {
body: {
series: [
{
metric: "system.load.1",
type: "gauge",
points: [[Math.round(new Date().getTime() / 1000), 1.1]],
tags: ["test:ExampleMetric"],
},
],
},
contentEncoding: "deflate",
};
apiInstance
.submitMetrics(params)
.then((data: v1.IntakePayloadAccepted) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
/**
* Submit metrics returns "Payload accepted" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.MetricsApi(configuration);
const params: v1.MetricsApiSubmitMetricsRequest = {
body: {
series: [
{
metric: "system.load.1",
type: "gauge",
points: [[Math.round(new Date().getTime() / 1000), 1.1]],
tags: ["test:ExampleMetric"],
},
],
},
};
apiInstance
.submitMetrics(params)
.then((data: v1.IntakePayloadAccepted) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v2/serieshttps://api.datadoghq.eu/api/v2/serieshttps://api.ddog-gov.com/api/v2/serieshttps://api.datadoghq.com/api/v2/serieshttps://api.us3.datadoghq.com/api/v2/serieshttps://api.us5.datadoghq.com/api/v2/series
メトリクスエンドポイントを使用して、Datadog のダッシュボードでグラフ化できる時系列データをポストできます。 ペイロードの上限は 3.2 メガバイト (3200000 バイト) です。非圧縮ペイロードの場合、サイズは 62 メガバイト (62914560 バイト) までとなります。
DogStatsD を使用せず、Datadog API に直接メトリクスを送信する場合は以下の仕様に従ってください。
名前
種類
説明
Content-Encoding
string
HTTP header used to compress the media-type.
フィールド
種類
説明
series [required]
[object]
A list of time series to submit to Datadog.
interval
int64
If the type of the metric is rate or count, define the corresponding interval.
metadata
object
Metadata for the metric.
origin
object
Metric origin information.
metric_type
int32
The origin metric type code
product
int32
The origin product code
service
int32
The origin service code
metric [required]
string
The name of the timeseries.
points [required]
[object]
Points relating to a metric. All points must be objects with timestamp and a scalar value (cannot be a string). Timestamps should be in POSIX time in seconds, and cannot be more than ten minutes in the future or more than one hour in the past.
timestamp
int64
The timestamp should be in seconds and current. Current is defined as not more than 10 minutes in the future or more than 1 hour in the past.
value
double
The numeric value format should be a 64bit float gauge-type value.
resources
[object]
A list of resources to associate with this metric.
name
string
The name of the resource.
type
string
The type of the resource.
source_type_name
string
The source type name.
tags
[string]
A list of tags associated with the metric.
type
enum
The type of metric. The available types are 0
(unspecified), 1
(count), 2
(rate), and 3
(gauge).
Allowed enum values: 0,1,2,3
unit
string
The unit of point value.
{
"series": [
{
"metric": "system.load.1",
"type": 0,
"points": [
{
"timestamp": 1636629071,
"value": 0.7
}
],
"resources": [
{
"name": "dummyhost",
"type": "host"
}
]
}
]
}
{
"series": [
{
"metric": "system.load.1",
"type": 0,
"points": [
{
"timestamp": 1636629071,
"value": 0.7
}
]
}
]
}
Payload accepted
The payload accepted for intake.
{
"errors": []
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Request timeout
API error response.
{
"errors": [
"Bad Request"
]
}
Payload too large
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
# Template variables
export NOW="$(date +%s)"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/series" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"series": [
{
"metric": "system.load.1",
"type": 0,
"points": [
{
"timestamp": 1636629071,
"value": 0.7
}
],
"resources": [
{
"name": "dummyhost",
"type": "host"
}
]
}
]
}
EOF
## Dynamic Points
# Post time-series data that can be graphed on Datadog’s dashboards.
See one of the other client libraries for an example of sending deflate-compressed data.
// Submit metrics returns "Payload accepted" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.MetricPayload{
Series: []datadogV2.MetricSeries{
{
Metric: "system.load.1",
Type: datadogV2.METRICINTAKETYPE_UNSPECIFIED.Ptr(),
Points: []datadogV2.MetricPoint{
{
Timestamp: datadog.PtrInt64(time.Now().Unix()),
Value: datadog.PtrFloat64(0.7),
},
},
Resources: []datadogV2.MetricResource{
{
Name: datadog.PtrString("dummyhost"),
Type: datadog.PtrString("host"),
},
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.SubmitMetrics(ctx, body, *datadogV2.NewSubmitMetricsOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.SubmitMetrics`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.SubmitMetrics`:\n%s\n", responseContent)
}
// Submit metrics with compression returns "Payload accepted" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.MetricPayload{
Series: []datadogV2.MetricSeries{
{
Metric: "system.load.1",
Type: datadogV2.METRICINTAKETYPE_UNSPECIFIED.Ptr(),
Points: []datadogV2.MetricPoint{
{
Timestamp: datadog.PtrInt64(time.Now().Unix()),
Value: datadog.PtrFloat64(0.7),
},
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.SubmitMetrics(ctx, body, *datadogV2.NewSubmitMetricsOptionalParameters().WithContentEncoding(datadogV2.METRICCONTENTENCODING_ZSTD1))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.SubmitMetrics`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.SubmitMetrics`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
// Submit metrics returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.IntakePayloadAccepted;
import com.datadog.api.client.v2.model.MetricIntakeType;
import com.datadog.api.client.v2.model.MetricPayload;
import com.datadog.api.client.v2.model.MetricPoint;
import com.datadog.api.client.v2.model.MetricResource;
import com.datadog.api.client.v2.model.MetricSeries;
import java.time.OffsetDateTime;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
MetricPayload body =
new MetricPayload()
.series(
Collections.singletonList(
new MetricSeries()
.metric("system.load.1")
.type(MetricIntakeType.UNSPECIFIED)
.points(
Collections.singletonList(
new MetricPoint()
.timestamp(OffsetDateTime.now().toInstant().getEpochSecond())
.value(0.7)))
.resources(
Collections.singletonList(
new MetricResource().name("dummyhost").type("host")))));
try {
IntakePayloadAccepted result = apiInstance.submitMetrics(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#submitMetrics");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
// Submit metrics with compression returns "Payload accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.api.MetricsApi.SubmitMetricsOptionalParameters;
import com.datadog.api.client.v2.model.IntakePayloadAccepted;
import com.datadog.api.client.v2.model.MetricContentEncoding;
import com.datadog.api.client.v2.model.MetricIntakeType;
import com.datadog.api.client.v2.model.MetricPayload;
import com.datadog.api.client.v2.model.MetricPoint;
import com.datadog.api.client.v2.model.MetricSeries;
import java.time.OffsetDateTime;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
MetricPayload body =
new MetricPayload()
.series(
Collections.singletonList(
new MetricSeries()
.metric("system.load.1")
.type(MetricIntakeType.UNSPECIFIED)
.points(
Collections.singletonList(
new MetricPoint()
.timestamp(OffsetDateTime.now().toInstant().getEpochSecond())
.value(0.7)))));
try {
IntakePayloadAccepted result =
apiInstance.submitMetrics(
body,
new SubmitMetricsOptionalParameters().contentEncoding(MetricContentEncoding.ZSTD1));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#submitMetrics");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"
"""
Submit metrics returns "Payload accepted" response
"""
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_intake_type import MetricIntakeType
from datadog_api_client.v2.model.metric_payload import MetricPayload
from datadog_api_client.v2.model.metric_point import MetricPoint
from datadog_api_client.v2.model.metric_resource import MetricResource
from datadog_api_client.v2.model.metric_series import MetricSeries
body = MetricPayload(
series=[
MetricSeries(
metric="system.load.1",
type=MetricIntakeType.UNSPECIFIED,
points=[
MetricPoint(
timestamp=int(datetime.now().timestamp()),
value=0.7,
),
],
resources=[
MetricResource(
name="dummyhost",
type="host",
),
],
),
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.submit_metrics(body=body)
print(response)
"""
Submit metrics with compression returns "Payload accepted" response
"""
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_content_encoding import MetricContentEncoding
from datadog_api_client.v2.model.metric_intake_type import MetricIntakeType
from datadog_api_client.v2.model.metric_payload import MetricPayload
from datadog_api_client.v2.model.metric_point import MetricPoint
from datadog_api_client.v2.model.metric_series import MetricSeries
body = MetricPayload(
series=[
MetricSeries(
metric="system.load.1",
type=MetricIntakeType.UNSPECIFIED,
points=[
MetricPoint(
timestamp=int(datetime.now().timestamp()),
value=0.7,
),
],
),
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.submit_metrics(content_encoding=MetricContentEncoding.ZSTD1, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"
# Submit metrics returns "Payload accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::MetricPayload.new({
series: [
DatadogAPIClient::V2::MetricSeries.new({
metric: "system.load.1",
type: DatadogAPIClient::V2::MetricIntakeType::UNSPECIFIED,
points: [
DatadogAPIClient::V2::MetricPoint.new({
timestamp: Time.now.to_i,
value: 0.7,
}),
],
resources: [
DatadogAPIClient::V2::MetricResource.new({
name: "dummyhost",
type: "host",
}),
],
}),
],
})
p api_instance.submit_metrics(body)
# Submit metrics with compression returns "Payload accepted" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::MetricPayload.new({
series: [
DatadogAPIClient::V2::MetricSeries.new({
metric: "system.load.1",
type: DatadogAPIClient::V2::MetricIntakeType::UNSPECIFIED,
points: [
DatadogAPIClient::V2::MetricPoint.new({
timestamp: Time.now.to_i,
value: 0.7,
}),
],
}),
],
})
opts = {
content_encoding: MetricContentEncoding::ZSTD1,
}
p api_instance.submit_metrics(body, opts)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"
/**
* Submit metrics returns "Payload accepted" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiSubmitMetricsRequest = {
body: {
series: [
{
metric: "system.load.1",
type: 0,
points: [
{
timestamp: Math.round(new Date().getTime() / 1000),
value: 0.7,
},
],
resources: [
{
name: "dummyhost",
type: "host",
},
],
},
],
},
};
apiInstance
.submitMetrics(params)
.then((data: v2.IntakePayloadAccepted) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
/**
* Submit metrics with compression returns "Payload accepted" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiSubmitMetricsRequest = {
body: {
series: [
{
metric: "system.load.1",
type: 0,
points: [
{
timestamp: Math.round(new Date().getTime() / 1000),
value: 0.7,
},
],
},
],
},
contentEncoding: "zstd1",
};
apiInstance
.submitMetrics(params)
.then((data: v2.IntakePayloadAccepted) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v1/metrics/{metric_name}https://api.datadoghq.eu/api/v1/metrics/{metric_name}https://api.ddog-gov.com/api/v1/metrics/{metric_name}https://api.datadoghq.com/api/v1/metrics/{metric_name}https://api.us3.datadoghq.com/api/v1/metrics/{metric_name}https://api.us5.datadoghq.com/api/v1/metrics/{metric_name}
指定されたメトリクスに関するメタデータを取得します。
This endpoint requires the metrics_read
authorization scope.
名前
種類
説明
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"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export metric_name="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get metric metadata returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.get_metric_metadata(
metric_name="metric_name",
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get metric metadata returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::MetricsAPI.new
p api_instance.get_metric_metadata("metric_name")
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
# Get metadata on metric
result = dog.get_metadata('system.net.bytes_sent')
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get metric metadata returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMetricsApi(apiClient)
resp, r, err := api.GetMetricMetadata(ctx, "metric_name")
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.GetMetricMetadata`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.GetMetricMetadata`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get metric metadata returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MetricsApi;
import com.datadog.api.client.v1.model.MetricMetadata;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
try {
MetricMetadata result = apiInstance.getMetricMetadata("metric_name");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#getMetricMetadata");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
metric = 'system.cpu.idle'
api.Metadata.get(metric_name=metric)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
/**
* Get metric metadata returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.MetricsApi(configuration);
const params: v1.MetricsApiGetMetricMetadataRequest = {
metricName: "metric_name",
};
apiInstance
.getMetricMetadata(params)
.then((data: v1.MetricMetadata) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us3.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.us5.datadoghq.com/api/v2/metrics/{metric_name}/tags
Returns the tag configuration for the given metric name.
This endpoint requires the metrics_read
authorization scope.
名前
種類
説明
metric_name [required]
string
The name of the metric.
Success
Response object which includes a single metric’s tag configuration.
フィールド
種類
説明
data
object
Object for a single metric tag configuration.
attributes
object
Object containing the definition of a metric tag configuration attributes.
aggregations
[object]
A list of queryable aggregation combinations for a count, rate, or gauge metric. By default, count and rate metrics require the (time: sum, space: sum) aggregation and Gauge metrics require the (time: avg, space: avg) aggregation. Additional time & space combinations are also available:
Can only be applied to metrics that have a metric_type
of count
, rate
, or gauge
.
space [required]
enum
A space aggregation for use in query.
Allowed enum values: avg,max,min,sum
time [required]
enum
A time aggregation for use in query.
Allowed enum values: avg,count,max,min,sum
created_at
date-time
Timestamp when the tag configuration was created.
exclude_tags_mode
boolean
When set to true, the configuration will exclude the configured tags and include any other submitted tags.
When set to false, the configuration will include the configured tags and exclude any other submitted tags.
Defaults to false. Requires tags
property.
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type
is distribution
.
metric_type
enum
The metric's type.
Allowed enum values: gauge,count,rate,distribution
default: gauge
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
default: manage_tags
{
"data": {
"attributes": {
"aggregations": [
{
"space": "sum",
"time": "sum"
}
],
"created_at": "2020-03-25T09:48:37.463835Z",
"exclude_tags_mode": false,
"include_percentiles": true,
"metric_type": "count",
"modified_at": "2020-03-25T09:48:37.463835Z",
"tags": [
"app",
"datacenter"
]
},
"id": "test.metric.latency",
"type": "manage_tags"
}
}
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.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
List tag configuration by name returns "Success" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
# there is a valid "metric_tag_configuration" in the system
METRIC_TAG_CONFIGURATION_DATA_ID = environ["METRIC_TAG_CONFIGURATION_DATA_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.list_tag_configuration_by_name(
metric_name=METRIC_TAG_CONFIGURATION_DATA_ID,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# List tag configuration by name returns "Success" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MetricsAPI.new
# there is a valid "metric_tag_configuration" in the system
METRIC_TAG_CONFIGURATION_DATA_ID = ENV["METRIC_TAG_CONFIGURATION_DATA_ID"]
p api_instance.list_tag_configuration_by_name(METRIC_TAG_CONFIGURATION_DATA_ID)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// List tag configuration by name returns "Success" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
// there is a valid "metric_tag_configuration" in the system
MetricTagConfigurationDataID := os.Getenv("METRIC_TAG_CONFIGURATION_DATA_ID")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.ListTagConfigurationByName(ctx, MetricTagConfigurationDataID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.ListTagConfigurationByName`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.ListTagConfigurationByName`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// List tag configuration by name returns "Success" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.MetricTagConfigurationResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);
// there is a valid "metric_tag_configuration" in the system
String METRIC_TAG_CONFIGURATION_DATA_ID = System.getenv("METRIC_TAG_CONFIGURATION_DATA_ID");
try {
MetricTagConfigurationResponse result =
apiInstance.listTagConfigurationByName(METRIC_TAG_CONFIGURATION_DATA_ID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#listTagConfigurationByName");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
/**
* List tag configuration by name returns "Success" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.MetricsApi(configuration);
// there is a valid "metric_tag_configuration" in the system
const METRIC_TAG_CONFIGURATION_DATA_ID = process.env
.METRIC_TAG_CONFIGURATION_DATA_ID as string;
const params: v2.MetricsApiListTagConfigurationByNameRequest = {
metricName: METRIC_TAG_CONFIGURATION_DATA_ID,
};
apiInstance
.listTagConfigurationByName(params)
.then((data: v2.MetricTagConfigurationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
Note: This endpoint is GA for Metrics, Real User Monitoring (RUM), and Cloud Cost Management data sources. Support for logs is in beta. We are gradually onboarding support for more sources. If you have any feedback, contact Datadog Support.
POST https://api.ap1.datadoghq.com/api/v2/query/scalarhttps://api.datadoghq.eu/api/v2/query/scalarhttps://api.ddog-gov.com/api/v2/query/scalarhttps://api.datadoghq.com/api/v2/query/scalarhttps://api.us3.datadoghq.com/api/v2/query/scalarhttps://api.us5.datadoghq.com/api/v2/query/scalar
Query scalar values (as seen on Query Value, Table, and Toplist widgets).
Multiple data sources are supported with the ability to
process the data using formulas and functions.
This endpoint requires the timeseries_query
authorization scope.
フィールド
種類
説明
data [required]
object
A single scalar query to be executed.
attributes [required]
object
The object describing a scalar formula request.
formulas
[object]
List of formulas to be calculated and returned as responses.
formula [required]
string
Formula string, referencing one or more queries with their name property.
limit
object
Message for specifying limits to the number of values returned by a query. This limit is only for scalar queries and has no effect on timeseries queries.
count
int32
The number of results to which to limit.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
from [required]
int64
Start date (inclusive) of the query in milliseconds since the Unix epoch.
queries [required]
[ <oneOf>]
List of queries to be run and used as inputs to the formulas.
Option 1
object
An individual scalar metrics query.
aggregator [required]
enum
The type of aggregation that can be performed on metrics-based queries.
Allowed enum values: avg,min,max,sum,last,percentile,mean,l2norm,area
default: avg
data_source [required]
enum
A data source that is powered by the Metrics platform.
Allowed enum values: metrics,cloud_cost
default: metrics
name
string
The variable name for use in formulas.
query [required]
string
A classic metrics query string.
Option 2
object
An individual scalar events query.
compute [required]
object
The instructions for what to compute for this query.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,max,avg
default: count
interval
int64
Interval for compute in milliseconds.
metric
string
The "measure" attribute on which to perform the computation.
data_source [required]
enum
A data source that is powered by the Events Platform.
Allowed enum values: logs,rum
default: logs
group_by
[object]
The list of facets on which to split results.
facet [required]
string
The facet by which to split groups.
limit
int32
The maximum number of groups to return.
sort
object
The dimension by which to sort a query's results.
aggregation [required]
enum
The type of aggregation that can be performed on events-based queries.
Allowed enum values: count,cardinality,pc75,pc90,pc95,pc98,pc99,sum,min,max,avg
default: count
metric
string
The metric's calculated value which should be used to define the sort order of a query's results.
order
enum
Direction of sort.
Allowed enum values: asc,desc
default: desc
type
enum
The type of sort to use on the calculated value.
Allowed enum values: alphabetical,measure
indexes
[string]
The indexes in which to search.
name
string
The variable name for use in formulas.
search
object
Configuration of the search/filter for an events query.
query
string
The search/filter string for an events query.
to [required]
int64
End date (exclusive) of the query in milliseconds since the Unix epoch.
type [required]
enum
The type of the resource. The value should always be scalar_request.
Allowed enum values: scalar_request
default: scalar_request
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1671612804000,
"queries": [
{
"aggregator": "avg",
"data_source": "metrics",
"query": "avg:system.cpu.user{*}",
"name": "a"
}
],
"to": 1671620004000
},
"type": "scalar_request"
}
}
OK
A message containing one or more responses to scalar queries.
フィールド
種類
説明
data
object
A message containing the response to a scalar query.
attributes
object
The object describing a scalar response.
columns
[ <oneOf>]
List of response columns, each corresponding to an individual formula or query in the request and with values in parallel arrays matching the series list.
Option 1
object
A column containing the tag keys and values in a group.
name
string
The name of the tag key or group.
type
enum
The type of column present for groups.
Allowed enum values: group
default: group
values
[array]
The array of tag values for each group found for the results of the formulas or queries.
Option 2
object
A column containing the numerical results for a formula or query.
meta
object
Metadata for the resulting numerical values.
unit
[object]
Detailed information about the unit.
First element describes the "primary unit" (for example, bytes
in bytes per second
).
The second element describes the "per unit" (for example, second
in bytes per second
).
If the second element is not present, the API returns null.
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.
name
string
The name referencing the formula or query for this column.
type
enum
The type of column present for numbers.
Allowed enum values: number
default: number
values
[number]
The array of numerical values for one formula or query.
type
enum
The type of the resource. The value should always be scalar_response.
Allowed enum values: scalar_response
default: scalar_response
errors
string
An error generated when processing a request.
{
"data": {
"attributes": {
"columns": [
{
"name": "env",
"type": "group",
"values": [
[
"staging"
]
]
}
]
},
"type": "scalar_response"
},
"errors": "string"
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Unauthorized
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 POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/query/scalar" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"attributes": {
"formulas": [
{
"formula": "a",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1671612804000,
"queries": [
{
"aggregator": "avg",
"data_source": "metrics",
"query": "avg:system.cpu.user{*}",
"name": "a"
}
],
"to": 1671620004000
},
"type": "scalar_request"
}
}
EOF
// Scalar cross product query returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.ScalarFormulaQueryRequest{
Data: datadogV2.ScalarFormulaRequest{
Attributes: datadogV2.ScalarFormulaRequestAttributes{
Formulas: []datadogV2.QueryFormula{
{
Formula: "a",
Limit: &datadogV2.FormulaLimit{
Count: datadog.PtrInt32(10),
Order: datadogV2.QUERYSORTORDER_DESC.Ptr(),
},
},
},
From: 1671612804000,
Queries: []datadogV2.ScalarQuery{
datadogV2.ScalarQuery{
MetricsScalarQuery: &datadogV2.MetricsScalarQuery{
Aggregator: datadogV2.METRICSAGGREGATOR_AVG,
DataSource: datadogV2.METRICSDATASOURCE_METRICS,
Query: "avg:system.cpu.user{*}",
Name: datadog.PtrString("a"),
}},
},
To: 1671620004000,
},
Type: datadogV2.SCALARFORMULAREQUESTTYPE_SCALAR_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.QueryScalarData", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.QueryScalarData(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryScalarData`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryScalarData`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Scalar cross product query returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MetricsApi;
import com.datadog.api.client.v2.model.FormulaLimit;
import com.datadog.api.client.v2.model.MetricsAggregator;
import com.datadog.api.client.v2.model.MetricsDataSource;
import com.datadog.api.client.v2.model.MetricsScalarQuery;
import com.datadog.api.client.v2.model.QueryFormula;
import com.datadog.api.client.v2.model.QuerySortOrder;
import com.datadog.api.client.v2.model.ScalarFormulaQueryRequest;
import com.datadog.api.client.v2.model.ScalarFormulaQueryResponse;
import com.datadog.api.client.v2.model.ScalarFormulaRequest;
import com.datadog.api.client.v2.model.ScalarFormulaRequestAttributes;
import com.datadog.api.client.v2.model.ScalarFormulaRequestType;
import com.datadog.api.client.v2.model.ScalarQuery;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.queryScalarData", true);
MetricsApi apiInstance = new MetricsApi(defaultClient);
ScalarFormulaQueryRequest body =
new ScalarFormulaQueryRequest()
.data(
new ScalarFormulaRequest()
.attributes(
new ScalarFormulaRequestAttributes()
.formulas(
Collections.singletonList(
new QueryFormula()
.formula("a")
.limit(
new FormulaLimit()
.count(10)
.order(QuerySortOrder.DESC))))
.from(1671612804000L)
.queries(
Collections.singletonList(
new ScalarQuery(
new MetricsScalarQuery()
.aggregator(MetricsAggregator.AVG)
.dataSource(MetricsDataSource.METRICS)
.query("avg:system.cpu.user{*}")
.name("a"))))
.to(1671620004000L))
.type(ScalarFormulaRequestType.SCALAR_REQUEST));
try {
ScalarFormulaQueryResponse result = apiInstance.queryScalarData(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#queryScalarData");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Scalar cross product query returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.formula_limit import FormulaLimit
from datadog_api_client.v2.model.metrics_aggregator import MetricsAggregator
from datadog_api_client.v2.model.metrics_data_source import MetricsDataSource
from datadog_api_client.v2.model.metrics_scalar_query import MetricsScalarQuery
from datadog_api_client.v2.model.query_formula import QueryFormula
from datadog_api_client.v2.model.query_sort_order import QuerySortOrder
from datadog_api_client.v2.model.scalar_formula_query_request import ScalarFormulaQueryRequest
from datadog_api_client.v2.model.scalar_formula_request import ScalarFormulaRequest
from datadog_api_client.v2.model.scalar_formula_request_attributes import ScalarFormulaRequestAttributes
from datadog_api_client.v2.model.scalar_formula_request_queries import ScalarFormulaRequestQueries
from datadog_api_client.v2.model.scalar_formula_request_type import ScalarFormulaRequestType
body = ScalarFormulaQueryRequest(
data=ScalarFormulaRequest(
attributes=ScalarFormulaRequestAttributes(
formulas=[
QueryFormula(
formula="a",
limit=FormulaLimit(
count=10,
order=QuerySortOrder.DESC,
),
),
],
_from=1671612804000,
queries=ScalarFormulaRequestQueries(
[
MetricsScalarQuery(
aggregator=MetricsAggregator.AVG,
data_source=MetricsDataSource.METRICS,
query="avg:system.cpu.user{*}",
name="a",
),
]
),
to=1671620004000,
),
type=ScalarFormulaRequestType.SCALAR_REQUEST,
),
)
configuration = Configuration()
configuration.unstable_operations["query_scalar_data"] = True
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.query_scalar_data(body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Scalar cross product query returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.query_scalar_data".to_sym] = true
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::ScalarFormulaQueryRequest.new({
data: DatadogAPIClient::V2::ScalarFormulaRequest.new({
attributes: DatadogAPIClient::V2::ScalarFormulaRequestAttributes.new({
formulas: [
DatadogAPIClient::V2::QueryFormula.new({
formula: "a",
limit: DatadogAPIClient::V2::FormulaLimit.new({
count: 10,
order: DatadogAPIClient::V2::QuerySortOrder::DESC,
}),
}),
],
from: 1671612804000,
queries: [
DatadogAPIClient::V2::MetricsScalarQuery.new({
aggregator: DatadogAPIClient::V2::MetricsAggregator::AVG,
data_source: DatadogAPIClient::V2::MetricsDataSource::METRICS,
query: "avg:system.cpu.user{*}",
name: "a",
}),
],
to: 1671620004000,
}),
type: DatadogAPIClient::V2::ScalarFormulaRequestType::SCALAR_REQUEST,
}),
})
p api_instance.query_scalar_data(body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
* Scalar cross product query returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
configuration.unstableOperations["v2.queryScalarData"] = true;
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiQueryScalarDataRequest = {
body: {
data: {
attributes: {
formulas: [
{
formula: "a",
limit: {
count: 10,
order: "desc",
},
},
],
from: 1671612804000,
queries: [
{
aggregator: "avg",
dataSource: "metrics",
query: "avg:system.cpu.user{*}",
name: "a",
},
],
to: 1671620004000,
},
type: "scalar_request",
},
},
};
apiInstance
.queryScalarData(params)
.then((data: v2.ScalarFormulaQueryResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
PUT https://api.ap1.datadoghq.com/api/v1/metrics/{metric_name}https://api.datadoghq.eu/api/v1/metrics/{metric_name}https://api.ddog-gov.com/api/v1/metrics/{metric_name}https://api.datadoghq.com/api/v1/metrics/{metric_name}https://api.us3.datadoghq.com/api/v1/metrics/{metric_name}https://api.us5.datadoghq.com/api/v1/metrics/{metric_name}
指定されたメトリクスのメタデータを編集します。詳しくはサポートされる種類を参照してください。
名前
種類
説明
metric_name [required]
string
Name of the metric for which to edit 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"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export metric_name="CHANGE_ME"
# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{}
EOF