Skip to content

Commit 031a42f

Browse files
api-clients-generation-pipeline[bot]jirikuncarci.datadog-api-spec
authored
Add tag filter options for /api/v{1,2}/metrics (#340)
* cassettes * Regenerate client from commit 20f68cb of spec repo Co-authored-by: Jiri Kuncar <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent fe7b605 commit 031a42f

10 files changed

+120
-6
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.4.1.dev6",
7-
"regenerated": "2021-03-24 08:45:09.299583",
8-
"spec_repo_commit": "075d167"
7+
"regenerated": "2021-03-25 11:07:51.194255",
8+
"spec_repo_commit": "20f68cb"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev6",
12-
"regenerated": "2021-03-24 08:45:48.710930",
13-
"spec_repo_commit": "075d167"
12+
"regenerated": "2021-03-25 11:08:34.265135",
13+
"spec_repo_commit": "20f68cb"
1414
}
1515
}
1616
}

docs/v1/MetricsApi.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ with ApiClient(configuration) as api_client:
124124
api_instance = metrics_api.MetricsApi(api_client)
125125
_from = 1 # int | Seconds since the Unix epoch.
126126
host = "host_example" # str | Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag. (optional)
127+
tag_filter = "env IN (staging,test) AND service:web" # str | Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. (optional)
127128

128129
# example passing only required values which don't have defaults set
129130
try:
@@ -137,7 +138,7 @@ with ApiClient(configuration) as api_client:
137138
# and optional values
138139
try:
139140
# Get active metrics list
140-
api_response = api_instance.list_active_metrics(_from, host=host)
141+
api_response = api_instance.list_active_metrics(_from, host=host, tag_filter=tag_filter)
141142
pprint(api_response)
142143
except ApiException as e:
143144
print("Exception when calling MetricsApi->list_active_metrics: %s\n" % e)
@@ -150,6 +151,7 @@ Name | Type | Description | Notes
150151
------------- | ------------- | ------------- | -------------
151152
**_from** | **int**| Seconds since the Unix epoch. |
152153
**host** | **str**| Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag. | [optional]
154+
**tag_filter** | **str**| Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. | [optional]
153155

154156
### Return type
155157

docs/v2/MetricsApi.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,14 @@ with ApiClient(configuration) as api_client:
299299
filter_tags_configured = "app" # str | Filter tag configurations by configured tags. (optional)
300300
filter_metric_type = MetricTagConfigurationMetricTypes("count") # MetricTagConfigurationMetricTypes | Filter tag configurations by metric type. (optional)
301301
filter_include_percentiles = True # bool | Filter distributions with additional percentile aggregations enabled or disabled. (optional)
302+
filter_tags = "env IN (staging,test) AND service:web" # str | Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. (optional)
303+
window_seconds = 3600 # int | The number of seconds of look back (from now) to apply to a filter[tag] query. Defaults value is 3600 (1 hour), maximum value is 172,800 (2 days). (optional)
302304

303305
# example passing only required values which don't have defaults set
304306
# and optional values
305307
try:
306308
# List tag configurations
307-
api_response = api_instance.list_tag_configurations(filter_configured=filter_configured, filter_tags_configured=filter_tags_configured, filter_metric_type=filter_metric_type, filter_include_percentiles=filter_include_percentiles)
309+
api_response = api_instance.list_tag_configurations(filter_configured=filter_configured, filter_tags_configured=filter_tags_configured, filter_metric_type=filter_metric_type, filter_include_percentiles=filter_include_percentiles, filter_tags=filter_tags, window_seconds=window_seconds)
308310
pprint(api_response)
309311
except ApiException as e:
310312
print("Exception when calling MetricsApi->list_tag_configurations: %s\n" % e)
@@ -319,6 +321,8 @@ Name | Type | Description | Notes
319321
**filter_tags_configured** | **str**| Filter tag configurations by configured tags. | [optional]
320322
**filter_metric_type** | **MetricTagConfigurationMetricTypes**| Filter tag configurations by metric type. | [optional]
321323
**filter_include_percentiles** | **bool**| Filter distributions with additional percentile aggregations enabled or disabled. | [optional]
324+
**filter_tags** | **str**| Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. | [optional]
325+
**window_seconds** | **int**| The number of seconds of look back (from now) to apply to a filter[tag] query. Defaults value is 3600 (1 hour), maximum value is 172,800 (2 days). | [optional]
322326

