Skip to content

Commit 79321bb

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Get Tag Cardinalities Endpoint Spec (#2409)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent bf58238 commit 79321bb

File tree

13 files changed

+539
-2
lines changed

13 files changed

+539
-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:23:57.186"
2+
"spec_repo_commit": "dc49df4",
3+
"generated": "2025-07-18 13:58:29.146"
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Get tag key cardinality details returns "Success" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.MetricsApi(configuration);
9+
10+
const params: v2.MetricsApiGetMetricTagCardinalityDetailsRequest = {
11+
metricName: "metric_name",
12+
};
13+
14+
apiInstance
15+
.getMetricTagCardinalityDetails(params)
16+
.then((data: v2.MetricTagCardinalitiesResponse) => {
17+
console.log(
18+
"API called successfully. Returned data: " + JSON.stringify(data)
19+
);
20+
})
21+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
58565856
},
58575857
"operationResponseType": "MetricEstimateResponse",
58585858
},
5859+
"v2.GetMetricTagCardinalityDetails": {
5860+
"metricName": {
5861+
"type": "string",
5862+
"format": "",
5863+
},
5864+
"operationResponseType": "MetricTagCardinalitiesResponse",
5865+
},
58595866
"v2.DeleteTagConfiguration": {
58605867
"metricName": {
58615868
"type": "string",

features/v2/metrics.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,30 @@ Feature: Metrics
152152
Then the response status is 200 Success
153153
And the response "data[0].type" is equal to "manage_tags"
154154

155+
@generated @skip @team:DataDog/metrics-experience
156+
Scenario: Get tag key cardinality details returns "Bad Request" response
157+
Given a valid "appKeyAuth" key in the system
158+
And new "GetMetricTagCardinalityDetails" request
159+
And request contains "metric_name" parameter from "REPLACE.ME"
160+
When the request is sent
161+
Then the response status is 400 Bad Request
162+
163+
@generated @skip @team:DataDog/metrics-experience
164+
Scenario: Get tag key cardinality details returns "Not Found" response
165+
Given a valid "appKeyAuth" key in the system
166+
And new "GetMetricTagCardinalityDetails" request
167+
And request contains "metric_name" parameter from "REPLACE.ME"
168+
When the request is sent
169+
Then the response status is 404 Not Found
170+
171+
@generated @skip @team:DataDog/metrics-experience
172+
Scenario: Get tag key cardinality details returns "Success" response
173+
Given a valid "appKeyAuth" key in the system
174+
And new "GetMetricTagCardinalityDetails" request
175+
And request contains "metric_name" parameter from "REPLACE.ME"
176+
When the request is sent
177+
Then the response status is 200 Success
178+
155179
@generated @skip @team:DataDog/metrics-experience
156180
Scenario: List active tags and aggregations returns "Bad Request" response
157181
Given a valid "appKeyAuth" key in the system

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,12 @@
18641864
"type": "safe"
18651865
}
18661866
},
1867+
"GetMetricTagCardinalityDetails": {
1868+
"tag": "Metrics",
1869+
"undo": {
1870+
"type": "safe"
1871+
}
1872+
},
18671873
"DeleteTagConfiguration": {
18681874
"tag": "Metrics",
18691875
"undo": {

packages/datadog-api-client-v2/apis/MetricsApi.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { MetricPayload } from "../models/MetricPayload";
2929
import { MetricsAndMetricTagConfigurations } from "../models/MetricsAndMetricTagConfigurations";
3030
import { MetricsAndMetricTagConfigurationsResponse } from "../models/MetricsAndMetricTagConfigurationsResponse";
3131
import { MetricSuggestedTagsAndAggregationsResponse } from "../models/MetricSuggestedTagsAndAggregationsResponse";
32+
import { MetricTagCardinalitiesResponse } from "../models/MetricTagCardinalitiesResponse";
3233
import { MetricTagConfigurationCreateRequest } from "../models/MetricTagConfigurationCreateRequest";
3334
import { MetricTagConfigurationMetricTypeCategory } from "../models/MetricTagConfigurationMetricTypeCategory";
3435
import { MetricTagConfigurationResponse } from "../models/MetricTagConfigurationResponse";
@@ -284,6 +285,40 @@ export class MetricsApiRequestFactory extends BaseAPIRequestFactory {
284285
return requestContext;
285286
}
286287

288+
public async getMetricTagCardinalityDetails(
289+
metricName: string,
290+
_options?: Configuration
291+
): Promise<RequestContext> {
292+
const _config = _options || this.configuration;
293+
294+
// verify required parameter 'metricName' is not null or undefined
295+
if (metricName === null || metricName === undefined) {
296+
throw new RequiredError("metricName", "getMetricTagCardinalityDetails");
297+
}
298+
299+
// Path Params
300+
const localVarPath =
301+
"/api/v2/metrics/{metric_name}/tag-cardinalities".replace(
302+
"{metric_name}",
303+
encodeURIComponent(String(metricName))
304+
);
305+
306+
// Make Request Context
307+
const requestContext = _config
308+
.getServer("v2.MetricsApi.getMetricTagCardinalityDetails")
309+
.makeRequestContext(localVarPath, HttpMethod.GET);
310+
requestContext.setHeaderParam("Accept", "application/json");
311+
requestContext.setHttpConfig(_config.httpConfig);
312+
313+
// Apply auth methods
314+
applySecurityAuthentication(_config, requestContext, [
315+
"apiKeyAuth",
316+
"appKeyAuth",
317+
]);
318+
319+
return requestContext;
320+
}
321+
287322
public async listActiveMetricConfigurations(
288323
metricName: string,
289324
windowSeconds?: number,
@@ -1071,6 +1106,69 @@ export class MetricsApiResponseProcessor {
10711106
);
10721107
}
10731108

1109+
/**
1110+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
1111+
* to the expected objects
1112+
*
1113+
* @params response Response returned by the server for a request to getMetricTagCardinalityDetails
1114+
* @throws ApiException if the response code was not in [200, 299]
1115+
*/
1116+
public async getMetricTagCardinalityDetails(
1117+
response: ResponseContext
1118+
): Promise<MetricTagCardinalitiesResponse> {
1119+
const contentType = ObjectSerializer.normalizeMediaType(
1120+
response.headers["content-type"]
1121+
);
1122+
if (response.httpStatusCode === 200) {
1123+
const body: MetricTagCardinalitiesResponse = ObjectSerializer.deserialize(
1124+
ObjectSerializer.parse(await response.body.text(), contentType),
1125+
"MetricTagCardinalitiesResponse"
1126+
) as MetricTagCardinalitiesResponse;
1127+
return body;
1128+
}
1129+
if (
1130+
response.httpStatusCode === 400 ||
1131+
response.httpStatusCode === 403 ||
1132+
response.httpStatusCode === 404 ||
1133+
response.httpStatusCode === 429
1134+
) {
1135+
const bodyText = ObjectSerializer.parse(
1136+
await response.body.text(),
1137+
contentType
1138+
);
1139+
let body: APIErrorResponse;
1140+
try {
1141+
body = ObjectSerializer.deserialize(
1142+
bodyText,
1143+
"APIErrorResponse"
1144+
) as APIErrorResponse;
1145+
} catch (error) {
1146+
logger.debug(`Got error deserializing error: ${error}`);
1147+
throw new ApiException<APIErrorResponse>(
1148+
response.httpStatusCode,
1149+
bodyText
1150+
);
1151+
}
1152+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
1153+
}
1154+
1155+
// Work around for missing responses in specification, e.g. for petstore.yaml
1156+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
1157+
const body: MetricTagCardinalitiesResponse = ObjectSerializer.deserialize(
1158+
ObjectSerializer.parse(await response.body.text(), contentType),
1159+
"MetricTagCardinalitiesResponse",
1160+
""
1161+
) as MetricTagCardinalitiesResponse;
1162+
return body;
1163+
}
1164+
1165+
const body = (await response.body.text()) || "";
1166+
throw new ApiException<string>(
1167+
response.httpStatusCode,
1168+
'Unknown API Status Code!\nBody: "' + body + '"'
1169+
);
1170+
}
1171+
10741172
/**
10751173
* Unwraps the actual response sent by the server from the response context and deserializes the response content
10761174
* to the expected objects
@@ -1772,6 +1870,14 @@ export interface MetricsApiEstimateMetricsOutputSeriesRequest {
17721870
filterTimespanH?: number;
17731871
}
17741872

1873+
export interface MetricsApiGetMetricTagCardinalityDetailsRequest {
1874+
/**
1875+
* The name of the metric.
1876+
* @type string
1877+
*/
1878+
metricName: string;
1879+
}
1880+
17751881
export interface MetricsApiListActiveMetricConfigurationsRequest {
17761882
/**
17771883
* The name of the metric.
@@ -2066,6 +2172,30 @@ export class MetricsApi {
20662172
});
20672173
}
20682174

2175+
/**
2176+
* Returns the cardinality details of tags for a specific metric.
2177+
* @param param The request object
2178+
*/
2179+
public getMetricTagCardinalityDetails(
2180+
param: MetricsApiGetMetricTagCardinalityDetailsRequest,
2181+
options?: Configuration
2182+
): Promise<MetricTagCardinalitiesResponse> {
2183+
const requestContextPromise =
2184+
this.requestFactory.getMetricTagCardinalityDetails(
2185+
param.metricName,
2186+
options
2187+
);
2188+
return requestContextPromise.then((requestContext) => {
2189+
return this.configuration.httpApi
2190+
.send(requestContext)
2191+
.then((responseContext) => {
2192+
return this.responseProcessor.getMetricTagCardinalityDetails(
2193+
responseContext
2194+
);
2195+
});
2196+
});
2197+
}
2198+
20692199
/**
20702200
* List tags and aggregations that are actively queried on dashboards, notebooks, monitors, the Metrics Explorer, and using the API for a given metric name.
20712201
* @param param The request object

packages/datadog-api-client-v2/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ export {
385385
MetricsApiDeleteBulkTagsMetricsConfigurationRequest,
386386
MetricsApiDeleteTagConfigurationRequest,
387387
MetricsApiEstimateMetricsOutputSeriesRequest,
388+
MetricsApiGetMetricTagCardinalityDetailsRequest,
388389
MetricsApiListActiveMetricConfigurationsRequest,
389390
MetricsApiListMetricAssetsRequest,
390391
MetricsApiListTagConfigurationByNameRequest,
@@ -2164,6 +2165,10 @@ export { MetricsTimeseriesQuery } from "./models/MetricsTimeseriesQuery";
21642165
export { MetricSuggestedTagsAndAggregations } from "./models/MetricSuggestedTagsAndAggregations";
21652166
export { MetricSuggestedTagsAndAggregationsResponse } from "./models/MetricSuggestedTagsAndAggregationsResponse";
21662167
export { MetricSuggestedTagsAttributes } from "./models/MetricSuggestedTagsAttributes";
2168+
export { MetricTagCardinalitiesMeta } from "./models/MetricTagCardinalitiesMeta";
2169+
export { MetricTagCardinalitiesResponse } from "./models/MetricTagCardinalitiesResponse";
2170+
export { MetricTagCardinality } from "./models/MetricTagCardinality";
2171+
export { MetricTagCardinalityAttributes } from "./models/MetricTagCardinalityAttributes";
21672172
export { MetricTagConfiguration } from "./models/MetricTagConfiguration";
21682173
export { MetricTagConfigurationAttributes } from "./models/MetricTagConfigurationAttributes";
21692174
export { MetricTagConfigurationCreateAttributes } from "./models/MetricTagConfigurationCreateAttributes";

0 commit comments

Comments
 (0)