Skip to content

Commit 51d64fd

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Get Tag Cardinalities Endpoint Spec (#2938)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 8348cd4 commit 51d64fd

File tree

10 files changed

+956
-2
lines changed

10 files changed

+956
-2
lines changed

.generated-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"spec_repo_commit": "20279f4",
3-
"generated": "2025-07-18 10:24:13.081"
2+
"spec_repo_commit": "dc49df4",
3+
"generated": "2025-07-18 13:58:47.478"
44
}

.generator/schemas/v2/openapi.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23189,6 +23189,61 @@ components:
2318923189
type: string
2319023190
type: array
2319123191
type: object
23192+
MetricTagCardinalitiesData:
23193+
description: A list of tag cardinalities associated with the given metric.
23194+
items:
23195+
$ref: '#/components/schemas/MetricTagCardinality'
23196+
type: array
23197+
MetricTagCardinalitiesMeta:
23198+
description: Response metadata object.
23199+
properties:
23200+
metric_name:
23201+
description: 'The name of metric for which the tag cardinalities are returned.
23202+
23203+
This matches the metric name provided in the request.
23204+
23205+
'
23206+
type: string
23207+
type: object
23208+
MetricTagCardinalitiesResponse:
23209+
description: 'Response object that includes an array of objects representing
23210+
the cardinality details of a metric''s tags.
23211+
23212+
'
23213+
properties:
23214+
data:
23215+
$ref: '#/components/schemas/MetricTagCardinalitiesData'
23216+
meta:
23217+
$ref: '#/components/schemas/MetricTagCardinalitiesMeta'
23218+
readOnly: true
23219+
type: object
23220+
MetricTagCardinality:
23221+
description: Object containing metadata and attributes related to a specific
23222+
tag key associated with the metric.
23223+
example:
23224+
attributes:
23225+
cardinality_delta: 25
23226+
id: http.request.latency
23227+
type: tag_cardinality
23228+
properties:
23229+
attributes:
23230+
$ref: '#/components/schemas/MetricTagCardinalityAttributes'
23231+
id:
23232+
description: The name of the tag key.
23233+
type: string
23234+
type:
23235+
default: tag_cardinality
23236+
description: This describes the endpoint action.
23237+
type: string
23238+
type: object
23239+
MetricTagCardinalityAttributes:
23240+
description: An object containing properties related to the tag key
23241+
properties:
23242+
cardinality_delta:
23243+
description: This describes the recent change in the tag keys cardinality
23244+
format: int64
23245+
type: integer
23246+
type: object
2319223247
MetricTagConfiguration:
2319323248
description: Object for a single metric tag configuration.
2319423249
example:
@@ -53610,6 +53665,50 @@ paths:
5361053665
x-permission:
5361153666
operator: OPEN
5361253667
permissions: []
53668+
/api/v2/metrics/{metric_name}/tag-cardinalities:
53669+
get:
53670+
description: Returns the cardinality details of tags for a specific metric.
53671+
operationId: GetMetricTagCardinalityDetails
53672+
parameters:
53673+
- $ref: '#/components/parameters/MetricName'
53674+
responses:
53675+
'200':
53676+
content:
53677+
application/json:
53678+
schema:
53679+
$ref: '#/components/schemas/MetricTagCardinalitiesResponse'
53680+
description: Success
53681+
'400':
53682+
content:
53683+
application/json:
53684+
schema:
53685+
$ref: '#/components/schemas/APIErrorResponse'
53686+
description: Bad Request
53687+
'403':
53688+
content:
53689+
application/json:
53690+
schema:
53691+
$ref: '#/components/schemas/APIErrorResponse'
53692+
description: Forbidden
53693+
'404':
53694+
content:
53695+
application/json:
53696+
schema:
53697+
$ref: '#/components/schemas/APIErrorResponse'
53698+
description: Not Found
53699+
'429':
53700+
content:
53701+
application/json:
53702+
schema:
53703+
$ref: '#/components/schemas/APIErrorResponse'
53704+
description: Too Many Requests
53705+
summary: Get tag key cardinality details
53706+
tags:
53707+
- Metrics
53708+
x-permission:
53709+
operator: OR
53710+
permissions:
53711+
- metrics_read
5361353712
/api/v2/metrics/{metric_name}/tags:
5361453713
delete:
5361553714
description: 'Deletes a metric''s tag configuration. Can only be used with application
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Get tag key cardinality details returns "Success" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.MetricsApi;
6+
import com.datadog.api.client.v2.model.MetricTagCardinalitiesResponse;
7+
8+
public class Example {
9+
public static void main(String[] args) {
10+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
11+
MetricsApi apiInstance = new MetricsApi(defaultClient);
12+
13+
try {
14+
MetricTagCardinalitiesResponse result =
15+
apiInstance.getMetricTagCardinalityDetails("metric_name");
16+
System.out.println(result);
17+
} catch (ApiException e) {
18+
System.err.println("Exception when calling MetricsApi#getMetricTagCardinalityDetails");
19+
System.err.println("Status code: " + e.getCode());
20+
System.err.println("Reason: " + e.getResponseBody());
21+
System.err.println("Response headers: " + e.getResponseHeaders());
22+
e.printStackTrace();
23+
}
24+
}
25+
}

