Skip to content

Commit f029d6f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add a new field additional_query_filters to formula and function slo query (#1555)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent fb5d15b commit f029d6f

8 files changed

+32
-14
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.6.5",
7-
"regenerated": "2023-07-04 16:12:29.169633",
8-
"spec_repo_commit": "dcb95a4a"
7+
"regenerated": "2023-07-05 21:53:47.988269",
8+
"spec_repo_commit": "aee1c6e4"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-07-04 16:12:29.188201",
13-
"spec_repo_commit": "dcb95a4a"
12+
"regenerated": "2023-07-05 21:53:48.144607",
13+
"spec_repo_commit": "aee1c6e4"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,13 +2782,18 @@ components:
27822782
FormulaAndFunctionSLOQueryDefinition:
27832783
description: A formula and functions metrics query.
27842784
example:
2785+
additional_query_filters: '*'
27852786
data_source: slo
27862787
group_mode: overall
27872788
measure: good_events
27882789
name: my_slo
27892790
slo_id: '12345678910'
27902791
slo_query_type: metric
27912792
properties:
2793+
additional_query_filters:
2794+
description: Additional filters applied to the SLO query.
2795+
example: host:host_a,env:prod
2796+
type: string
27922797
data_source:
27932798
$ref: '#/components/schemas/FormulaAndFunctionSLODataSource'
27942799
group_mode:

examples/v1/dashboards/CreateDashboard_3562282606.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
measure=FormulaAndFunctionSLOMeasure.SLO_STATUS,
5757
group_mode=FormulaAndFunctionSLOGroupMode.OVERALL,
5858
slo_query_type=FormulaAndFunctionSLOQueryType.METRIC,
59+
additional_query_filters="*",
5960
),
6061
],
6162
response_format=FormulaAndFunctionResponseFormat.SCALAR,

src/datadog_api_client/v1/model/formula_and_function_query_definition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def __init__(self, **kwargs):
8484
:param stat: APM statistic.
8585
:type stat: FormulaAndFunctionApmDependencyStatName
8686
87+
:param additional_query_filters: Additional filters applied to the SLO query.
88+
:type additional_query_filters: str, optional
89+
8790
:param group_mode: Group mode to query measures.
8891
:type group_mode: FormulaAndFunctionSLOGroupMode, optional
8992

src/datadog_api_client/v1/model/formula_and_function_slo_query_definition.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def openapi_types(_):
2929
from datadog_api_client.v1.model.formula_and_function_slo_query_type import FormulaAndFunctionSLOQueryType
3030

3131
return {
32+
"additional_query_filters": (str,),
3233
"data_source": (FormulaAndFunctionSLODataSource,),
3334
"group_mode": (FormulaAndFunctionSLOGroupMode,),
3435
"measure": (FormulaAndFunctionSLOMeasure,),
@@ -38,6 +39,7 @@ def openapi_types(_):
3839
}
3940

