タグコンフィギュレーションを作成する
https://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}/tagshttps://api.datadoghq.eu/api/v2/metrics/{metric_name}/tagshttps://api.ap1.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.ap2.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.uk1.datadoghq.com/api/v2/metrics/{metric_name}/tagshttps://api.ddog-gov.com/api/v2/metrics/{metric_name}/tagshttps://api.us2.ddog-gov.com/api/v2/metrics/{metric_name}/tags概要
既存の count/gauge/rate/distribution メトリクスについて、クエリが可能なタグキーの一覧を作成および定義します。
オプションで、任意の分散型メトリクスについてのパーセンタイル集計を含めるか、任意の count、rate、または gauge メトリクスのカスタム集計を構成することができます。
Manage Tags for Metrics 権限を持つユーザーが発行したアプリケーションキーのみを使用できます。
引数
パスパラメーター
metric_name [required]The name of the metric.
リクエスト
Body Data (required)
data [required]タグを構成したいメトリクスを含むオブジェクトをリクエストします。
attributesObject containing the definition of a metric tag configuration to be created.
aggregationsDeprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]A space aggregation for use in query.
avg, max, min, sumtime [required]A time aggregation for use in query.
avg, count, max, min, sumexclude_tags_modeWhen 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_percentilesToggle 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]The metric's type.
gaugegauge, count, rate, distributiontags [required]A list of tag keys that will be queryable for your metric.
id [required]The metric name for this resource.
type [required]The metric tag configuration resource type.
manage_tagsmanage_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.
dataObject for a single metric tag configuration.
attributesObject containing the definition of a metric tag configuration attributes.
aggregationsDeprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits.
space [required]A space aggregation for use in query.
avg, max, min, sumtime [required]A time aggregation for use in query.
avg, count, max, min, sumcreated_atTimestamp when the tag configuration was created.
exclude_tags_modeWhen 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_percentilesToggle to include or exclude percentile aggregations for distribution metrics.
Only present when the metric_type is distribution.
metric_typeThe metric's type.
gaugegauge, count, rate, distributionmodified_atTimestamp when the tag configuration was last modified.
tagsList of tag keys on which to group.
idThe metric name for this resource.
relationshipsRelationships for a metric.
metric_volumesRelationship to a metric volume included in the response.
dataRelationship data for a metric volume.
idThe metric name for this resource.
typeThe metric ingested and indexed volume type.
metric_volumesmetric_volumestypeThe metric tag configuration resource type.
manage_tagsmanage_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",
"relationships": {
"metric_volumes": {
"data": {
"id": "test.metric.latency",
"type": "metric_volumes"
}
}
},
"type": "manage_tags"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Conflict
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too Many Requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}コード例
# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "manage_tags",
"id": "ExampleMetric",
"attributes": {
"tags": [
"app",
"datacenter"
],
"metric_type": "gauge"
}
}
}
EOF# Path parameters
export metric_name="dist.http.endpoint.request"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/metrics/${metric_name}/tags" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewMetricsApi(apiClient)
resp, r, err := api.CreateTagConfiguration(ctx, "ExampleMetric", body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.CreateTagConfiguration`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MetricsApi.CreateTagConfiguration`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" 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();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MetricsApi apiInstance = new MetricsApi(defaultClient);
MetricTagConfigurationCreateRequest body =
new MetricTagConfigurationCreateRequest()
.data(
new MetricTagConfigurationCreateData()
.type(MetricTagConfigurationType.MANAGE_TAGS)
.id("ExampleMetric")
.attributes(
new MetricTagConfigurationCreateAttributes()
.tags(Arrays.asList("app", "datacenter"))
.metricType(MetricTagConfigurationMetricTypes.GAUGE)));
try {
MetricTagConfigurationResponse result =
apiInstance.createTagConfiguration("ExampleMetric", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#createTagConfiguration");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create a tag configuration returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.metrics_api import MetricsApi
from datadog_api_client.v2.model.metric_tag_configuration_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()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.create_tag_configuration(metric_name="ExampleMetric", body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create a tag configuration returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::MetricsAPI.new
body = DatadogAPIClient::V2::MetricTagConfigurationCreateRequest.new({
data: DatadogAPIClient::V2::MetricTagConfigurationCreateData.new({
type: DatadogAPIClient::V2::MetricTagConfigurationType::MANAGE_TAGS,
id: "ExampleMetric",
attributes: DatadogAPIClient::V2::MetricTagConfigurationCreateAttributes.new({
tags: [
"app",
"datacenter",
],
metric_type: DatadogAPIClient::V2::MetricTagConfigurationMetricTypes::GAUGE,
}),
}),
})
p api_instance.create_tag_configuration("ExampleMetric", body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create a tag configuration returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::MetricTagConfigurationCreateAttributes;
use datadog_api_client::datadogV2::model::MetricTagConfigurationCreateData;
use datadog_api_client::datadogV2::model::MetricTagConfigurationCreateRequest;
use datadog_api_client::datadogV2::model::MetricTagConfigurationMetricTypes;
use datadog_api_client::datadogV2::model::MetricTagConfigurationType;
#[tokio::main]
async fn main() {
let body = MetricTagConfigurationCreateRequest::new(
MetricTagConfigurationCreateData::new(
"ExampleMetric".to_string(),
MetricTagConfigurationType::MANAGE_TAGS,
)
.attributes(MetricTagConfigurationCreateAttributes::new(
MetricTagConfigurationMetricTypes::GAUGE,
vec!["app".to_string(), "datacenter".to_string()],
)),
);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.create_tag_configuration("ExampleMetric".to_string(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create a tag configuration returns "Created" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.MetricsApi(configuration);
const params: v2.MetricsApiCreateTagConfigurationRequest = {
body: {
data: {
type: "manage_tags",
id: "ExampleMetric",
attributes: {
tags: ["app", "datacenter"],
metricType: "gauge",
},
},
},
metricName: "ExampleMetric",
};
apiInstance
.createTagConfiguration(params)
.then((data: v2.MetricTagConfigurationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"