323327
### Return type
324328

src/datadog_api_client/v1/api/metrics_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def __list_active_metrics(self, _from, **kwargs):
141141
142142
Keyword Args:
143143
host (str): Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag.. [optional]
144+
tag_filter (str): Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters.. [optional]
144145
_return_http_data_only (bool): response data without head status
145146
code and headers. Default is True.
146147
_preload_content (bool): if False, the urllib3.HTTPResponse object
@@ -189,6 +190,7 @@ def __list_active_metrics(self, _from, **kwargs):
189190
"all": [
190191
"_from",
191192
"host",
193+
"tag_filter",
192194
],
193195
"required": [
194196
"_from",
@@ -203,14 +205,17 @@ def __list_active_metrics(self, _from, **kwargs):
203205
"openapi_types": {
204206
"_from": (int,),
205207
"host": (str,),
208+
"tag_filter": (str,),
206209
},
207210
"attribute_map": {
208211
"_from": "from",
209212
"host": "host",
213+
"tag_filter": "tag_filter",
210214
},
211215
"location_map": {
212216
"_from": "query",
213217
"host": "query",
218+
"tag_filter": "query",
214219
},
215220
"collection_format_map": {},
216221
},

src/datadog_api_client/v1/openapi.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14505,6 +14505,16 @@ paths:
1450514505
required: false
1450614506
schema:
1450714507
type: string
14508+
- description: 'Filter metrics that have been submitted with the given tags.
14509+
Supports boolean and wildcard expressions.
14510+
14511+
Cannot be combined with other filters.'
14512+
example: env IN (staging,test) AND service:web
14513+
in: query
14514+
name: tag_filter
14515+
required: false
14516+
schema:
14517+
type: string
1450814518
responses:
1450914519
'200':
1451014520
content:

src/datadog_api_client/v2/api/metrics_api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ def __list_tag_configurations(self, **kwargs):
332332
filter_tags_configured (str): Filter tag configurations by configured tags.. [optional]
333333
filter_metric_type (MetricTagConfigurationMetricTypes): Filter tag configurations by metric type.. [optional]
334334
filter_include_percentiles (bool): Filter distributions with additional percentile aggregations enabled or disabled.. [optional]
335+
filter_tags (str): Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters.. [optional]
336+
window_seconds (int): The number of seconds of look back (from now) to apply to a filter[tag] query. Defaults value is 3600 (1 hour), maximum value is 172,800 (2 days).. [optional]
335337
_return_http_data_only (bool): response data without head status
336338
code and headers. Default is True.
337339
_preload_content (bool): if False, the urllib3.HTTPResponse object
@@ -381,6 +383,8 @@ def __list_tag_configurations(self, **kwargs):
381383
"filter_tags_configured",
382384
"filter_metric_type",
383385
"filter_include_percentiles",
386+
"filter_tags",
387+
"window_seconds",
384388
],
385389
"required": [],
386390
"nullable": [],
@@ -395,18 +399,24 @@ def __list_tag_configurations(self, **kwargs):
395399
"filter_tags_configured": (str,),
396400
"filter_metric_type": (MetricTagConfigurationMetricTypes,),
397401
"filter_include_percentiles": (bool,),
402+
"filter_tags": (str,),
403+
"window_seconds": (int,),
398404
},
399405
"attribute_map": {
400406
"filter_configured": "filter[configured]",
401407
"filter_tags_configured": "filter[tags_configured]",
402408
"filter_metric_type": "filter[metric_type]",
403409
"filter_include_percentiles": "filter[include_percentiles]",
410+
"filter_tags": "filter[tags]",
411+
"window_seconds": "window[seconds]",
404412
},
405413
"location_map": {
406414
"filter_configured": "query",
407415
"filter_tags_configured": "query",
408416
"filter_metric_type": "query",
409417
"filter_include_percentiles": "query",
418+
"filter_tags": "query",
419+
"window_seconds": "query",
410420
},
411421
"collection_format_map": {},
412422
},