4041
attribute_map = {
42+
"additional_query_filters": "additional_query_filters",
4143
"data_source": "data_source",
4244
"group_mode": "group_mode",
4345
"measure": "measure",
@@ -51,6 +53,7 @@ def __init__(
5153
data_source: FormulaAndFunctionSLODataSource,
5254
measure: FormulaAndFunctionSLOMeasure,
5355
slo_id: str,
56+
additional_query_filters: Union[str, UnsetType] = unset,
5457
group_mode: Union[FormulaAndFunctionSLOGroupMode, UnsetType] = unset,
5558
name: Union[str, UnsetType] = unset,
5659
slo_query_type: Union[FormulaAndFunctionSLOQueryType, UnsetType] = unset,
@@ -59,6 +62,9 @@ def __init__(
5962
"""
6063
A formula and functions metrics query.
6164
65+
:param additional_query_filters: Additional filters applied to the SLO query.
66+
:type additional_query_filters: str, optional
67+
6268
:param data_source: Data source for SLO measures queries.
6369
:type data_source: FormulaAndFunctionSLODataSource
6470
@@ -77,6 +83,8 @@ def __init__(
7783
:param slo_query_type: Name of the query for use in formulas.
7884
:type slo_query_type: FormulaAndFunctionSLOQueryType, optional
7985
"""
86+
if additional_query_filters is not unset:
87+
kwargs["additional_query_filters"] = additional_query_filters
8088
if group_mode is not unset:
8189
kwargs["group_mode"] = group_mode
8290
if name is not unset:
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-05-16T22:06:53.853Z
1+
2023-07-03T20:01:23.941Z

tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"name":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1684274813","query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"thresholds":[{"target":95,"timeframe":"7d","warning":98}],"type":"metric"}'
3+
body: '{"name":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1688414483","query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"thresholds":[{"target":95,"timeframe":"7d","warning":98}],"type":"metric"}'
44
headers:
55
accept:
66
- application/json
@@ -10,7 +10,7 @@ interactions:
1010
uri: https://api.datadoghq.com/api/v1/slo
1111
response:
1212
body:
13-
string: '{"data":[{"id":"1c7cc520f98356d6b79adb1f8dbdef60","name":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1684274813","tags":[],"monitor_tags":[],"thresholds":[{"timeframe":"7d","target":95.0,"target_display":"95.","warning":98.0,"warning_display":"98."}],"type":"metric","type_id":1,"description":"","timeframe":"7d","warning_threshold":98,"target_threshold":95,"query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"},"created_at":1684274814,"modified_at":1684274814}],"error":null}
13+
string: '{"data":[{"id":"1973fea2b6975337b3c26626e42c34e4","name":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1688414483","tags":[],"monitor_tags":[],"thresholds":[{"timeframe":"7d","target":95.0,"target_display":"95.","warning":98.0,"warning_display":"98."}],"type":"metric","type_id":1,"description":"","timeframe":"7d","warning_threshold":98,"target_threshold":95,"query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"},"created_at":1688414484,"modified_at":1688414484}],"error":null}
1414
1515
'
1616
headers:
@@ -20,7 +20,7 @@ interactions:
2020
code: 200
2121
message: OK
2222
- request:
23-
body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1684274813","widgets":[{"definition":{"requests":[{"change_type":"absolute","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"asc","queries":[{"data_source":"slo","group_mode":"overall","measure":"slo_status","name":"query1","slo_id":"1c7cc520f98356d6b79adb1f8dbdef60","slo_query_type":"metric"}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":2,"width":4,"x":0,"y":0}}]}'
23+
body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1688414483","widgets":[{"definition":{"requests":[{"change_type":"absolute","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"asc","queries":[{"additional_query_filters":"*","data_source":"slo","group_mode":"overall","measure":"slo_status","name":"query1","slo_id":"1973fea2b6975337b3c26626e42c34e4","slo_query_type":"metric"}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":2,"width":4,"x":0,"y":0}}]}'
2424
headers:
2525
accept:
2626
- application/json
@@ -30,7 +30,7 @@ interactions:
3030
uri: https://api.datadoghq.com/api/v1/dashboard
3131
response:
3232
body:
33-
string: '{"id":"8kt-y74-2i3","title":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1684274813","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/8kt-y74-2i3/test-createanewdashboardwithachangewidgetusingformulasandfunctionssloquery-16842","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"change_type":"absolute","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"asc","queries":[{"data_source":"slo","group_mode":"overall","measure":"slo_status","name":"query1","slo_id":"1c7cc520f98356d6b79adb1f8dbdef60","slo_query_type":"metric"}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":2,"width":4,"x":0,"y":0},"id":8047848064178828}],"notify_list":null,"created_at":"2023-05-16T22:06:54.344881+00:00","modified_at":"2023-05-16T22:06:54.344881+00:00","restricted_roles":[]}
33+
string: '{"id":"9u7-4vb-5ag","title":"Test-Create_a_new_dashboard_with_a_change_widget_using_formulas_and_functions_slo_query-1688414483","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/9u7-4vb-5ag/test-createanewdashboardwithachangewidgetusingformulasandfunctionssloquery-16884","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"change_type":"absolute","formulas":[{"formula":"hour_before(query1)"},{"formula":"query1"}],"increase_good":true,"order_by":"change","order_dir":"asc","queries":[{"additional_query_filters":"*","data_source":"slo","group_mode":"overall","measure":"slo_status","name":"query1","slo_id":"1973fea2b6975337b3c26626e42c34e4","slo_query_type":"metric"}],"response_format":"scalar"}],"time":{},"title":"","title_align":"left","title_size":"16","type":"change"},"layout":{"height":2,"width":4,"x":0,"y":0},"id":6457792410139351}],"notify_list":null,"created_at":"2023-07-03T20:01:24.547325+00:00","modified_at":"2023-07-03T20:01:24.547325+00:00","restricted_roles":[]}
3434

3535
'
3636
headers:
@@ -45,10 +45,10 @@ interactions:
4545
accept:
4646
- application/json
4747
method: DELETE
48-
uri: https://api.datadoghq.com/api/v1/dashboard/8kt-y74-2i3
48+
uri: https://api.datadoghq.com/api/v1/dashboard/9u7-4vb-5ag
4949
response:
5050
body:
51-
string: '{"deleted_dashboard_id":"8kt-y74-2i3"}
51+
string: '{"deleted_dashboard_id":"9u7-4vb-5ag"}
5252

5353
'
5454
headers:
@@ -63,10 +63,10 @@ interactions:
6363
accept:
6464
- application/json
6565
method: DELETE
66-
uri: https://api.datadoghq.com/api/v1/slo/1c7cc520f98356d6b79adb1f8dbdef60
66+
uri: https://api.datadoghq.com/api/v1/slo/1973fea2b6975337b3c26626e42c34e4
6767
response:
6868
body:
69-
string: '{"data":["1c7cc520f98356d6b79adb1f8dbdef60"],"error":null}
69+
string: '{"data":["1973fea2b6975337b3c26626e42c34e4"],"error":null}
7070

7171
'
7272
headers:

tests/v1/features/dashboards.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Feature: Dashboards
8585
Scenario: Create a new dashboard with a change widget using formulas and functions slo query
8686
Given there is a valid "slo" in the system
8787
And new "CreateDashboard" request
88-
And body with value { "title": "{{ unique }}", "widgets": [ { "definition": {"title": "", "title_size": "16", "title_align": "left", "time": {}, "type": "change", "requests": [ {"formulas": [ { "formula": "hour_before(query1)" }, { "formula": "query1" } ], "queries": [ {"name": "query1", "data_source": "slo", "slo_id": "{{ slo.data[0].id }}", "measure": "slo_status", "group_mode": "overall", "slo_query_type": "metric" } ], "response_format": "scalar", "order_by": "change", "change_type": "absolute", "increase_good": true, "order_dir": "asc" } ] }, "layout": { "x":0, "y": 0, "width": 4, "height": 2 } } ], "layout_type": "ordered" }
88+
And body with value { "title": "{{ unique }}", "widgets": [ { "definition": {"title": "", "title_size": "16", "title_align": "left", "time": {}, "type": "change", "requests": [ {"formulas": [ { "formula": "hour_before(query1)" }, { "formula": "query1" } ], "queries": [ {"name": "query1", "data_source": "slo", "slo_id": "{{ slo.data[0].id }}", "measure": "slo_status", "group_mode": "overall", "slo_query_type": "metric", "additional_query_filters": "*" } ], "response_format": "scalar", "order_by": "change", "change_type": "absolute", "increase_good": true, "order_dir": "asc" } ] }, "layout": { "x":0, "y": 0, "width": 4, "height": 2 } } ], "layout_type": "ordered" }
8989
When the request is sent
9090
Then the response status is 200 OK
9191
And the response "widgets[0].definition.requests[0].response_format" is equal to "scalar"
@@ -99,6 +99,7 @@ Feature: Dashboards
9999
And the response "widgets[0].definition.requests[0].queries[0].measure" is equal to "slo_status"
100100
And the response "widgets[0].definition.requests[0].queries[0].slo_query_type" is equal to "metric"
101101
And the response "widgets[0].definition.requests[0].queries[0].slo_id" has the same value as "slo.data[0].id"
102+
And the response "widgets[0].definition.requests[0].queries[0].additional_query_filters" is equal to "*"
102103
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "hour_before(query1)"
103104
And the response "widgets[0].definition.requests[0].formulas[1].formula" is equal to "query1"
104105

0 commit comments

Comments
 (0)