Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104076,8 +104076,29 @@ components:
$ref: "#/components/schemas/TagIndexingRuleType"
type: object
TagIndexingRuleDynamicTags:
description: Configuration for including dynamically queried tags.
description: |-
Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.

Before a tag key is dropped by this rule, two grace period conditions must be met:

1. The metric must be submitted for at least as long as the selected window.
2. A tag key must have been submitted for at least 15 days.

Any metric or tag key that does not meet these conditions are excluded from this
indexing rule. The `exclude_not_*` fields require `exclude_tags_mode` to be set to `true`.
properties:
exclude_not_queried_window_seconds:
description: >-
Tags that have not been queried within this window are excluded from indexing. Maximum of `7776000` (90 days).
example: 3600
format: int64
maximum: 7776000
type: integer
exclude_not_used_in_assets:
description: >-
Tags not used in any dashboards, monitors, notebooks, or SLOs are excluded from indexing.
example: false
type: boolean
queried_tags_window_seconds:
description: Window in seconds for evaluating queried tags.
example: 3600
Expand Down
48 changes: 48 additions & 0 deletions examples/v2_metrics_CreateTagIndexingRule_2435129406.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Create a tag indexing rule with exclude-mode tag usage fields returns "Created"
// response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::TagIndexingRuleCreateAttributes;
use datadog_api_client::datadogV2::model::TagIndexingRuleCreateData;
use datadog_api_client::datadogV2::model::TagIndexingRuleCreateRequest;
use datadog_api_client::datadogV2::model::TagIndexingRuleDynamicTags;
use datadog_api_client::datadogV2::model::TagIndexingRuleOptions;
use datadog_api_client::datadogV2::model::TagIndexingRuleOptionsData;
use datadog_api_client::datadogV2::model::TagIndexingRuleType;

