diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ed984a56d0..61320cadad 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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 diff --git a/examples/v2/metrics/CreateTagIndexingRule_2435129406.py b/examples/v2/metrics/CreateTagIndexingRule_2435129406.py new file mode 100644 index 0000000000..54a61e50d4 --- /dev/null +++ b/examples/v2/metrics/CreateTagIndexingRule_2435129406.py @@ -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) diff --git a/examples/v2/metrics/UpdateTagIndexingRule_4127399471.py b/examples/v2/metrics/UpdateTagIndexingRule_4127399471.py new file mode 100644 index 0000000000..4196b0b1a0 --- /dev/null +++ b/examples/v2/metrics/UpdateTagIndexingRule_4127399471.py @@ -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) diff --git a/src/datadog_api_client/v2/model/tag_indexing_rule_dynamic_tags.py b/src/datadog_api_client/v2/model/tag_indexing_rule_dynamic_tags.py index 77fbedeaca..d450d53c27 100644 --- a/src/datadog_api_client/v2/model/tag_indexing_rule_dynamic_tags.py +++ b/src/datadog_api_client/v2/model/tag_indexing_rule_dynamic_tags.py @@ -14,26 +14,52 @@ 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 @@ -41,6 +67,10 @@ def __init__( :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: diff --git a/src/datadog_api_client/v2/model/tag_indexing_rule_options_data.py b/src/datadog_api_client/v2/model/tag_indexing_rule_options_data.py index 2ff424b00f..5964296bdd 100644 --- a/src/datadog_api_client/v2/model/tag_indexing_rule_options_data.py +++ b/src/datadog_api_client/v2/model/tag_indexing_rule_options_data.py @@ -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. diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_and_exclude_tags_mode_false_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_and_exclude_tags_mode_false_returns_bad_request_response.frozen new file mode 100644 index 0000000000..e653d57061 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_and_exclude_tags_mode_false_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2026-07-20T13:47:24.179Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_and_exclude_tags_mode_false_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_and_exclude_tags_mode_false_returns_bad_request_response.yaml new file mode 100644 index 0000000000..1bc976a26c --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_and_exclude_tags_mode_false_returns_bad_request_response.yaml @@ -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 diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_over_the_maximum_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_over_the_maximum_returns_bad_request_response.frozen new file mode 100644 index 0000000000..34477e0b53 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_over_the_maximum_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2026-07-20T13:47:24.273Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_over_the_maximum_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_over_the_maximum_returns_bad_request_response.yaml new file mode 100644 index 0000000000..bfea4d980a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_queried_window_seconds_over_the_maximum_returns_bad_request_response.yaml @@ -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 diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_used_in_assets_and_exclude_tags_mode_false_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_used_in_assets_and_exclude_tags_mode_false_returns_bad_request_response.frozen new file mode 100644 index 0000000000..bfa63b117d --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_used_in_assets_and_exclude_tags_mode_false_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2026-07-20T13:47:24.367Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_used_in_assets_and_exclude_tags_mode_false_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_used_in_assets_and_exclude_tags_mode_false_returns_bad_request_response.yaml new file mode 100644 index 0000000000..a0561e03d7 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_exclude_not_used_in_assets_and_exclude_tags_mode_false_returns_bad_request_response.yaml @@ -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 diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_created_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_created_response.frozen new file mode 100644 index 0000000000..0f10cd49f0 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_created_response.frozen @@ -0,0 +1 @@ +2026-07-20T13:47:22.097Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_created_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_created_response.yaml new file mode 100644 index 0000000000..7974d631ec --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_created_response.yaml @@ -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 diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_ok_response.frozen new file mode 100644 index 0000000000..41394dceed --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-07-20T13:47:24.486Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_ok_response.yaml new file mode 100644 index 0000000000..55fd5297ac --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_tag_indexing_rule_with_excludemode_tag_usage_fields_returns_ok_response.yaml @@ -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 diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index 0f9de6d48a..75fa924ff1 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -954,6 +954,18 @@ "tag": "Metrics", "operationId": "CreateTagIndexingRule" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"tag_indexing_rules\",\n \"attributes\": {\n \"name\": \"{{ unique_alnum }}\",\n \"exclude_tags_mode\": true,\n \"metric_name_matches\": [\"dd.{{ unique_alnum }}.*\"],\n \"tags\": [\"env\", \"service\"]\n }\n }\n}" + } + ], + "step": "there is a valid \"tag_indexing_rule_exclude_mode\" in the system", + "key": "tag_indexing_rule_exclude_mode", + "tag": "Metrics", + "operationId": "CreateTagIndexingRule" + }, { "parameters": [ { diff --git a/tests/v2/features/metrics.feature b/tests/v2/features/metrics.feature index 24b766d5d5..d463aa4250 100644 --- a/tests/v2/features/metrics.feature +++ b/tests/v2/features/metrics.feature @@ -106,6 +106,42 @@ Feature: Metrics When the request is sent Then the response status is 201 Created + @team:DataDog/metrics-experience + Scenario: Create a tag indexing rule with exclude-mode tag usage fields returns "Created" response + Given a valid "appKeyAuth" key in the system + And operation "CreateTagIndexingRule" enabled + And new "CreateTagIndexingRule" request + And body with value {"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"}} + When the request is sent + Then the response status is 201 Created + + @team:DataDog/metrics-experience + Scenario: Create a tag indexing rule with exclude_not_queried_window_seconds and exclude_tags_mode false returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "CreateTagIndexingRule" enabled + And new "CreateTagIndexingRule" request + And body with value {"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"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/metrics-experience + Scenario: Create a tag indexing rule with exclude_not_queried_window_seconds over the maximum returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "CreateTagIndexingRule" enabled + And new "CreateTagIndexingRule" request + And body with value {"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"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/metrics-experience + Scenario: Create a tag indexing rule with exclude_not_used_in_assets and exclude_tags_mode false returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "CreateTagIndexingRule" enabled + And new "CreateTagIndexingRule" request + And body with value {"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"}} + When the request is sent + Then the response status is 400 Bad Request + @replay-only @skip-validation @team:DataDog/metrics-experience Scenario: Delete a tag configuration returns "No Content" response Given there is a valid "metric" in the system @@ -995,7 +1031,7 @@ Feature: Metrics And operation "UpdateTagIndexingRule" enabled And new "UpdateTagIndexingRule" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"ignored_metric_name_matches": [], "metric_name_matches": ["dd.test.*"], "name": "my-indexing-rule", "options": {"data": {"dynamic_tags": {"queried_tags_window_seconds": 3600, "related_asset_tags": false}, "manage_preexisting_metrics": true, "metric_match": {"queried_window_seconds": 3600}, "override_previous_rules": false}, "version": 1}, "rule_order": 2, "tags": ["env", "service"]}, "type": "tag_indexing_rules"}} + And body with value {"data": {"attributes": {"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": false, "queried_tags_window_seconds": 3600, "related_asset_tags": false}, "manage_preexisting_metrics": true, "metric_match": {"queried_window_seconds": 3600}, "override_previous_rules": false}, "version": 1}, "rule_order": 2, "tags": ["env", "service"]}, "type": "tag_indexing_rules"}} When the request is sent Then the response status is 409 Conflict @@ -1019,3 +1055,14 @@ Feature: Metrics And body with value {"data": {"attributes": {"ignored_metric_name_matches": [], "metric_name_matches": ["dd.test.*"], "name": "my-indexing-rule", "options": {"data": {"dynamic_tags": {"queried_tags_window_seconds": 3600, "related_asset_tags": false}, "manage_preexisting_metrics": true, "metric_match": {"queried_window_seconds": 3600}, "override_previous_rules": false}, "version": 1}, "rule_order": 2, "tags": ["env", "service"]}, "type": "tag_indexing_rules"}} When the request is sent Then the response status is 200 OK + + @team:DataDog/metrics-experience + Scenario: Update a tag indexing rule with exclude-mode tag usage fields returns "OK" response + Given a valid "appKeyAuth" key in the system + And operation "UpdateTagIndexingRule" enabled + And there is a valid "tag_indexing_rule_exclude_mode" in the system + And new "UpdateTagIndexingRule" request + And request contains "id" parameter from "tag_indexing_rule_exclude_mode.data.id" + And body with value {"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"}} + When the request is sent + Then the response status is 200 OK