Skip to content

Commit d3db2dd

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

File tree

12 files changed

+497
-2
lines changed

12 files changed

+497
-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:22:42.241"
2+
"spec_repo_commit": "dc49df4",
3+
"generated": "2025-07-18 13:57:17.436"
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

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": {

private/bdd_runner/src/support/scenarios_model_mapping.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5866,6 +5866,13 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = {
58665866
},
58675867
operationResponseType: "MetricEstimateResponse",
58685868
},
5869+
"MetricsApi.V2.GetMetricTagCardinalityDetails": {
5870+
metricName: {
5871+
type: "string",
5872+
format: "",
5873+
},
5874+
operationResponseType: "MetricTagCardinalitiesResponse",
5875+
},
58695876
"MetricsApi.V2.ListTagConfigurationByName": {
58705877
metricName: {
58715878
type: "string",

services/metrics/src/v2/MetricsApi.ts

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { MetricPayload } from "./models/MetricPayload";
3535
import { MetricsAndMetricTagConfigurations } from "./models/MetricsAndMetricTagConfigurations";
3636
import { MetricsAndMetricTagConfigurationsResponse } from "./models/MetricsAndMetricTagConfigurationsResponse";
3737
import { MetricSuggestedTagsAndAggregationsResponse } from "./models/MetricSuggestedTagsAndAggregationsResponse";
38+
import { MetricTagCardinalitiesResponse } from "./models/MetricTagCardinalitiesResponse";
3839
import { MetricTagConfigurationCreateRequest } from "./models/MetricTagConfigurationCreateRequest";
3940
import { MetricTagConfigurationMetricTypeCategory } from "./models/MetricTagConfigurationMetricTypeCategory";
4041
import { MetricTagConfigurationResponse } from "./models/MetricTagConfigurationResponse";
@@ -344,6 +345,51 @@ export class MetricsApiRequestFactory extends BaseAPIRequestFactory {
344345
return requestContext;
345346
}
346347

348+
public async getMetricTagCardinalityDetails(
349+
metricName: string,
350+
_options?: Configuration,
351+
): Promise<RequestContext> {
352+
const _config = _options || this.configuration;
353+
354+
// verify required parameter 'metricName' is not null or undefined
355+
if (metricName === null || metricName === undefined) {
356+
throw new RequiredError("metricName", "getMetricTagCardinalityDetails");
357+
}
358+
359+
// Path Params
360+
const localVarPath =
361+
"/api/v2/metrics/{metric_name}/tag-cardinalities".replace(
362+
"{metric_name}",
363+
encodeURIComponent(String(metricName)),
364+
);
365+
366+
// Make Request Context
367+
const { server, overrides } = _config.getServerAndOverrides(
368+
"MetricsApi.v2.getMetricTagCardinalityDetails",
369+
MetricsApi.operationServers,
370+
);
371+
const requestContext = server.makeRequestContext(
372+
localVarPath,
373+
HttpMethod.GET,
374+
overrides,
375+
);
376+
requestContext.setHeaderParam("Accept", "application/json");
377+
requestContext.setHttpConfig(_config.httpConfig);
378+
379+
// Set User-Agent
380+
if (this.userAgent) {
381+
requestContext.setHeaderParam("User-Agent", this.userAgent);
382+
}
383+
384+
// Apply auth methods
385+
applySecurityAuthentication(_config, requestContext, [
386+
"apiKeyAuth",
387+
"appKeyAuth",
388+
]);
389+
390+
return requestContext;
391+
}
392+
347393
public async listActiveMetricConfigurations(
348394
metricName: string,
349395
windowSeconds?: number,
@@ -1213,6 +1259,67 @@ export class MetricsApiResponseProcessor {
12131259
);
12141260
}
12151261

1262+
/**
1263+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
1264+
* to the expected objects
1265+
*
1266+
* @params response Response returned by the server for a request to getMetricTagCardinalityDetails
1267+
* @throws ApiException if the response code was not in [200, 299]
1268+
*/
1269+
public async getMetricTagCardinalityDetails(
1270+
response: ResponseContext,
1271+
): Promise<MetricTagCardinalitiesResponse> {
1272+
const contentType = normalizeMediaType(response.headers["content-type"]);
1273+
if (response.httpStatusCode === 200) {
1274+
const body: MetricTagCardinalitiesResponse = deserialize(
1275+
parse(await response.body.text(), contentType),
1276+
TypingInfo,
1277+
"MetricTagCardinalitiesResponse",
1278+
) as MetricTagCardinalitiesResponse;
1279+
return body;
1280+
}
1281+
if (
1282+
response.httpStatusCode === 400 ||
1283+
response.httpStatusCode === 403 ||
1284+
response.httpStatusCode === 404 ||
1285+
response.httpStatusCode === 429
1286+
) {
1287+
const bodyText = parse(await response.body.text(), contentType);
1288+
let body: APIErrorResponse;
1289+
try {
1290+
body = deserialize(
1291+
bodyText,
1292+
TypingInfo,
1293+
"APIErrorResponse",
1294+
) as APIErrorResponse;
1295+
} catch (error) {
1296+
logger.debug(`Got error deserializing error: ${error}`);
1297+
throw new ApiException<APIErrorResponse>(
1298+
response.httpStatusCode,
1299+
bodyText,
1300+
);
1301+
}
1302+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
1303+
}
1304+
1305+
// Work around for missing responses in specification, e.g. for petstore.yaml
1306+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
1307+
const body: MetricTagCardinalitiesResponse = deserialize(
1308+
parse(await response.body.text(), contentType),
1309+
TypingInfo,
1310+
"MetricTagCardinalitiesResponse",
1311+
"",
1312+
) as MetricTagCardinalitiesResponse;
1313+
return body;
1314+
}
1315+
1316+
const body = (await response.body.text()) || "";
1317+
throw new ApiException<string>(
1318+
response.httpStatusCode,
1319+
'Unknown API Status Code!\nBody: "' + body + '"',
1320+
);
1321+
}
1322+
12161323
/**
12171324
* Unwraps the actual response sent by the server from the response context and deserializes the response content
12181325
* to the expected objects
@@ -1890,6 +1997,14 @@ export interface MetricsApiEstimateMetricsOutputSeriesRequest {
18901997
filterTimespanH?: number;
18911998
}
18921999

2000+
export interface MetricsApiGetMetricTagCardinalityDetailsRequest {
2001+
/**
2002+
* The name of the metric.
2003+
* @type string
2004+
*/
2005+
metricName: string;
2006+
}
2007+
18932008
export interface MetricsApiListActiveMetricConfigurationsRequest {
18942009
/**
18952010
* The name of the metric.
@@ -2186,6 +2301,30 @@ export class MetricsApi {
21862301
});
21872302
}
21882303

2304+
/**
2305+
* Returns the cardinality details of tags for a specific metric.
2306+
* @param param The request object
2307+
*/
2308+
public getMetricTagCardinalityDetails(
2309+
param: MetricsApiGetMetricTagCardinalityDetailsRequest,
2310+
options?: Configuration,
2311+
): Promise<MetricTagCardinalitiesResponse> {
2312+
const requestContextPromise =
2313+
this.requestFactory.getMetricTagCardinalityDetails(
2314+
param.metricName,
2315+
options,
2316+
);
2317+
return requestContextPromise.then((requestContext) => {
2318+
return this.configuration.httpApi
2319+
.send(requestContext)
2320+
.then((responseContext) => {
2321+
return this.responseProcessor.getMetricTagCardinalityDetails(
2322+
responseContext,
2323+
);
2324+
});
2325+
});
2326+
}
2327+
21892328
/**
21902329
* List tags and aggregations that are actively queried on dashboards, notebooks, monitors, the Metrics Explorer, and using the API for a given metric name.
21912330
* @param param The request object

services/metrics/src/v2/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export {
44
MetricsApiDeleteBulkTagsMetricsConfigurationRequest,
55
MetricsApiDeleteTagConfigurationRequest,
66
MetricsApiEstimateMetricsOutputSeriesRequest,
7+
MetricsApiGetMetricTagCardinalityDetailsRequest,
78
MetricsApiListActiveMetricConfigurationsRequest,
89
MetricsApiListMetricAssetsRequest,
910
MetricsApiListTagConfigurationByNameRequest,
@@ -103,6 +104,10 @@ export { MetricsTimeseriesQuery } from "./models/MetricsTimeseriesQuery";
103104
export { MetricSuggestedTagsAndAggregations } from "./models/MetricSuggestedTagsAndAggregations";
104105
export { MetricSuggestedTagsAndAggregationsResponse } from "./models/MetricSuggestedTagsAndAggregationsResponse";
105106
export { MetricSuggestedTagsAttributes } from "./models/MetricSuggestedTagsAttributes";
107+
export { MetricTagCardinalitiesMeta } from "./models/MetricTagCardinalitiesMeta";
108+
export { MetricTagCardinalitiesResponse } from "./models/MetricTagCardinalitiesResponse";
109+
export { MetricTagCardinality } from "./models/MetricTagCardinality";
110+
export { MetricTagCardinalityAttributes } from "./models/MetricTagCardinalityAttributes";
106111
export { MetricTagConfiguration } from "./models/MetricTagConfiguration";
107112
export { MetricTagConfigurationAttributes } from "./models/MetricTagConfigurationAttributes";
108113
export { MetricTagConfigurationCreateAttributes } from "./models/MetricTagConfigurationCreateAttributes";

0 commit comments

Comments
 (0)