Skip to content

Commit 5da39b3

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Get Tag Cardinalities Endpoint Spec (#3169)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 90fd638 commit 5da39b3

11 files changed

Lines changed: 776 additions & 2 deletions

.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:19.812"
2+
"spec_repo_commit": "dc49df4",
3+
"generated": "2025-07-18 13:58:52.566"
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

api/datadogV2/api_metrics.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,84 @@ func (a *MetricsApi) EstimateMetricsOutputSeries(ctx _context.Context, metricNam
484484
return localVarReturnValue, localVarHTTPResponse, nil
485485
}
486486

487+
// GetMetricTagCardinalityDetails Get tag key cardinality details.
488+
// Returns the cardinality details of tags for a specific metric.
489+
func (a *MetricsApi) GetMetricTagCardinalityDetails(ctx _context.Context, metricName string) (MetricTagCardinalitiesResponse, *_nethttp.Response, error) {
490+
var (
491+
localVarHTTPMethod = _nethttp.MethodGet
492+
localVarPostBody interface{}
493+
localVarReturnValue MetricTagCardinalitiesResponse
494+
)
495+
496+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.MetricsApi.GetMetricTagCardinalityDetails")
497+
if err != nil {
498+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
499+
}
500+
501+
localVarPath := localBasePath + "/api/v2/metrics/{metric_name}/tag-cardinalities"
502+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{metric_name}", _neturl.PathEscape(datadog.ParameterToString(metricName, "")))
503+
504+
localVarHeaderParams := make(map[string]string)
505+
localVarQueryParams := _neturl.Values{}
506+
localVarFormParams := _neturl.Values{}
507+
localVarHeaderParams["Accept"] = "application/json"
508+
509+
if a.Client.Cfg.DelegatedTokenConfig != nil {
510+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
511+
if err != nil {
512+
return localVarReturnValue, nil, err
513+
}
514+
} else {
515+
datadog.SetAuthKeys(
516+
ctx,
517+
&localVarHeaderParams,
518+
[2]string{"apiKeyAuth", "DD-API-KEY"},
519+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
520+
)
521+
}
522+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
523+
if err != nil {
524+
return localVarReturnValue, nil, err
525+
}
526+
527+
localVarHTTPResponse, err := a.Client.CallAPI(req)
528+
if err != nil || localVarHTTPResponse == nil {
529+
return localVarReturnValue, localVarHTTPResponse, err
530+
}
531+
532+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
533+
if err != nil {
534+
return localVarReturnValue, localVarHTTPResponse, err
535+
}
536+
537+
if localVarHTTPResponse.StatusCode >= 300 {
538+
newErr := datadog.GenericOpenAPIError{
539+
ErrorBody: localVarBody,
540+
ErrorMessage: localVarHTTPResponse.Status,
541+
}
542+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 {
543+
var v APIErrorResponse
544+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
545+
if err != nil {
546+
return localVarReturnValue, localVarHTTPResponse, newErr
547+
}
548+
newErr.ErrorModel = v
549+
}
550+
return localVarReturnValue, localVarHTTPResponse, newErr
551+
}
552+
553+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
554+
if err != nil {
555+
newErr := datadog.GenericOpenAPIError{
556+
ErrorBody: localVarBody,
557+
ErrorMessage: err.Error(),
558+
}
559+
return localVarReturnValue, localVarHTTPResponse, newErr
560+
}
561+
562+
return localVarReturnValue, localVarHTTPResponse, nil
563+
}
564+
487565
// ListActiveMetricConfigurationsOptionalParameters holds optional parameters for ListActiveMetricConfigurations.
488566
type ListActiveMetricConfigurationsOptionalParameters struct {
489567
WindowSeconds *int64

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
// - [MetricsApi.DeleteBulkTagsMetricsConfiguration]
268268
// - [MetricsApi.DeleteTagConfiguration]
269269
// - [MetricsApi.EstimateMetricsOutputSeries]
270+
// - [MetricsApi.GetMetricTagCardinalityDetails]
270271
// - [MetricsApi.ListActiveMetricConfigurations]
271272
// - [MetricsApi.ListMetricAssets]
272273
// - [MetricsApi.ListTagConfigurationByName]
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
5+
package datadogV2
6+
7+
import (
8+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
9+
)
10+
11+
// MetricTagCardinalitiesMeta Response metadata object.
12+
type MetricTagCardinalitiesMeta struct {
13+
// The name of metric for which the tag cardinalities are returned.
14+
// This matches the metric name provided in the request.
15+
//
16+
MetricName *string `json:"metric_name,omitempty"`
17+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
18+
UnparsedObject map[string]interface{} `json:"-"`
19+
AdditionalProperties map[string]interface{} `json:"-"`
20+
}
21+
22+
// NewMetricTagCardinalitiesMeta instantiates a new MetricTagCardinalitiesMeta object.
23+
// This constructor will assign default values to properties that have it defined,
24+
// and makes sure properties required by API are set, but the set of arguments
25+
// will change when the set of required properties is changed.
26+
func NewMetricTagCardinalitiesMeta() *MetricTagCardinalitiesMeta {
27+
this := MetricTagCardinalitiesMeta{}
28+
return &this
29+
}
30+
31+
// NewMetricTagCardinalitiesMetaWithDefaults instantiates a new MetricTagCardinalitiesMeta object.
32+
// This constructor will only assign default values to properties that have it defined,
33+
// but it doesn't guarantee that properties required by API are set.
34+
func NewMetricTagCardinalitiesMetaWithDefaults() *MetricTagCardinalitiesMeta {
35+
this := MetricTagCardinalitiesMeta{}
36+
return &this
37+
}
38+
39+
// GetMetricName returns the MetricName field value if set, zero value otherwise.
40+
func (o *MetricTagCardinalitiesMeta) GetMetricName() string {
41+
if o == nil || o.MetricName == nil {
42+
var ret string
43+
return ret
44+
}
45+
return *o.MetricName
46+
}
47+
48+
// GetMetricNameOk returns a tuple with the MetricName field value if set, nil otherwise
49+
// and a boolean to check if the value has been set.
50+
func (o *MetricTagCardinalitiesMeta) GetMetricNameOk() (*string, bool) {
51+
if o == nil || o.MetricName == nil {
52+
return nil, false
53+
}
54+
return o.MetricName, true
55+
}
56+
57+
// HasMetricName returns a boolean if a field has been set.
58+
func (o *MetricTagCardinalitiesMeta) HasMetricName() bool {
59+
return o != nil && o.MetricName != nil
60+
}
61+
62+
// SetMetricName gets a reference to the given string and assigns it to the MetricName field.
63+
func (o *MetricTagCardinalitiesMeta) SetMetricName(v string) {
64+
o.MetricName = &v
65+
}
66+
67+
// MarshalJSON serializes the struct using spec logic.
68+
func (o MetricTagCardinalitiesMeta) MarshalJSON() ([]byte, error) {
69+
toSerialize := map[string]interface{}{}
70+
if o.UnparsedObject != nil {
71+
return datadog.Marshal(o.UnparsedObject)
72+
}
73+
if o.MetricName != nil {
74+
toSerialize["metric_name"] = o.MetricName
75+
}
76+
77+
for key, value := range o.AdditionalProperties {
78+
toSerialize[key] = value
79+
}
80+
return datadog.Marshal(toSerialize)
81+
}
82+
83+
// UnmarshalJSON deserializes the given payload.
84+
func (o *MetricTagCardinalitiesMeta) UnmarshalJSON(bytes []byte) (err error) {
85+
all := struct {
86+
MetricName *string `json:"metric_name,omitempty"`
87+
}{}
88+
if err = datadog.Unmarshal(bytes, &all); err != nil {
89+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
90+
}
91+
additionalProperties := make(map[string]interface{})
92+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
93+
datadog.DeleteKeys(additionalProperties, &[]string{"metric_name"})
94+
} else {
95+
return err
96+
}
97+
o.MetricName = all.MetricName
98+
99+
if len(additionalProperties) > 0 {
100+
o.AdditionalProperties = additionalProperties
101+
}
102+
103+
return nil
104+
}

0 commit comments

Comments
 (0)