Skip to content

Commit 893c1d8

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

File tree

12 files changed

+662
-2
lines changed

12 files changed

+662
-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:50.343"
2+
"spec_repo_commit": "dc49df4",
3+
"generated": "2025-07-18 13:57:23.914"
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Get tag key cardinality details returns "Success" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V2::MetricsAPI.new
5+
p api_instance.get_metric_tag_cardinality_details("metric_name")

features/scenarios_model_mapping.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,9 @@
20552055
"filter_pct" => "Boolean",
20562056
"filter_timespan_h" => "Integer",
20572057
},
2058+
"v2.GetMetricTagCardinalityDetails" => {
2059+
"metric_name" => "String",
2060+
},
20582061
"v2.DeleteTagConfiguration" => {
20592062
"metric_name" => "String",
20602063
},

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

lib/datadog_api_client/inflector.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,10 @@ def overrides
23402340
"v2.metric_suggested_tags_and_aggregations" => "MetricSuggestedTagsAndAggregations",
23412341
"v2.metric_suggested_tags_and_aggregations_response" => "MetricSuggestedTagsAndAggregationsResponse",
23422342
"v2.metric_suggested_tags_attributes" => "MetricSuggestedTagsAttributes",
2343+
"v2.metric_tag_cardinalities_meta" => "MetricTagCardinalitiesMeta",
2344+
"v2.metric_tag_cardinalities_response" => "MetricTagCardinalitiesResponse",
2345+
"v2.metric_tag_cardinality" => "MetricTagCardinality",
2346+
"v2.metric_tag_cardinality_attributes" => "MetricTagCardinalityAttributes",
23432347
"v2.metric_tag_configuration" => "MetricTagConfiguration",
23442348
"v2.metric_tag_configuration_attributes" => "MetricTagConfigurationAttributes",
23452349
"v2.metric_tag_configuration_create_attributes" => "MetricTagConfigurationCreateAttributes",

lib/datadog_api_client/v2/api/metrics_api.rb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,71 @@ def estimate_metrics_output_series_with_http_info(metric_name, opts = {})
395395
return data, status_code, headers
396396
end
397397

398+
# Get tag key cardinality details.
399+
#
400+
# @see #get_metric_tag_cardinality_details_with_http_info
401+
def get_metric_tag_cardinality_details(metric_name, opts = {})
402+
data, _status_code, _headers = get_metric_tag_cardinality_details_with_http_info(metric_name, opts)
403+
data
404+
end
405+
406+
# Get tag key cardinality details.
407+
#
408+
# Returns the cardinality details of tags for a specific metric.
409+
#
410+
# @param metric_name [String] The name of the metric.
411+
# @param opts [Hash] the optional parameters
412+
# @return [Array<(MetricTagCardinalitiesResponse, Integer, Hash)>] MetricTagCardinalitiesResponse data, response status code and response headers
413+
def get_metric_tag_cardinality_details_with_http_info(metric_name, opts = {})
414+
415+
if @api_client.config.debugging
416+
@api_client.config.logger.debug 'Calling API: MetricsAPI.get_metric_tag_cardinality_details ...'
417+
end
418+
# verify the required parameter 'metric_name' is set
419+
if @api_client.config.client_side_validation && metric_name.nil?
420+
fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.get_metric_tag_cardinality_details"
421+
end
422+
# resource path
423+
local_var_path = '/api/v2/metrics/{metric_name}/tag-cardinalities'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/'))
424+
425+
# query parameters
426+
query_params = opts[:query_params] || {}
427+
428+
# header parameters
429+
header_params = opts[:header_params] || {}
430+
# HTTP header 'Accept' (if needed)
431+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
432+
433+
# form parameters
434+
form_params = opts[:form_params] || {}
435+
436+
# http body (model)
437+
post_body = opts[:debug_body]
438+
439+
# return_type
440+
return_type = opts[:debug_return_type] || 'MetricTagCardinalitiesResponse'
441+
442+
# auth_names
443+
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]
444+
445+
new_options = opts.merge(
446+
:operation => :get_metric_tag_cardinality_details,
447+
:header_params => header_params,
448+
:query_params => query_params,
449+
:form_params => form_params,
450+
:body => post_body,
451+
:auth_names => auth_names,
452+
:return_type => return_type,
453+
:api_version => "V2"
454+
)
455+
456+
data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
457+
if @api_client.config.debugging
458+
@api_client.config.logger.debug "API called: MetricsAPI#get_metric_tag_cardinality_details\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
459+
end
460+
return data, status_code, headers
461+
end
462+
398463
# List active tags and aggregations.
399464
#
400465
# @see #list_active_metric_configurations_with_http_info
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V2
20+
# Response metadata object.
21+
class MetricTagCardinalitiesMeta
22+
include BaseGenericModel
23+
24+
# The name of metric for which the tag cardinalities are returned.
25+
# This matches the metric name provided in the request.
26+
#
27+
attr_accessor :metric_name
28+
29+
attr_accessor :additional_properties
30+
31+
# Attribute mapping from ruby-style variable name to JSON key.
32+
# @!visibility private
33+
def self.attribute_map
34+
{
35+
:'metric_name' => :'metric_name'
36+
}
37+
end
38+
39+
# Attribute type mapping.
40+
# @!visibility private
41+
def self.openapi_types
42+
{
43+
:'metric_name' => :'String'
44+
}
45+
end
46+
47+
# Initializes the object
48+
# @param attributes [Hash] Model attributes in the form of hash
49+
# @!visibility private
50+
def initialize(attributes = {})
51+
if (!attributes.is_a?(Hash))
52+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MetricTagCardinalitiesMeta` initialize method"
53+
end
54+
55+
self.additional_properties = {}
56+
# check to see if the attribute exists and convert string to symbol for hash key
57+
attributes = attributes.each_with_object({}) { |(k, v), h|
58+
if (!self.class.attribute_map.key?(k.to_sym))
59+
self.additional_properties[k.to_sym] = v
60+
else
61+
h[k.to_sym] = v
62+
end
63+
}
64+
65+
if attributes.key?(:'metric_name')
66+
self.metric_name = attributes[:'metric_name']
67+
end
68+
end
69+
70+
# Returns the object in the form of hash, with additionalProperties support.
71+
# @return [Hash] Returns the object in the form of hash
72+
# @!visibility private
73+
def to_hash
74+
hash = {}
75+
self.class.attribute_map.each_pair do |attr, param|
76+
value = self.send(attr)
77+
if value.nil?
78+
is_nullable = self.class.openapi_nullable.include?(attr)
79+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
80+
end
81+
82+
hash[param] = _to_hash(value)
83+
end
84+
self.additional_properties.each_pair do |attr, value|
85+
hash[attr] = value
86+
end
87+
hash
88+
end
89+
90+
# Checks equality by comparing each attribute.
91+
# @param o [Object] Object to be compared
92+
# @!visibility private
93+
def ==(o)
94+
return true if self.equal?(o)
95+
self.class == o.class &&
96+
metric_name == o.metric_name &&
97+
additional_properties == o.additional_properties
98+
end
99+
100+
# Calculates hash code according to all attributes.
101+
# @return [Integer] Hash code
102+
# @!visibility private
103+
def hash
104+
[metric_name, additional_properties].hash
105+
end
106+
end
107+
end

0 commit comments

Comments
 (0)