Skip to content

Add Get Tag Cardinalities Endpoint Spec #2938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-07-08 07:29:01.236919",
"spec_repo_commit": "d9879085"
"regenerated": "2025-07-08 18:40:05.900519",
"spec_repo_commit": "6fc2e412"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-07-08 07:29:01.320596",
"spec_repo_commit": "d9879085"
"regenerated": "2025-07-08 18:40:05.916801",
"spec_repo_commit": "6fc2e412"
}
}
}
99 changes: 99 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22807,6 +22807,61 @@ components:
type: string
type: array
type: object
MetricTagCardinalitiesData:
description: A list of tag cardinalities associated with the given metric.
items:
$ref: '#/components/schemas/MetricTagCardinality'
type: array
MetricTagCardinalitiesMeta:
description: Response metadata object.
properties:
metric_name:
description: 'The name of metric for which the tag cardinalities are returned.

This matches the metric name provided in the request.

'
type: string
type: object
MetricTagCardinalitiesResponse:
description: 'Response object that includes an array of objects representing
the cardinality details of a metric''s tags.

'
properties:
data:
$ref: '#/components/schemas/MetricTagCardinalitiesData'
meta:
$ref: '#/components/schemas/MetricTagCardinalitiesMeta'
readOnly: true
type: object
MetricTagCardinality:
description: Object containing metadata and attributes related to a specific
tag key associated with the metric.
example:
attributes:
cardinality_delta: 25
id: http.request.latency
type: tag_cardinality
properties:
attributes:
$ref: '#/components/schemas/MetricTagCardinalityAttributes'
id:
description: The name of the tag key.
type: string
type:
default: tag_cardinality
description: This describes the endpoint action.
type: string
type: object
MetricTagCardinalityAttributes:
description: An object containing properties related to the tag key
properties:
cardinality_delta:
description: This describes the recent change in the tag keys cardinality
format: int64
type: integer
type: object
MetricTagConfiguration:
description: Object for a single metric tag configuration.
example:
Expand Down Expand Up @@ -52849,6 +52904,50 @@ paths:
x-permission:
operator: OPEN
permissions: []
/api/v2/metrics/{metric_name}/tag-cardinalities:
get:
description: Returns the cardinality details of tags for a specific metric.
operationId: GetMetricTagCardinalityDetails
parameters:
- $ref: '#/components/parameters/MetricName'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/MetricTagCardinalitiesResponse'
description: Success
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Not Found
'429':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Too Many Requests
summary: Get tag key cardinality details
tags:
- Metrics
x-permission:
operator: OR
permissions:
- metrics_read
/api/v2/metrics/{metric_name}/tags:
delete:
description: 'Deletes a metric''s tag configuration. Can only be used with application
Expand Down
25 changes: 25 additions & 0 deletions examples/v2/metrics/GetMetricTagCardinalityDetails.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Get tag key cardinality details returns "Success" 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.MetricTagCardinalitiesResponse;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
MetricsApi apiInstance = new MetricsApi(defaultClient);

try {
MetricTagCardinalitiesResponse result =
apiInstance.getMetricTagCardinalityDetails("metric_name");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricsApi#getMetricTagCardinalityDetails");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
147 changes: 147 additions & 0 deletions src/main/java/com/datadog/api/client/v2/api/MetricsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.datadog.api.client.v2.model.MetricEstimateResponse;
import com.datadog.api.client.v2.model.MetricPayload;
import com.datadog.api.client.v2.model.MetricSuggestedTagsAndAggregationsResponse;
import com.datadog.api.client.v2.model.MetricTagCardinalitiesResponse;
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateRequest;
import com.datadog.api.client.v2.model.MetricTagConfigurationMetricTypeCategory;
import com.datadog.api.client.v2.model.MetricTagConfigurationResponse;
Expand Down Expand Up @@ -943,6 +944,152 @@ public ApiResponse<MetricEstimateResponse> estimateMetricsOutputSeriesWithHttpIn
new GenericType<MetricEstimateResponse>() {});
}

/**
* Get tag key cardinality details.
*
* <p>See {@link #getMetricTagCardinalityDetailsWithHttpInfo}.
*
* @param metricName The name of the metric. (required)
* @return MetricTagCardinalitiesResponse
* @throws ApiException if fails to make API call
*/
public MetricTagCardinalitiesResponse getMetricTagCardinalityDetails(String metricName)
throws ApiException {
return getMetricTagCardinalityDetailsWithHttpInfo(metricName).getData();
}

/**
* Get tag key cardinality details.
*
* <p>See {@link #getMetricTagCardinalityDetailsWithHttpInfoAsync}.
*
* @param metricName The name of the metric. (required)
* @return CompletableFuture&lt;MetricTagCardinalitiesResponse&gt;
*/
public CompletableFuture<MetricTagCardinalitiesResponse> getMetricTagCardinalityDetailsAsync(
String metricName) {
return getMetricTagCardinalityDetailsWithHttpInfoAsync(metricName)
.thenApply(
response -> {
return response.getData();
});
}

/**
* Returns the cardinality details of tags for a specific metric.
*
* @param metricName The name of the metric. (required)
* @return ApiResponse&lt;MetricTagCardinalitiesResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table border="1">
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> Success </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too Many Requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<MetricTagCardinalitiesResponse> getMetricTagCardinalityDetailsWithHttpInfo(
String metricName) throws ApiException {
Object localVarPostBody = null;

// verify the required parameter 'metricName' is set
if (metricName == null) {
throw new ApiException(
400,
"Missing the required parameter 'metricName' when calling"
+ " getMetricTagCardinalityDetails");
}
// create path and map variables
String localVarPath =
"/api/v2/metrics/{metric_name}/tag-cardinalities"
.replaceAll(
"\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString()));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder =
apiClient.createBuilder(
"v2.MetricsApi.getMetricTagCardinalityDetails",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"apiKeyAuth", "appKeyAuth"});
return apiClient.invokeAPI(
"GET",
builder,
localVarHeaderParams,
new String[] {},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<MetricTagCardinalitiesResponse>() {});
}

/**
* Get tag key cardinality details.
*
* <p>See {@link #getMetricTagCardinalityDetailsWithHttpInfo}.
*
* @param metricName The name of the metric. (required)
* @return CompletableFuture&lt;ApiResponse&lt;MetricTagCardinalitiesResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<MetricTagCardinalitiesResponse>>
getMetricTagCardinalityDetailsWithHttpInfoAsync(String metricName) {
Object localVarPostBody = null;

// verify the required parameter 'metricName' is set
if (metricName == null) {
CompletableFuture<ApiResponse<MetricTagCardinalitiesResponse>> result =
new CompletableFuture<>();
result.completeExceptionally(
new ApiException(
400,
"Missing the required parameter 'metricName' when calling"
+ " getMetricTagCardinalityDetails"));
return result;
}
// create path and map variables
String localVarPath =
"/api/v2/metrics/{metric_name}/tag-cardinalities"
.replaceAll(
"\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString()));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.MetricsApi.getMetricTagCardinalityDetails",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"apiKeyAuth", "appKeyAuth"});
} catch (ApiException ex) {
CompletableFuture<ApiResponse<MetricTagCardinalitiesResponse>> result =
new CompletableFuture<>();
result.completeExceptionally(ex);
return result;
}
return apiClient.invokeAPIAsync(
"GET",
builder,
localVarHeaderParams,
new String[] {},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<MetricTagCardinalitiesResponse>() {});
}

/** Manage optional parameters to listActiveMetricConfigurations. */
public static class ListActiveMetricConfigurationsOptionalParameters {
private Long windowSeconds;
Expand Down
Loading