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
57 changes: 57 additions & 0 deletions examples/v2/metrics/CreateTagIndexingRule_2435129406.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Create a tag indexing rule with exclude-mode tag usage fields 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.TagIndexingRuleCreateAttributes;
import com.datadog.api.client.v2.model.TagIndexingRuleCreateData;
import com.datadog.api.client.v2.model.TagIndexingRuleCreateRequest;
import com.datadog.api.client.v2.model.TagIndexingRuleDynamicTags;
import com.datadog.api.client.v2.model.TagIndexingRuleOptions;
import com.datadog.api.client.v2.model.TagIndexingRuleOptionsData;
import com.datadog.api.client.v2.model.TagIndexingRuleResponse;
import com.datadog.api.client.v2.model.TagIndexingRuleType;
import java.util.Arrays;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.createTagIndexingRule", true);
MetricsApi apiInstance = new MetricsApi(defaultClient);

TagIndexingRuleCreateRequest body =
new TagIndexingRuleCreateRequest()
.data(
new TagIndexingRuleCreateData()
.attributes(
new TagIndexingRuleCreateAttributes()
.excludeTagsMode(true)
.metricNameMatches(Collections.singletonList("dd.test.*"))
.name("my-indexing-rule")
.options(
new TagIndexingRuleOptions()
.data(
new TagIndexingRuleOptionsData()
.dynamicTags(
new TagIndexingRuleDynamicTags()
.excludeNotQueriedWindowSeconds(3600L)
.excludeNotUsedInAssets(true))
.managePreexistingMetrics(true)
.overridePreviousRules(false))
.version(1L))
.tags(Arrays.asList("env", "service")))
.type(TagIndexingRuleType.TAG_INDEXING_RULES));