#[tokio::main]
async fn main() {
let body = TagIndexingRuleCreateRequest::new(TagIndexingRuleCreateData::new(
TagIndexingRuleCreateAttributes::new(
vec!["dd.test.*".to_string()],
"my-indexing-rule".to_string(),
)
.exclude_tags_mode(true)
.ignored_metric_name_matches(vec![])
.options(
TagIndexingRuleOptions::new()
.data(
TagIndexingRuleOptionsData::new()
.dynamic_tags(
TagIndexingRuleDynamicTags::new()
.exclude_not_queried_window_seconds(3600)
.exclude_not_used_in_assets(true),
)
.manage_preexisting_metrics(true)
.override_previous_rules(false),
)
.version(1),
)
.tags(vec!["env".to_string(), "service".to_string()]),
TagIndexingRuleType::TAG_INDEXING_RULES,
));
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.CreateTagIndexingRule", true);
let api = MetricsAPI::with_config(configuration);
let resp = api.create_tag_indexing_rule(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
54 changes: 54 additions & 0 deletions examples/v2_metrics_UpdateTagIndexingRule_4127399471.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Update a tag indexing rule with exclude-mode tag usage fields returns "OK"
// response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
use datadog_api_client::datadogV2::model::TagIndexingRuleDynamicTags;
use datadog_api_client::datadogV2::model::TagIndexingRuleOptions;
use datadog_api_client::datadogV2::model::TagIndexingRuleOptionsData;
use datadog_api_client::datadogV2::model::TagIndexingRuleType;
use datadog_api_client::datadogV2::model::TagIndexingRuleUpdateAttributes;
use datadog_api_client::datadogV2::model::TagIndexingRuleUpdateData;
use datadog_api_client::datadogV2::model::TagIndexingRuleUpdateRequest;

#[tokio::main]
async fn main() {
// there is a valid "tag_indexing_rule_exclude_mode" in the system
let tag_indexing_rule_exclude_mode_data_id =
std::env::var("TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID").unwrap();
let body = TagIndexingRuleUpdateRequest::new(
TagIndexingRuleUpdateData::new(TagIndexingRuleType::TAG_INDEXING_RULES).attributes(
TagIndexingRuleUpdateAttributes::new()
.exclude_tags_mode(true)
.ignored_metric_name_matches(vec![])
.metric_name_matches(vec!["dd.test.*".to_string()])
.name("my-indexing-rule".to_string())
.options(
TagIndexingRuleOptions::new()
.data(
TagIndexingRuleOptionsData::new()
.dynamic_tags(
TagIndexingRuleDynamicTags::new()
.exclude_not_queried_window_seconds(7200)
.exclude_not_used_in_assets(true),
)
.manage_preexisting_metrics(true)
.override_previous_rules(false),
)
.version(1),
)
.rule_order(2)
.tags(vec!["env".to_string(), "service".to_string()]),
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.UpdateTagIndexingRule", true);
let api = MetricsAPI::with_config(configuration);
let resp = api
.update_tag_indexing_rule(tag_indexing_rule_exclude_mode_data_id.clone(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
46 changes: 45 additions & 1 deletion src/datadogV2/model/model_tag_indexing_rule_dynamic_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};

/// Configuration for including dynamically queried tags.
/// Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.
///
/// Before a tag key is dropped by this rule, two grace period conditions must be met:
///
/// 1. The metric must be submitted for at least as long as the selected window.
/// 2. A tag key must have been submitted for at least 15 days.
///
/// Any metric or tag key that does not meet these conditions are excluded from this
/// indexing rule. The `exclude_not_*` fields require `exclude_tags_mode` to be set to `true`.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct TagIndexingRuleDynamicTags {
/// Tags that have not been queried within this window are excluded from indexing. Maximum of `7776000` (90 days).
#[serde(rename = "exclude_not_queried_window_seconds")]
pub exclude_not_queried_window_seconds: Option<i64>,
/// Tags not used in any dashboards, monitors, notebooks, or SLOs are excluded from indexing.
#[serde(rename = "exclude_not_used_in_assets")]
pub exclude_not_used_in_assets: Option<bool>,
/// Window in seconds for evaluating queried tags.
#[serde(rename = "queried_tags_window_seconds")]
pub queried_tags_window_seconds: Option<i64>,
Expand All @@ -27,13 +41,25 @@ pub struct TagIndexingRuleDynamicTags {
impl TagIndexingRuleDynamicTags {
pub fn new() -> TagIndexingRuleDynamicTags {
TagIndexingRuleDynamicTags {
exclude_not_queried_window_seconds: None,
exclude_not_used_in_assets: None,
queried_tags_window_seconds: None,
related_asset_tags: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn exclude_not_queried_window_seconds(mut self, value: i64) -> Self {
self.exclude_not_queried_window_seconds = Some(value);
self
}

pub fn exclude_not_used_in_assets(mut self, value: bool) -> Self {
self.exclude_not_used_in_assets = Some(value);
self
}

pub fn queried_tags_window_seconds(mut self, value: i64) -> Self {
self.queried_tags_window_seconds = Some(value);
self
Expand Down Expand Up @@ -76,6 +102,8 @@ impl<'de> Deserialize<'de> for TagIndexingRuleDynamicTags {
where
M: MapAccess<'a>,
{
let mut exclude_not_queried_window_seconds: Option<i64> = None;
let mut exclude_not_used_in_assets: Option<bool> = None;
let mut queried_tags_window_seconds: Option<i64> = None;
let mut related_asset_tags: Option<bool> = None;
let mut additional_properties: std::collections::BTreeMap<
Expand All @@ -86,6 +114,20 @@ impl<'de> Deserialize<'de> for TagIndexingRuleDynamicTags {

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"exclude_not_queried_window_seconds" => {
if v.is_null() {
continue;
}
exclude_not_queried_window_seconds =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"exclude_not_used_in_assets" => {
if v.is_null() {
continue;
}
exclude_not_used_in_assets =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"queried_tags_window_seconds" => {
if v.is_null() {
continue;
Expand All @@ -109,6 +151,8 @@ impl<'de> Deserialize<'de> for TagIndexingRuleDynamicTags {
}

let content = TagIndexingRuleDynamicTags {
exclude_not_queried_window_seconds,
exclude_not_used_in_assets,
queried_tags_window_seconds,
related_asset_tags,
additional_properties,
Expand Down
10 changes: 9 additions & 1 deletion src/datadogV2/model/model_tag_indexing_rule_options_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ use std::fmt::{self, Formatter};
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct TagIndexingRuleOptionsData {
/// Configuration for including dynamically queried tags.
/// Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.
///
/// Before a tag key is dropped by this rule, two grace period conditions must be met:
///
/// 1. The metric must be submitted for at least as long as the selected window.
/// 2. A tag key must have been submitted for at least 15 days.
///
/// Any metric or tag key that does not meet these conditions are excluded from this
/// indexing rule. The `exclude_not_*` fields require `exclude_tags_mode` to be set to `true`.
#[serde(rename = "dynamic_tags")]
pub dynamic_tags: Option<crate::datadogV2::model::TagIndexingRuleDynamicTags>,
/// When true, the rule applies to metrics that were ingested before the rule was created.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-20T13:47:22.097Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"http_interactions": [
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"exclude_tags_mode\":true,\"ignored_metric_name_matches\":[],\"metric_name_matches\":[\"dd.test.*\"],\"name\":\"my-indexing-rule\",\"options\":{\"data\":{\"dynamic_tags\":{\"exclude_not_queried_window_seconds\":3600,\"exclude_not_used_in_assets\":true},\"manage_preexisting_metrics\":true,\"override_previous_rules\":false},\"version\":1},\"tags\":[\"env\",\"service\"]},\"type\":\"tag_indexing_rules\"}}",
"encoding": null
},
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json"
]
},
"method": "post",
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules"
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"50b7b68a-4580-4f9b-8c2c-8622446e68eb\",\"type\":\"tag_indexing_rules\",\"attributes\":{\"created_at\":\"2026-07-20T13:47:24.033083Z\",\"created_by_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"exclude_tags_mode\":true,\"ignored_metric_name_matches\":[],\"metric_name_matches\":[\"dd.test.*\"],\"modified_at\":\"2026-07-20T13:47:24.033083Z\",\"modified_by_handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"my-indexing-rule\",\"options\":{\"version\":1,\"data\":{\"override_previous_rules\":false,\"manage_preexisting_metrics\":true,\"dynamic_tags\":{\"exclude_not_queried_window_seconds\":3600,\"exclude_not_used_in_assets\":true}}},\"rule_order\":1,\"tags\":[\"env\",\"service\"]}}}",
"encoding": null
},
"headers": {
"Content-Type": [
"application/vnd.api+json"
]
},
"status": {
"code": 201,
"message": "Created"
}
},
"recorded_at": "Mon, 20 Jul 2026 13:47:22 GMT"
},
{
"request": {
"body": "",
"headers": {
"Accept": [
"*/*"
]
},
"method": "delete",
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules/50b7b68a-4580-4f9b-8c2c-8622446e68eb"
},
"response": {
"body": {
"string": "",
"encoding": null
},
"headers": {},
"status": {
"code": 204,
"message": "No Content"
}
},
"recorded_at": "Mon, 20 Jul 2026 13:47:22 GMT"
}
],
"recorded_with": "VCR 6.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-20T13:47:24.179Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"http_interactions": [
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"exclude_tags_mode\":false,\"ignored_metric_name_matches\":[],\"metric_name_matches\":[\"dd.test.*\"],\"name\":\"my-indexing-rule\",\"options\":{\"data\":{\"dynamic_tags\":{\"exclude_not_queried_window_seconds\":3600},\"manage_preexisting_metrics\":true,\"override_previous_rules\":false},\"version\":1},\"tags\":[\"env\",\"service\"]},\"type\":\"tag_indexing_rules\"}}",
"encoding": null
},
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json"
]
},
"method": "post",
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules"
},
"response": {
"body": {
"string": "{\"errors\":[\"Invalid request body: exclude_not_queried_window_seconds/exclude_not_used_in_assets cannot be set when exclude_tags_mode is false \u2014 \\\"by tag usage\\\" is Exclude-mode only\"]}",
"encoding": null
},
"headers": {
"Content-Type": [
"application/vnd.api+json"
]
},
"status": {
"code": 400,
"message": "Bad Request"
}
},
"recorded_at": "Mon, 20 Jul 2026 13:47:24 GMT"
}
],
"recorded_with": "VCR 6.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-20T13:47:24.273Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"http_interactions": [
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"exclude_tags_mode\":true,\"ignored_metric_name_matches\":[],\"metric_name_matches\":[\"dd.test.*\"],\"name\":\"my-indexing-rule\",\"options\":{\"data\":{\"dynamic_tags\":{\"exclude_not_queried_window_seconds\":7776001},\"manage_preexisting_metrics\":true,\"override_previous_rules\":false},\"version\":1},\"tags\":[\"env\",\"service\"]},\"type\":\"tag_indexing_rules\"}}",
"encoding": null
},
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json"
]
},
"method": "post",
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules"
},
"response": {
"body": {
"string": "{\"errors\":[\"Invalid request body: dynamic_tags.exclude_not_queried_window_seconds cannot exceed 7776000 seconds (90 days)\"]}",
"encoding": null
},
"headers": {
"Content-Type": [
"application/vnd.api+json"
]
},
"status": {
"code": 400,
"message": "Bad Request"
}
},
"recorded_at": "Mon, 20 Jul 2026 13:47:24 GMT"
}
],
"recorded_with": "VCR 6.0.0"
}
Loading
Loading