Skip to content

Commit 1350eff

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Exclude-mode tag usage fields to tag indexing rules (#1846)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 192bab1 commit 1350eff

17 files changed

Lines changed: 520 additions & 4 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104076,8 +104076,29 @@ components:
104076104076
$ref: "#/components/schemas/TagIndexingRuleType"
104077104077
type: object
104078104078
TagIndexingRuleDynamicTags:
104079-
description: Configuration for including dynamically queried tags.
104079+
description: |-
104080+
Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.
104081+
104082+
Before a tag key is dropped by this rule, two grace period conditions must be met:
104083+
104084+
1. The metric must be submitted for at least as long as the selected window.
104085+
2. A tag key must have been submitted for at least 15 days.
104086+
104087+
Any metric or tag key that does not meet these conditions are excluded from this
104088+
indexing rule. The `exclude_not_*` fields require `exclude_tags_mode` to be set to `true`.
104080104089
properties:
104090+
exclude_not_queried_window_seconds:
104091+
description: >-
104092+
Tags that have not been queried within this window are excluded from indexing. Maximum of `7776000` (90 days).
104093+
example: 3600
104094+
format: int64
104095+
maximum: 7776000
104096+
type: integer
104097+
exclude_not_used_in_assets:
104098+
description: >-
104099+
Tags not used in any dashboards, monitors, notebooks, or SLOs are excluded from indexing.
104100+
example: false
104101+
type: boolean
104081104102
queried_tags_window_seconds:
104082104103
description: Window in seconds for evaluating queried tags.
104083104104
example: 3600
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Create a tag indexing rule with exclude-mode tag usage fields returns "Created"
2+
// response
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
5+
use datadog_api_client::datadogV2::model::TagIndexingRuleCreateAttributes;
6+
use datadog_api_client::datadogV2::model::TagIndexingRuleCreateData;
7+
use datadog_api_client::datadogV2::model::TagIndexingRuleCreateRequest;
8+
use datadog_api_client::datadogV2::model::TagIndexingRuleDynamicTags;
9+
use datadog_api_client::datadogV2::model::TagIndexingRuleOptions;
10+
use datadog_api_client::datadogV2::model::TagIndexingRuleOptionsData;
11+
use datadog_api_client::datadogV2::model::TagIndexingRuleType;
12+
13+
#[tokio::main]
14+
async fn main() {
15+
let body = TagIndexingRuleCreateRequest::new(TagIndexingRuleCreateData::new(
16+
TagIndexingRuleCreateAttributes::new(
17+
vec!["dd.test.*".to_string()],
18+
"my-indexing-rule".to_string(),
19+
)
20+
.exclude_tags_mode(true)
21+
.ignored_metric_name_matches(vec![])
22+
.options(
23+
TagIndexingRuleOptions::new()
24+
.data(
25+
TagIndexingRuleOptionsData::new()
26+
.dynamic_tags(
27+
TagIndexingRuleDynamicTags::new()
28+
.exclude_not_queried_window_seconds(3600)
29+
.exclude_not_used_in_assets(true),
30+
)
31+
.manage_preexisting_metrics(true)
32+
.override_previous_rules(false),
33+
)
34+
.version(1),
35+
)
36+
.tags(vec!["env".to_string(), "service".to_string()]),
37+
TagIndexingRuleType::TAG_INDEXING_RULES,
38+
));
39+
let mut configuration = datadog::Configuration::new();
40+
configuration.set_unstable_operation_enabled("v2.CreateTagIndexingRule", true);
41+
let api = MetricsAPI::with_config(configuration);
42+
let resp = api.create_tag_indexing_rule(body).await;
43+
if let Ok(value) = resp {
44+
println!("{:#?}", value);
45+
} else {
46+
println!("{:#?}", resp.unwrap_err());
47+
}
48+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Update a tag indexing rule with exclude-mode tag usage fields returns "OK"
2+
// response
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV2::api_metrics::MetricsAPI;
5+
use datadog_api_client::datadogV2::model::TagIndexingRuleDynamicTags;
6+
use datadog_api_client::datadogV2::model::TagIndexingRuleOptions;
7+
use datadog_api_client::datadogV2::model::TagIndexingRuleOptionsData;
8+
use datadog_api_client::datadogV2::model::TagIndexingRuleType;
9+
use datadog_api_client::datadogV2::model::TagIndexingRuleUpdateAttributes;
10+
use datadog_api_client::datadogV2::model::TagIndexingRuleUpdateData;
11+
use datadog_api_client::datadogV2::model::TagIndexingRuleUpdateRequest;
12+
13+
#[tokio::main]
14+
async fn main() {
15+
// there is a valid "tag_indexing_rule_exclude_mode" in the system
16+
let tag_indexing_rule_exclude_mode_data_id =
17+
std::env::var("TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID").unwrap();
18+
let body = TagIndexingRuleUpdateRequest::new(
19+
TagIndexingRuleUpdateData::new(TagIndexingRuleType::TAG_INDEXING_RULES).attributes(
20+
TagIndexingRuleUpdateAttributes::new()
21+
.exclude_tags_mode(true)
22+
.ignored_metric_name_matches(vec![])
23+
.metric_name_matches(vec!["dd.test.*".to_string()])
24+
.name("my-indexing-rule".to_string())
25+
.options(
26+
TagIndexingRuleOptions::new()
27+
.data(
28+
TagIndexingRuleOptionsData::new()
29+
.dynamic_tags(
30+
TagIndexingRuleDynamicTags::new()
31+
.exclude_not_queried_window_seconds(7200)
32+
.exclude_not_used_in_assets(true),
33+
)
34+
.manage_preexisting_metrics(true)
35+
.override_previous_rules(false),
36+
)
37+
.version(1),
38+
)
39+
.rule_order(2)
40+
.tags(vec!["env".to_string(), "service".to_string()]),
41+
),
42+
);
43+
let mut configuration = datadog::Configuration::new();
44+
configuration.set_unstable_operation_enabled("v2.UpdateTagIndexingRule", true);
45+
let api = MetricsAPI::with_config(configuration);
46+
let resp = api
47+
.update_tag_indexing_rule(tag_indexing_rule_exclude_mode_data_id.clone(), body)
48+
.await;
49+
if let Ok(value) = resp {
50+
println!("{:#?}", value);
51+
} else {
52+
println!("{:#?}", resp.unwrap_err());
53+
}
54+
}

src/datadogV2/model/model_tag_indexing_rule_dynamic_tags.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@ use serde::{Deserialize, Deserializer, Serialize};
66
use serde_with::skip_serializing_none;
77
use std::fmt::{self, Formatter};
88

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

53+
pub fn exclude_not_queried_window_seconds(mut self, value: i64) -> Self {
54+
self.exclude_not_queried_window_seconds = Some(value);
55+
self
56+
}
57+
58+
pub fn exclude_not_used_in_assets(mut self, value: bool) -> Self {
59+
self.exclude_not_used_in_assets = Some(value);
60+
self
61+
}
62+
3763
pub fn queried_tags_window_seconds(mut self, value: i64) -> Self {
3864
self.queried_tags_window_seconds = Some(value);
3965
self
@@ -76,6 +102,8 @@ impl<'de> Deserialize<'de> for TagIndexingRuleDynamicTags {
76102
where
77103
M: MapAccess<'a>,
78104
{
105+
let mut exclude_not_queried_window_seconds: Option<i64> = None;
106+
let mut exclude_not_used_in_assets: Option<bool> = None;
79107
let mut queried_tags_window_seconds: Option<i64> = None;
80108
let mut related_asset_tags: Option<bool> = None;
81109
let mut additional_properties: std::collections::BTreeMap<
@@ -86,6 +114,20 @@ impl<'de> Deserialize<'de> for TagIndexingRuleDynamicTags {
86114

87115
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
88116
match k.as_str() {
117+
"exclude_not_queried_window_seconds" => {
118+
if v.is_null() {
119+
continue;
120+
}
121+
exclude_not_queried_window_seconds =
122+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
123+
}
124+
"exclude_not_used_in_assets" => {
125+
if v.is_null() {
126+
continue;
127+
}
128+
exclude_not_used_in_assets =
129+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
130+
}
89131
"queried_tags_window_seconds" => {
90132
if v.is_null() {
91133
continue;
@@ -109,6 +151,8 @@ impl<'de> Deserialize<'de> for TagIndexingRuleDynamicTags {
109151
}
110152

111153
let content = TagIndexingRuleDynamicTags {
154+
exclude_not_queried_window_seconds,
155+
exclude_not_used_in_assets,
112156
queried_tags_window_seconds,
113157
related_asset_tags,
114158
additional_properties,

src/datadogV2/model/model_tag_indexing_rule_options_data.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ use std::fmt::{self, Formatter};
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct TagIndexingRuleOptionsData {
14-
/// Configuration for including dynamically queried tags.
14+
/// Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.
15+
///
16+
/// Before a tag key is dropped by this rule, two grace period conditions must be met:
17+
///
18+
/// 1. The metric must be submitted for at least as long as the selected window.
19+
/// 2. A tag key must have been submitted for at least 15 days.
20+
///
21+
/// Any metric or tag key that does not meet these conditions are excluded from this
22+
/// indexing rule. The `exclude_not_*` fields require `exclude_tags_mode` to be set to `true`.
1523
#[serde(rename = "dynamic_tags")]
1624
pub dynamic_tags: Option<crate::datadogV2::model::TagIndexingRuleDynamicTags>,
1725
/// When true, the rule applies to metrics that were ingested before the rule was created.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-07-20T13:47:22.097Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": {
6+
"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\"}}",
7+
"encoding": null
8+
},
9+
"headers": {
10+
"Accept": [
11+
"application/json"
12+
],
13+
"Content-Type": [
14+
"application/json"
15+
]
16+
},
17+
"method": "post",
18+
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules"
19+
},
20+
"response": {
21+
"body": {
22+
"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\"]}}}",
23+
"encoding": null
24+
},
25+
"headers": {
26+
"Content-Type": [
27+
"application/vnd.api+json"
28+
]
29+
},
30+
"status": {
31+
"code": 201,
32+
"message": "Created"
33+
}
34+
},
35+
"recorded_at": "Mon, 20 Jul 2026 13:47:22 GMT"
36+
},
37+
{
38+
"request": {
39+
"body": "",
40+
"headers": {
41+
"Accept": [
42+
"*/*"
43+
]
44+
},
45+
"method": "delete",
46+
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules/50b7b68a-4580-4f9b-8c2c-8622446e68eb"
47+
},
48+
"response": {
49+
"body": {
50+
"string": "",
51+
"encoding": null
52+
},
53+
"headers": {},
54+
"status": {
55+
"code": 204,
56+
"message": "No Content"
57+
}
58+
},
59+
"recorded_at": "Mon, 20 Jul 2026 13:47:22 GMT"
60+
}
61+
],
62+
"recorded_with": "VCR 6.0.0"
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-07-20T13:47:24.179Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": {
6+
"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\"}}",
7+
"encoding": null
8+
},
9+
"headers": {
10+
"Accept": [
11+
"application/json"
12+
],
13+
"Content-Type": [
14+
"application/json"
15+
]
16+
},
17+
"method": "post",
18+
"uri": "https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules"
19+
},
20+
"response": {
21+
"body": {
22+
"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\"]}",
23+
"encoding": null
24+
},
25+
"headers": {
26+
"Content-Type": [
27+
"application/vnd.api+json"
28+
]
29+
},
30+
"status": {
31+
"code": 400,
32+
"message": "Bad Request"
33+
}
34+
},
35+
"recorded_at": "Mon, 20 Jul 2026 13:47:24 GMT"
36+
}
37+
],
38+
"recorded_with": "VCR 6.0.0"
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-07-20T13:47:24.273Z

0 commit comments

Comments
 (0)