try {
TagIndexingRuleResponse result = apiInstance.createTagIndexingRule(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#createTagIndexingRule");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
63 changes: 63 additions & 0 deletions examples/v2/metrics/UpdateTagIndexingRule_4127399471.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Update a tag indexing rule with exclude-mode tag usage fields returns "OK" 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.TagIndexingRuleDynamicTags;
import com.datadog.api.client.v2.model.TagIndexingRuleOptions;
import com.datadog.api.client.v2.model.TagIndexingRuleOptionsData;
import com.datadog.api.client.v2.model.TagIndexingRuleResponse;
import com.datadog.api.client.v2.model.TagIndexingRuleType;
import com.datadog.api.client.v2.model.TagIndexingRuleUpdateAttributes;
import com.datadog.api.client.v2.model.TagIndexingRuleUpdateData;
import com.datadog.api.client.v2.model.TagIndexingRuleUpdateRequest;
import java.util.Arrays;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.updateTagIndexingRule", true);
MetricsApi apiInstance = new MetricsApi(defaultClient);

// there is a valid "tag_indexing_rule_exclude_mode" in the system
String TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID =
System.getenv("TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID");

TagIndexingRuleUpdateRequest body =
new TagIndexingRuleUpdateRequest()
.data(
new TagIndexingRuleUpdateData()
.attributes(
new TagIndexingRuleUpdateAttributes()
.excludeTagsMode(true)
.metricNameMatches(Collections.singletonList("dd.test.*"))
.name("my-indexing-rule")
.options(
new TagIndexingRuleOptions()
.data(
new TagIndexingRuleOptionsData()
.dynamicTags(
new TagIndexingRuleDynamicTags()
.excludeNotQueriedWindowSeconds(7200L)
.excludeNotUsedInAssets(true))
.managePreexistingMetrics(true)
.overridePreviousRules(false))
.version(1L))
.ruleOrder(2L)
.tags(Arrays.asList("env", "service")))
.type(TagIndexingRuleType.TAG_INDEXING_RULES));

try {
TagIndexingRuleResponse result =
apiInstance.updateTagIndexingRule(TAG_INDEXING_RULE_EXCLUDE_MODE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#updateTagIndexingRule");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,89 @@
import java.util.Map;
import java.util.Objects;

/** Configuration for including dynamically queried tags. */
/**
* Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.
*
* <p>Before a tag key is dropped by this rule, two grace period conditions must be met:
*
* <ol>
* <li>The metric must be submitted for at least as long as the selected window.
* <li>A tag key must have been submitted for at least 15 days.
* </ol>
*
* <p>Any metric or tag key that does not meet these conditions are excluded from this indexing
* rule. The <code>exclude_not_*</code> fields require <code>exclude_tags_mode</code> to be set to
* <code>true</code>.
*/
@JsonPropertyOrder({
TagIndexingRuleDynamicTags.JSON_PROPERTY_EXCLUDE_NOT_QUERIED_WINDOW_SECONDS,
TagIndexingRuleDynamicTags.JSON_PROPERTY_EXCLUDE_NOT_USED_IN_ASSETS,
TagIndexingRuleDynamicTags.JSON_PROPERTY_QUERIED_TAGS_WINDOW_SECONDS,
TagIndexingRuleDynamicTags.JSON_PROPERTY_RELATED_ASSET_TAGS
})
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
public class TagIndexingRuleDynamicTags {
@JsonIgnore public boolean unparsed = false;
public static final String JSON_PROPERTY_EXCLUDE_NOT_QUERIED_WINDOW_SECONDS =
"exclude_not_queried_window_seconds";
private Long excludeNotQueriedWindowSeconds;

public static final String JSON_PROPERTY_EXCLUDE_NOT_USED_IN_ASSETS =
"exclude_not_used_in_assets";
private Boolean excludeNotUsedInAssets;

public static final String JSON_PROPERTY_QUERIED_TAGS_WINDOW_SECONDS =
"queried_tags_window_seconds";
private Long queriedTagsWindowSeconds;

public static final String JSON_PROPERTY_RELATED_ASSET_TAGS = "related_asset_tags";
private Boolean relatedAssetTags;

public TagIndexingRuleDynamicTags excludeNotQueriedWindowSeconds(
Long excludeNotQueriedWindowSeconds) {
this.excludeNotQueriedWindowSeconds = excludeNotQueriedWindowSeconds;
return this;
}

/**
* Tags that have not been queried within this window are excluded from indexing. Maximum of
* <code>7776000</code> (90 days). maximum: 7776000
*
* @return excludeNotQueriedWindowSeconds
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_EXCLUDE_NOT_QUERIED_WINDOW_SECONDS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getExcludeNotQueriedWindowSeconds() {
return excludeNotQueriedWindowSeconds;
}

public void setExcludeNotQueriedWindowSeconds(Long excludeNotQueriedWindowSeconds) {
this.excludeNotQueriedWindowSeconds = excludeNotQueriedWindowSeconds;
}

public TagIndexingRuleDynamicTags excludeNotUsedInAssets(Boolean excludeNotUsedInAssets) {
this.excludeNotUsedInAssets = excludeNotUsedInAssets;
return this;
}

/**
* Tags not used in any dashboards, monitors, notebooks, or SLOs are excluded from indexing.
*
* @return excludeNotUsedInAssets
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_EXCLUDE_NOT_USED_IN_ASSETS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Boolean getExcludeNotUsedInAssets() {
return excludeNotUsedInAssets;
}

public void setExcludeNotUsedInAssets(Boolean excludeNotUsedInAssets) {
this.excludeNotUsedInAssets = excludeNotUsedInAssets;
}

public TagIndexingRuleDynamicTags queriedTagsWindowSeconds(Long queriedTagsWindowSeconds) {
this.queriedTagsWindowSeconds = queriedTagsWindowSeconds;
return this;
Expand Down Expand Up @@ -131,6 +198,11 @@ public boolean equals(Object o) {
}
TagIndexingRuleDynamicTags tagIndexingRuleDynamicTags = (TagIndexingRuleDynamicTags) o;
return Objects.equals(
this.excludeNotQueriedWindowSeconds,
tagIndexingRuleDynamicTags.excludeNotQueriedWindowSeconds)
&& Objects.equals(
this.excludeNotUsedInAssets, tagIndexingRuleDynamicTags.excludeNotUsedInAssets)
&& Objects.equals(
this.queriedTagsWindowSeconds, tagIndexingRuleDynamicTags.queriedTagsWindowSeconds)
&& Objects.equals(this.relatedAssetTags, tagIndexingRuleDynamicTags.relatedAssetTags)
&& Objects.equals(
Expand All @@ -139,13 +211,24 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(queriedTagsWindowSeconds, relatedAssetTags, additionalProperties);
return Objects.hash(
excludeNotQueriedWindowSeconds,
excludeNotUsedInAssets,
queriedTagsWindowSeconds,
relatedAssetTags,
additionalProperties);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TagIndexingRuleDynamicTags {\n");
sb.append(" excludeNotQueriedWindowSeconds: ")
.append(toIndentedString(excludeNotQueriedWindowSeconds))
.append("\n");
sb.append(" excludeNotUsedInAssets: ")
.append(toIndentedString(excludeNotUsedInAssets))
.append("\n");
sb.append(" queriedTagsWindowSeconds: ")
.append(toIndentedString(queriedTagsWindowSeconds))
.append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ public TagIndexingRuleOptionsData dynamicTags(TagIndexingRuleDynamicTags dynamic
}

/**
* Configuration for including dynamically queried tags.
* Options for dynamic tag indexing applied per metric, such as tags filtered by query usage.
*
* <p>Before a tag key is dropped by this rule, two grace period conditions must be met:
*
* <ol>
* <li>The metric must be submitted for at least as long as the selected window.
* <li>A tag key must have been submitted for at least 15 days.
* </ol>
*
* <p>Any metric or tag key that does not meet these conditions are excluded from this indexing
* rule. The <code>exclude_not_*</code> fields require <code>exclude_tags_mode</code> to be set to
* <code>true</code>.
*
* @return dynamicTags
*/
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,53 @@
[
{
"httpRequest": {
"body": {
"type": "JSON",
"json": "{\"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": {},
"method": "POST",
"path": "/api/v2/metrics/tag-indexing-rules",
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"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"
]
},
"statusCode": 201,
"reasonPhrase": "Created"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "a192ca36-ce1e-45ff-83c6-1aba712c929b"
},
{
"httpRequest": {
"headers": {},
"method": "DELETE",
"path": "/api/v2/metrics/tag-indexing-rules/50b7b68a-4580-4f9b-8c2c-8622446e68eb",
"keepAlive": false,
"secure": true
},
"httpResponse": {
"headers": {},
"statusCode": 204,
"reasonPhrase": "No Content"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "c3d2e3a7-98b1-8a8a-44aa-b83749a5168e"
}
]
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,32 @@
[
{
"httpRequest": {
"body": {
"type": "JSON",
"json": "{\"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": {},
"method": "POST",
"path": "/api/v2/metrics/tag-indexing-rules",
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"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"
]
},
"statusCode": 400,
"reasonPhrase": "Bad Request"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "0f4a963e-a630-c158-7ce9-3d7ae48e825d"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-07-20T13:47:24.273Z
Loading
Loading