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
50 changes: 50 additions & 0 deletions examples/v2/metrics/CreateTagIndexingRule_2435129406.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Create a tag indexing rule with exclude-mode tag usage fields 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.tag_indexing_rule_create_attributes import TagIndexingRuleCreateAttributes
from datadog_api_client.v2.model.tag_indexing_rule_create_data import TagIndexingRuleCreateData
from datadog_api_client.v2.model.tag_indexing_rule_create_request import TagIndexingRuleCreateRequest
from datadog_api_client.v2.model.tag_indexing_rule_dynamic_tags import TagIndexingRuleDynamicTags
from datadog_api_client.v2.model.tag_indexing_rule_options import TagIndexingRuleOptions
from datadog_api_client.v2.model.tag_indexing_rule_options_data import TagIndexingRuleOptionsData
from datadog_api_client.v2.model.tag_indexing_rule_type import TagIndexingRuleType

body = TagIndexingRuleCreateRequest(
data=TagIndexingRuleCreateData(
attributes=TagIndexingRuleCreateAttributes(
exclude_tags_mode=True,
ignored_metric_name_matches=[],
metric_name_matches=[
"dd.test.*",
],
name="my-indexing-rule",
options=TagIndexingRuleOptions(
data=TagIndexingRuleOptionsData(
dynamic_tags=TagIndexingRuleDynamicTags(
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=TagIndexingRuleType.TAG_INDEXING_RULES,
),
)

configuration = Configuration()
configuration.unstable_operations["create_tag_indexing_rule"] = True
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.create_tag_indexing_rule(body=body)

print(response)
55 changes: 55 additions & 0 deletions examples/v2/metrics/UpdateTagIndexingRule_4127399471.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Update a tag indexing rule with exclude-mode tag usage fields returns "OK" 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.tag_indexing_rule_dynamic_tags import TagIndexingRuleDynamicTags
from datadog_api_client.v2.model.tag_indexing_rule_options import TagIndexingRuleOptions
from datadog_api_client.v2.model.tag_indexing_rule_options_data import TagIndexingRuleOptionsData
from datadog_api_client.v2.model.tag_indexing_rule_type import TagIndexingRuleType
from datadog_api_client.v2.model.tag_indexing_rule_update_attributes import TagIndexingRuleUpdateAttributes
from datadog_api_client.v2.model.tag_indexing_rule_update_data import TagIndexingRuleUpdateData
from datadog_api_client.v2.model.tag_indexing_rule_update_request import TagIndexingRuleUpdateRequest

# there is a valid "tag_indexing_rule_exclude_mode" in the system
TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID = environ["TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID"]

body = TagIndexingRuleUpdateRequest(
data=TagIndexingRuleUpdateData(
attributes=TagIndexingRuleUpdateAttributes(
exclude_tags_mode=True,
ignored_metric_name_matches=[],
metric_name_matches=[
"dd.test.*",
],
name="my-indexing-rule",
options=TagIndexingRuleOptions(
data=TagIndexingRuleOptionsData(
dynamic_tags=TagIndexingRuleDynamicTags(
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=[
"env",
"service",
],
),
type=TagIndexingRuleType.TAG_INDEXING_RULES,
),
)

configuration = Configuration()
configuration.unstable_operations["update_tag_indexing_rule"] = True
with ApiClient(configuration) as api_client:
api_instance = MetricsApi(api_client)
response = api_instance.update_tag_indexing_rule(id=TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID, body=body)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,63 @@


class TagIndexingRuleDynamicTags(ModelNormal):
validations = {
"exclude_not_queried_window_seconds": {
"inclusive_maximum": 7776000,
},
}

@cached_property
def openapi_types(_):
return {
"exclude_not_queried_window_seconds": (int,),
"exclude_not_used_in_assets": (bool,),
"queried_tags_window_seconds": (int,),
"related_asset_tags": (bool,),
}

attribute_map = {
"exclude_not_queried_window_seconds": "exclude_not_queried_window_seconds",
"exclude_not_used_in_assets": "exclude_not_used_in_assets",
"queried_tags_window_seconds": "queried_tags_window_seconds",
"related_asset_tags": "related_asset_tags",
}

def __init__(
self_,
exclude_not_queried_window_seconds: Union[int, UnsetType] = unset,
exclude_not_used_in_assets: Union[bool, UnsetType] = unset,
queried_tags_window_seconds: Union[int, UnsetType] = unset,
related_asset_tags: Union[bool, UnsetType] = unset,
**kwargs,
):
"""
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:

#. The metric must be submitted for at least as long as the selected window.
#. 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``.

:param exclude_not_queried_window_seconds: Tags that have not been queried within this window are excluded from indexing. Maximum of ``7776000`` (90 days).
:type exclude_not_queried_window_seconds: int, optional

:param exclude_not_used_in_assets: Tags not used in any dashboards, monitors, notebooks, or SLOs are excluded from indexing.
:type exclude_not_used_in_assets: bool, optional

:param queried_tags_window_seconds: Window in seconds for evaluating queried tags.
:type queried_tags_window_seconds: int, optional

:param related_asset_tags: When true, tags from related assets are included.
:type related_asset_tags: bool, optional
"""
if exclude_not_queried_window_seconds is not unset:
kwargs["exclude_not_queried_window_seconds"] = exclude_not_queried_window_seconds
if exclude_not_used_in_assets is not unset:
kwargs["exclude_not_used_in_assets"] = exclude_not_used_in_assets
if queried_tags_window_seconds is not unset:
kwargs["queried_tags_window_seconds"] = queried_tags_window_seconds
if related_asset_tags is not unset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ def __init__(
"""
Data payload for tag indexing rule options.
:param dynamic_tags: Configuration for including dynamically queried tags.
:param dynamic_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:
#. The metric must be submitted for at least as long as the selected window.
#. 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``.
:type dynamic_tags: TagIndexingRuleDynamicTags, optional
:param manage_preexisting_metrics: 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:24.179Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
interactions:
- request:
body: '{"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"}}'
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\"]}"
headers:
content-type:
- application/vnd.api+json
status:
code: 400
message: Bad Request
version: 1
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,21 @@
interactions:
- request:
body: '{"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"}}'
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)"]}'
headers:
content-type:
- application/vnd.api+json
status:
code: 400
message: Bad Request
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-20T13:47:24.367Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
interactions:
- request:
body: '{"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_used_in_assets":true},"manage_preexisting_metrics":true,"override_previous_rules":false},"version":1},"tags":["env","service"]},"type":"tag_indexing_rules"}}'
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\"]}"
headers:
content-type:
- application/vnd.api+json
status:
code: 400
message: Bad Request
version: 1
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,34 @@
interactions:
- request:
body: '{"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"}}'
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"]}}}'
headers:
content-type:
- application/vnd.api+json
status:
code: 201
message: Created
- request:
body: null
headers:
accept:
- '*/*'
method: DELETE
uri: https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules/50b7b68a-4580-4f9b-8c2c-8622446e68eb
response:
body:
string: ''
headers: {}
status:
code: 204
message: No Content
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-20T13:47:24.486Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
interactions:
- request:
body: '{"data":{"attributes":{"exclude_tags_mode":true,"metric_name_matches":["dd.TestUpdateatagindexingrulewithexcludemodetagusagefieldsreturnsOKresponse1784555244.*"],"name":"TestUpdateatagindexingrulewithexcludemodetagusagefieldsreturnsOKresponse1784555244","tags":["env","service"]},"type":"tag_indexing_rules"}}'
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":"e4a507ac-ee83-439b-bf65-72d162150e3c","type":"tag_indexing_rules","attributes":{"created_at":"2026-07-20T13:47:24.568418Z","created_by_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","exclude_tags_mode":true,"metric_name_matches":["dd.TestUpdateatagindexingrulewithexcludemodetagusagefieldsreturnsOKresponse1784555244.*"],"modified_at":"2026-07-20T13:47:24.568418Z","modified_by_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"TestUpdateatagindexingrulewithexcludemodetagusagefieldsreturnsOKresponse1784555244","options":{"version":1,"data":{"override_previous_rules":false,"manage_preexisting_metrics":true}},"rule_order":1,"tags":["env","service"]}}}'
headers:
content-type:
- application/vnd.api+json
status:
code: 201
message: Created
- request:
body: '{"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":7200,"exclude_not_used_in_assets":true},"manage_preexisting_metrics":true,"override_previous_rules":false},"version":1},"rule_order":2,"tags":["env","service"]},"type":"tag_indexing_rules"}}'
headers:
accept:
- application/json
content-type:
- application/json
method: PUT
uri: https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules/e4a507ac-ee83-439b-bf65-72d162150e3c
response:
body:
string: '{"data":{"id":"e4a507ac-ee83-439b-bf65-72d162150e3c","type":"tag_indexing_rules","attributes":{"created_at":"2026-07-20T13:47:24.568418Z","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.708603Z","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":7200,"exclude_not_used_in_assets":true}}},"rule_order":2,"tags":["env","service"]}}}'
headers:
content-type:
- application/vnd.api+json
status:
code: 200
message: OK
- request:
body: null
headers:
accept:
- '*/*'
method: DELETE
uri: https://api.datadoghq.com/api/v2/metrics/tag-indexing-rules/e4a507ac-ee83-439b-bf65-72d162150e3c
response:
body:
string: ''
headers: {}
status:
code: 204
message: No Content
version: 1
Loading
Loading