Skip to content

Commit b1b4144

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

File tree

12 files changed

+414
-2
lines changed

12 files changed

+414
-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:04.096"
2+
"spec_repo_commit": "dc49df4",
3+
"generated": "2025-07-18 13:57:41.438"
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

docs/datadog_api_client.v2.model.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9881,6 +9881,34 @@ datadog\_api\_client.v2.model.metric\_suggested\_tags\_attributes module
98819881
:members:
98829882
:show-inheritance:
98839883

9884+
datadog\_api\_client.v2.model.metric\_tag\_cardinalities\_meta module
9885+
---------------------------------------------------------------------
9886+
9887+
.. automodule:: datadog_api_client.v2.model.metric_tag_cardinalities_meta
9888+
:members:
9889+
:show-inheritance:
9890+
9891+
datadog\_api\_client.v2.model.metric\_tag\_cardinalities\_response module
9892+
-------------------------------------------------------------------------
9893+
9894+
.. automodule:: datadog_api_client.v2.model.metric_tag_cardinalities_response
9895+
:members:
9896+
:show-inheritance:
9897+
9898+
datadog\_api\_client.v2.model.metric\_tag\_cardinality module
9899+
-------------------------------------------------------------
9900+
9901+
.. automodule:: datadog_api_client.v2.model.metric_tag_cardinality
9902+
:members:
9903+
:show-inheritance:
9904+
9905+
datadog\_api\_client.v2.model.metric\_tag\_cardinality\_attributes module
9906+
-------------------------------------------------------------------------
9907+
9908+
.. automodule:: datadog_api_client.v2.model.metric_tag_cardinality_attributes
9909+
:members:
9910+
:show-inheritance:
9911+
98849912
datadog\_api\_client.v2.model.metric\_tag\_configuration module
98859913
---------------------------------------------------------------
98869914

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Get tag key cardinality details returns "Success" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.metrics_api import MetricsApi
7+
8+
configuration = Configuration()
9+
with ApiClient(configuration) as api_client:
10+
api_instance = MetricsApi(api_client)
11+
response = api_instance.get_metric_tag_cardinality_details(
12+
metric_name="metric_name",
13+
)
14+
15+
print(response)

src/datadog_api_client/v2/api/metrics_api.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from datadog_api_client.v2.model.metric_all_tags_response import MetricAllTagsResponse
3131
from datadog_api_client.v2.model.metric_assets_response import MetricAssetsResponse
3232
from datadog_api_client.v2.model.metric_estimate_response import MetricEstimateResponse
33+
from datadog_api_client.v2.model.metric_tag_cardinalities_response import MetricTagCardinalitiesResponse
3334
from datadog_api_client.v2.model.metric_tag_configuration_response import MetricTagConfigurationResponse
3435
from datadog_api_client.v2.model.metric_tag_configuration_update_request import MetricTagConfigurationUpdateRequest
3536
from datadog_api_client.v2.model.metric_tag_configuration_create_request import MetricTagConfigurationCreateRequest
@@ -214,6 +215,29 @@ def __init__(self, api_client=None):
214215
api_client=api_client,
215216
)
216217