src/main/java/com/datadog/api/client/v2/api/MetricsApi.java

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.datadog.api.client.v2.model.MetricEstimateResponse;
1616
import com.datadog.api.client.v2.model.MetricPayload;
1717
import com.datadog.api.client.v2.model.MetricSuggestedTagsAndAggregationsResponse;
18+
import com.datadog.api.client.v2.model.MetricTagCardinalitiesResponse;
1819
import com.datadog.api.client.v2.model.MetricTagConfigurationCreateRequest;
1920
import com.datadog.api.client.v2.model.MetricTagConfigurationMetricTypeCategory;
2021
import com.datadog.api.client.v2.model.MetricTagConfigurationResponse;
@@ -943,6 +944,152 @@ public ApiResponse<MetricEstimateResponse> estimateMetricsOutputSeriesWithHttpIn
943944
new GenericType<MetricEstimateResponse>() {});
944945
}
945946

947+
/**
948+
* Get tag key cardinality details.
949+
*
950+
* <p>See {@link #getMetricTagCardinalityDetailsWithHttpInfo}.
951+
*
952+
* @param metricName The name of the metric. (required)
953+
* @return MetricTagCardinalitiesResponse
954+
* @throws ApiException if fails to make API call
955+
*/
956+
public MetricTagCardinalitiesResponse getMetricTagCardinalityDetails(String metricName)
957+
throws ApiException {
958+
return getMetricTagCardinalityDetailsWithHttpInfo(metricName).getData();
959+
}
960+
961+
/**
962+
* Get tag key cardinality details.
963+
*
964+
* <p>See {@link #getMetricTagCardinalityDetailsWithHttpInfoAsync}.
965+
*
966+
* @param metricName The name of the metric. (required)
967+
* @return CompletableFuture&lt;MetricTagCardinalitiesResponse&gt;
968+
*/
969+
public CompletableFuture<MetricTagCardinalitiesResponse> getMetricTagCardinalityDetailsAsync(
970+
String metricName) {
971+
return getMetricTagCardinalityDetailsWithHttpInfoAsync(metricName)
972+
.thenApply(
973+
response -> {
974+
return response.getData();
975+
});
976+
}
977+
978+
/**
979+
* Returns the cardinality details of tags for a specific metric.
980+
*
981+
* @param metricName The name of the metric. (required)
982+
* @return ApiResponse&lt;MetricTagCardinalitiesResponse&gt;
983+
* @throws ApiException if fails to make API call
984+
* @http.response.details
985+
* <table border="1">
986+
* <caption>Response details</caption>
987+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
988+
* <tr><td> 200 </td><td> Success </td><td> - </td></tr>
989+
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
990+
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
991+
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
992+
* <tr><td> 429 </td><td> Too Many Requests </td><td> - </td></tr>
993+
* </table>
994+
*/
995+
public ApiResponse<MetricTagCardinalitiesResponse> getMetricTagCardinalityDetailsWithHttpInfo(
996+
String metricName) throws ApiException {
997+
Object localVarPostBody = null;
998+
999+
// verify the required parameter 'metricName' is set
1000+
if (metricName == null) {
1001+
throw new ApiException(
1002+
400,
1003+
"Missing the required parameter 'metricName' when calling"
1004+
+ " getMetricTagCardinalityDetails");
1005+
}
1006+
// create path and map variables
1007+
String localVarPath =
1008+
"/api/v2/metrics/{metric_name}/tag-cardinalities"
1009+
.replaceAll(
1010+
"\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString()));
1011+
1012+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
1013+
1014+
Invocation.Builder builder =
1015+
apiClient.createBuilder(
1016+
"v2.MetricsApi.getMetricTagCardinalityDetails",
1017+
localVarPath,
1018+
new ArrayList<Pair>(),
1019+
localVarHeaderParams,
1020+
new HashMap<String, String>(),
1021+
new String[] {"application/json"},
1022+
new String[] {"apiKeyAuth", "appKeyAuth"});
1023+
return apiClient.invokeAPI(
1024+
"GET",
1025+
builder,
1026+
localVarHeaderParams,
1027+
new String[] {},
1028+
localVarPostBody,
1029+
new HashMap<String, Object>(),
1030+
false,
1031+
new GenericType<MetricTagCardinalitiesResponse>() {});
1032+
}
1033+
1034+
/**
1035+
* Get tag key cardinality details.
1036+
*
1037+
* <p>See {@link #getMetricTagCardinalityDetailsWithHttpInfo}.
1038+
*
1039+
* @param metricName The name of the metric. (required)
1040+
* @return CompletableFuture&lt;ApiResponse&lt;MetricTagCardinalitiesResponse&gt;&gt;
1041+
*/
1042+
public CompletableFuture<ApiResponse<MetricTagCardinalitiesResponse>>
1043+
getMetricTagCardinalityDetailsWithHttpInfoAsync(String metricName) {
1044+
Object localVarPostBody = null;
1045+
1046+
// verify the required parameter 'metricName' is set
1047+
if (metricName == null) {
1048+
CompletableFuture<ApiResponse<MetricTagCardinalitiesResponse>> result =
1049+
new CompletableFuture<>();
1050+
result.completeExceptionally(
1051+
new ApiException(
1052+
400,
1053+
"Missing the required parameter 'metricName' when calling"
1054+
+ " getMetricTagCardinalityDetails"));
1055+
return result;
1056+
}
1057+
// create path and map variables
1058+
String localVarPath =
1059+
"/api/v2/metrics/{metric_name}/tag-cardinalities"
1060+
.replaceAll(
1061+
"\\{" + "metric_name" + "\\}", apiClient.escapeString(metricName.toString()));
1062+
1063+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
1064+
1065+
Invocation.Builder builder;
1066+
try {
1067+
builder =
1068+
apiClient.createBuilder(
1069+
"v2.MetricsApi.getMetricTagCardinalityDetails",
1070+
localVarPath,
1071+
new ArrayList<Pair>(),
1072+
localVarHeaderParams,
1073+
new HashMap<String, String>(),
1074+
new String[] {"application/json"},
1075+
new String[] {"apiKeyAuth", "appKeyAuth"});
1076+
} catch (ApiException ex) {
1077+
CompletableFuture<ApiResponse<MetricTagCardinalitiesResponse>> result =
1078+
new CompletableFuture<>();
1079+
result.completeExceptionally(ex);
1080+
return result;
1081+
}
1082+
return apiClient.invokeAPIAsync(
1083+
"GET",
1084+
builder,
1085+
localVarHeaderParams,
1086+
new String[] {},
1087+
localVarPostBody,
1088+
new HashMap<String, Object>(),
1089+
false,
1090+
new GenericType<MetricTagCardinalitiesResponse>() {});
1091+
}
1092+
9461093
/** Manage optional parameters to listActiveMetricConfigurations. */
9471094
public static class ListActiveMetricConfigurationsOptionalParameters {
9481095
private Long windowSeconds;

0 commit comments

Comments
 (0)