Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new field additional_query_filters to formula and function slo query #1555

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.5",
"regenerated": "2023-07-04 16:12:29.169633",
"spec_repo_commit": "dcb95a4a"
"regenerated": "2023-07-05 21:53:47.988269",
"spec_repo_commit": "aee1c6e4"
},
"v2": {
"apigentools_version": "1.6.5",
"regenerated": "2023-07-04 16:12:29.188201",
"spec_repo_commit": "dcb95a4a"
"regenerated": "2023-07-05 21:53:48.144607",
"spec_repo_commit": "aee1c6e4"
}
}
}
5 changes: 5 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2782,13 +2782,18 @@ components:
FormulaAndFunctionSLOQueryDefinition:
description: A formula and functions metrics query.
example:
additional_query_filters: '*'
data_source: slo
group_mode: overall
measure: good_events
name: my_slo
slo_id: '12345678910'
slo_query_type: metric
properties:
additional_query_filters:
description: Additional filters applied to the SLO query.
example: host:host_a,env:prod
type: string
data_source:
$ref: '#/components/schemas/FormulaAndFunctionSLODataSource'
group_mode:
Expand Down
1 change: 1 addition & 0 deletions examples/v1/dashboards/CreateDashboard_3562282606.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
measure=FormulaAndFunctionSLOMeasure.SLO_STATUS,
group_mode=FormulaAndFunctionSLOGroupMode.OVERALL,
slo_query_type=FormulaAndFunctionSLOQueryType.METRIC,
additional_query_filters="*",
),
],
response_format=FormulaAndFunctionResponseFormat.SCALAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def __init__(self, **kwargs):
:param stat: APM statistic.
:type stat: FormulaAndFunctionApmDependencyStatName

:param additional_query_filters: Additional filters applied to the SLO query.
:type additional_query_filters: str, optional

:param group_mode: Group mode to query measures.
:type group_mode: FormulaAndFunctionSLOGroupMode, optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def openapi_types(_):
from datadog_api_client.v1.model.formula_and_function_slo_query_type import FormulaAndFunctionSLOQueryType

return {
"additional_query_filters": (str,),
"data_source": (FormulaAndFunctionSLODataSource,),
"group_mode": (FormulaAndFunctionSLOGroupMode,),
"measure": (FormulaAndFunctionSLOMeasure,),
Expand All @@ -38,6 +39,7 @@ def openapi_types(_):
}

attribute_map = {
"additional_query_filters": "additional_query_filters",
"data_source": "data_source",
"group_mode": "group_mode",
"measure": "measure",
Expand All @@ -51,6 +53,7 @@ def __init__(
data_source: FormulaAndFunctionSLODataSource,
measure: FormulaAndFunctionSLOMeasure,
slo_id: str,
additional_query_filters: Union[str, UnsetType] = unset,
group_mode: Union[FormulaAndFunctionSLOGroupMode, UnsetType] = unset,
name: Union[str, UnsetType] = unset,
slo_query_type: Union[FormulaAndFunctionSLOQueryType, UnsetType] = unset,
Expand All @@ -59,6 +62,9 @@ def __init__(
"""
A formula and functions metrics query.

:param additional_query_filters: Additional filters applied to the SLO query.
:type additional_query_filters: str, optional

:param data_source: Data source for SLO measures queries.
:type data_source: FormulaAndFunctionSLODataSource

Expand All @@ -77,6 +83,8 @@ def __init__(
:param slo_query_type: Name of the query for use in formulas.
:type slo_query_type: FormulaAndFunctionSLOQueryType, optional
"""
if additional_query_filters is not unset:
kwargs["additional_query_filters"] = additional_query_filters
if group_mode is not unset:
kwargs["group_mode"] = group_mode
if name is not unset:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-05-16T22:06:53.853Z
2023-07-03T20:01:23.941Z
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interactions:
- request:
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"}'
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"}'
headers:
accept:
- application/json
Expand All @@ -10,7 +10,7 @@ interactions:
uri: https://api.datadoghq.com/api/v1/slo
response:
body:
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":"frog@datadoghq.com","email":"frog@datadoghq.com"},"created_at":1684274814,"modified_at":1684274814}],"error":null}
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":"frog@datadoghq.com","email":"frog@datadoghq.com"},"created_at":1688414484,"modified_at":1688414484}],"error":null}

'
headers:
Expand All @@ -20,7 +20,7 @@ interactions:
code: 200
message: OK
- request:
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}}]}'
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}}]}'
headers:
accept:
- application/json
Expand All @@ -30,7 +30,7 @@ interactions:
uri: https://api.datadoghq.com/api/v1/dashboard
response:
body:
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":"frog@datadoghq.com","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":[]}
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":"frog@datadoghq.com","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":[]}

'
headers:
Expand All @@ -45,10 +45,10 @@ interactions:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/dashboard/8kt-y74-2i3
uri: https://api.datadoghq.com/api/v1/dashboard/9u7-4vb-5ag
response:
body:
string: '{"deleted_dashboard_id":"8kt-y74-2i3"}
string: '{"deleted_dashboard_id":"9u7-4vb-5ag"}

'
headers:
Expand All @@ -63,10 +63,10 @@ interactions:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/slo/1c7cc520f98356d6b79adb1f8dbdef60
uri: https://api.datadoghq.com/api/v1/slo/1973fea2b6975337b3c26626e42c34e4
response:
body:
string: '{"data":["1c7cc520f98356d6b79adb1f8dbdef60"],"error":null}
string: '{"data":["1973fea2b6975337b3c26626e42c34e4"],"error":null}

'
headers:
Expand Down
3 changes: 2 additions & 1 deletion tests/v1/features/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Feature: Dashboards
Scenario: Create a new dashboard with a change widget using formulas and functions slo query
Given there is a valid "slo" in the system
And new "CreateDashboard" request
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" }
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" }
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.requests[0].response_format" is equal to "scalar"
Expand All @@ -99,6 +99,7 @@ Feature: Dashboards
And the response "widgets[0].definition.requests[0].queries[0].measure" is equal to "slo_status"
And the response "widgets[0].definition.requests[0].queries[0].slo_query_type" is equal to "metric"
And the response "widgets[0].definition.requests[0].queries[0].slo_id" has the same value as "slo.data[0].id"
And the response "widgets[0].definition.requests[0].queries[0].additional_query_filters" is equal to "*"
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "hour_before(query1)"
And the response "widgets[0].definition.requests[0].formulas[1].formula" is equal to "query1"

Expand Down