218+
self._get_metric_tag_cardinality_details_endpoint = _Endpoint(
219+
settings={
220+
"response_type": (MetricTagCardinalitiesResponse,),
221+
"auth": ["apiKeyAuth", "appKeyAuth"],
222+
"endpoint_path": "/api/v2/metrics/{metric_name}/tag-cardinalities",
223+
"operation_id": "get_metric_tag_cardinality_details",
224+
"http_method": "GET",
225+
"version": "v2",
226+
},
227+
params_map={
228+
"metric_name": {
229+
"required": True,
230+
"openapi_types": (str,),
231+
"attribute": "metric_name",
232+
"location": "path",
233+
},
234+
},
235+
headers_map={
236+
"accept": ["application/json"],
237+
},
238+
api_client=api_client,
239+
)
240+
217241
self._list_active_metric_configurations_endpoint = _Endpoint(
218242
settings={
219243
"response_type": (MetricSuggestedTagsAndAggregationsResponse,),
@@ -628,6 +652,23 @@ def estimate_metrics_output_series(
628652

629653
return self._estimate_metrics_output_series_endpoint.call_with_http_info(**kwargs)
630654

655+
def get_metric_tag_cardinality_details(
656+
self,
657+
metric_name: str,
658+
) -> MetricTagCardinalitiesResponse:
659+
"""Get tag key cardinality details.
660+
661+
Returns the cardinality details of tags for a specific metric.
662+
663+
:param metric_name: The name of the metric.
664+
:type metric_name: str
665+
:rtype: MetricTagCardinalitiesResponse
666+
"""
667+
kwargs: Dict[str, Any] = {}
668+
kwargs["metric_name"] = metric_name
669+
670+
return self._get_metric_tag_cardinality_details_endpoint.call_with_http_info(**kwargs)
671+
631672
def list_active_metric_configurations(
632673
self,
633674
metric_name: str,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
class MetricTagCardinalitiesMeta(ModelNormal):
17+
@cached_property
18+
def openapi_types(_):
19+
return {
20+
"metric_name": (str,),
21+
}
22+
23+
attribute_map = {
24+
"metric_name": "metric_name",
25+
}
26+
27+
def __init__(self_, metric_name: Union[str, UnsetType] = unset, **kwargs):
28+
"""
29+
Response metadata object.
30+
31+
:param metric_name: The name of metric for which the tag cardinalities are returned.
32+
This matches the metric name provided in the request.
33+
:type metric_name: str, optional
34+
"""
35+
if metric_name is not unset:
36+
kwargs["metric_name"] = metric_name
37+
super().__init__(kwargs)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import List, Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.metric_tag_cardinality import MetricTagCardinality
18+
from datadog_api_client.v2.model.metric_tag_cardinalities_meta import MetricTagCardinalitiesMeta
19+
20+
21+
class MetricTagCardinalitiesResponse(ModelNormal):
22+
@cached_property
23+
def openapi_types(_):
24+
from datadog_api_client.v2.model.metric_tag_cardinality import MetricTagCardinality
25+
from datadog_api_client.v2.model.metric_tag_cardinalities_meta import MetricTagCardinalitiesMeta
26+
27+
return {
28+
"data": ([MetricTagCardinality],),
29+
"meta": (MetricTagCardinalitiesMeta,),
30+
}
31+
32+
attribute_map = {
33+
"data": "data",
34+
"meta": "meta",
35+
}
36+
37+
def __init__(
38+
self_,
39+
data: Union[List[MetricTagCardinality], UnsetType] = unset,
40+
meta: Union[MetricTagCardinalitiesMeta, UnsetType] = unset,
41+
**kwargs,
42+
):
43+
"""
44+
Response object that includes an array of objects representing the cardinality details of a metric's tags.
45+
46+
:param data: A list of tag cardinalities associated with the given metric.
47+
:type data: [MetricTagCardinality], optional
48+
49+
:param meta: Response metadata object.
50+
:type meta: MetricTagCardinalitiesMeta, optional
51+
"""
52+
if data is not unset:
53+
kwargs["data"] = data
54+
if meta is not unset:
55+
kwargs["meta"] = meta
56+
super().__init__(kwargs)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.metric_tag_cardinality_attributes import MetricTagCardinalityAttributes
18+
19+
20+
class MetricTagCardinality(ModelNormal):
21+
@cached_property
22+
def openapi_types(_):
23+
from datadog_api_client.v2.model.metric_tag_cardinality_attributes import MetricTagCardinalityAttributes
24+
25+
return {
26+
"attributes": (MetricTagCardinalityAttributes,),
27+
"id": (str,),
28+
"type": (str,),
29+
}
30+
31+
attribute_map = {
32+
"attributes": "attributes",
33+
"id": "id",
34+
"type": "type",
35+
}
36+
37+
def __init__(
38+
self_,
39+
attributes: Union[MetricTagCardinalityAttributes, UnsetType] = unset,
40+
id: Union[str, UnsetType] = unset,
41+
type: Union[str, UnsetType] = unset,
42+
**kwargs,
43+
):
44+
"""
45+
Object containing metadata and attributes related to a specific tag key associated with the metric.
46+
47+
:param attributes: An object containing properties related to the tag key
48+
:type attributes: MetricTagCardinalityAttributes, optional
49+
50+
:param id: The name of the tag key.
51+
:type id: str, optional
52+
53+
:param type: This describes the endpoint action.
54+
:type type: str, optional
55+
"""
56+
if attributes is not unset:
57+
kwargs["attributes"] = attributes
58+
if id is not unset:
59+
kwargs["id"] = id
60+
if type is not unset:
61+
kwargs["type"] = type
62+
super().__init__(kwargs)

0 commit comments

Comments
 (0)