src/datadog_api_client/v2/openapi.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6328,6 +6328,27 @@ paths:
63286328
required: false
63296329
schema:
63306330
type: boolean
6331+
- description: 'Filter metrics that have been submitted with the given tags.
6332+
Supports boolean and wildcard expressions.
6333+
6334+
Cannot be combined with other filters.'
6335+
example: env IN (staging,test) AND service:web
6336+
in: query
6337+
name: filter[tags]
6338+
required: false
6339+
schema:
6340+
type: string
6341+
- description: 'The number of seconds of look back (from now) to apply to a
6342+
filter[tag] query.
6343+
6344+
Defaults value is 3600 (1 hour), maximum value is 172,800 (2 days).'
6345+
example: 3600
6346+
in: query
6347+
name: window[seconds]
6348+
required: false
6349+
schema:
6350+
format: int64
6351+
type: integer
63316352
responses:
63326353
'200':
63336354
content:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2021-03-24T16:45:31.438729+00:00
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Content-Type:
8+
- application/json
9+
Dd-Operation-Id:
10+
- ListTagConfigurations
11+
User-Agent:
12+
- datadog-api-client-python/0.1.dev273 (python 3.9.2; os Linux; arch x86_64)
13+
method: GET
14+
uri: https://api.datadoghq.com/api/v2/metrics?filter%5Btags%5D=datadogapiclientpythontestlisttagconfigurationswithatagfilterreturnssuccessresponse1616604331438729
15+
response:
16+
body:
17+
string: '{"data":[]}'
18+
headers:
19+
Connection:
20+
- keep-alive
21+
Content-Length:
22+
- '11'
23+
Content-Type:
24+
- application/json
25+
Date:
26+
- Wed, 24 Mar 2021 16:45:31 GMT
27+
cache-control:
28+
- no-cache
29+
content-security-policy:
30+
- frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report
31+
pragma:
32+
- no-cache
33+
strict-transport-security:
34+
- max-age=15724800;
35+
x-content-type-options:
36+
- nosniff
37+
x-dd-debug:
38+
- twvpGlmuom5y6A0pjGtXzTf554cmwJgTcCZ71fK4H/RDi+v5ehBK0zQiRcTJQG5C
39+
x-dd-version:
40+
- '35.4165979'
41+
x-frame-options:
42+
- SAMEORIGIN
43+
x-ratelimit-limit:
44+
- '50'
45+
x-ratelimit-period:
46+
- '60'
47+
x-ratelimit-remaining:
48+
- '49'
49+
x-ratelimit-reset:
50+
- '29'
51+
status:
52+
code: 200
53+
message: OK
54+
version: 1

tests/v2/features/metrics.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ Feature: Metrics
154154
When the request is sent
155155
Then the response status is 429 Too Many Requests
156156

157+
Scenario: List tag configurations with a tag filter returns "Success" response
158+
Given operation "ListTagConfigurations" enabled
159+
And new "ListTagConfigurations" request
160+
And request contains "filter[tags]" parameter with value "{{ unique_alnum }}"
161+
When the request is sent
162+
Then the response status is 200 Success
163+
157164
@generated @skip
158165
Scenario: List tags by metric name returns "Bad Request" response
159166
Given operation "ListTagsByMetricName" enabled

0 commit comments

Comments
 (0)