Skip to content

Commit cda0198

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Add formula and function slo query to dash widgets (#1466)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent d42c7df commit cda0198

23 files changed

+605
-4
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.4",
7-
"regenerated": "2023-05-17 14:44:49.208852",
8-
"spec_repo_commit": "f8bfb8c1"
7+
"regenerated": "2023-05-17 20:57:57.889792",
8+
"spec_repo_commit": "d8186149"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-05-17 14:44:49.255286",
13-
"spec_repo_commit": "f8bfb8c1"
12+
"regenerated": "2023-05-17 20:57:57.901737",
13+
"spec_repo_commit": "d8186149"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,7 @@ components:
27282728
- $ref: '#/components/schemas/FormulaAndFunctionProcessQueryDefinition'
27292729
- $ref: '#/components/schemas/FormulaAndFunctionApmDependencyStatsQueryDefinition'
27302730
- $ref: '#/components/schemas/FormulaAndFunctionApmResourceStatsQueryDefinition'
2731+
- $ref: '#/components/schemas/FormulaAndFunctionSLOQueryDefinition'
27312732
type: object
27322733
FormulaAndFunctionResponseFormat:
27332734
description: Timeseries or Scalar response.
@@ -2739,6 +2740,81 @@ components:
27392740
x-enum-varnames:
27402741
- TIMESERIES
27412742
- SCALAR
2743+
FormulaAndFunctionSLODataSource:
2744+
description: Data source for SLO measures queries.
2745+
enum:
2746+
- slo
2747+
example: slo
2748+
type: string
2749+
x-enum-varnames:
2750+
- SLO
2751+
FormulaAndFunctionSLOGroupMode:
2752+
description: Group mode to query measures.
2753+
enum:
2754+
- overall
2755+
- components
2756+
example: overall
2757+
type: string
2758+
x-enum-varnames:
2759+
- OVERALL
2760+
- COMPONENTS
2761+
FormulaAndFunctionSLOMeasure:
2762+
description: SLO measures queries.
2763+
enum:
2764+
- good_events
2765+
- bad_events
2766+
- slo_status
2767+
- error_budget_remaining
2768+
- burn_rate
2769+
- error_budget_burndown
2770+
example: slo_status
2771+
type: string
2772+
x-enum-varnames:
2773+
- GOOD_EVENTS
2774+
- BAD_EVENTS
2775+
- SLO_STATUS
2776+
- ERROR_BUDGET_REMAINING
2777+
- BURN_RATE
2778+
- ERROR_BUDGET_BURNDOWN
2779+
FormulaAndFunctionSLOQueryDefinition:
2780+
description: A formula and functions metrics query.
2781+
example:
2782+
data_source: slo
2783+
group_mode: overall
2784+
measure: good_events
2785+
name: my_slo
2786+
slo_id: '12345678910'
2787+
slo_query_type: metric
2788+
properties:
2789+
data_source:
2790+
$ref: '#/components/schemas/FormulaAndFunctionSLODataSource'
2791+
group_mode:
2792+
$ref: '#/components/schemas/FormulaAndFunctionSLOGroupMode'
2793+
measure:
2794+
$ref: '#/components/schemas/FormulaAndFunctionSLOMeasure'
2795+
name:
2796+
description: Name of the query for use in formulas.
2797+
example: my_slo
2798+
type: string
2799+
slo_id:
2800+
description: ID of an SLO to query measures.
2801+
example: '12345678910'
2802+
type: string
2803+
slo_query_type:
2804+
$ref: '#/components/schemas/FormulaAndFunctionSLOQueryType'
2805+
required:
2806+
- data_source
2807+
- slo_id
2808+
- measure
2809+
type: object
2810+
FormulaAndFunctionSLOQueryType:
2811+
description: Name of the query for use in formulas.
2812+
enum:
2813+
- metric
2814+
example: metric
2815+
type: string
2816+
x-enum-varnames:
2817+
- METRIC
27422818
FreeTextWidgetDefinition:
27432819
description: Free text is a widget that allows you to add headings to your screenboard.
27442820
Commonly used to state the overall purpose of the dashboard. Only available

docs/datadog_api_client.v1.model.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,41 @@ formula\_and\_function\_response\_format
813813
:members:
814814
:show-inheritance:
815815

816+
formula\_and\_function\_slo\_data\_source
817+
-----------------------------------------
818+
819+
.. automodule:: datadog_api_client.v1.model.formula_and_function_slo_data_source
820+
:members:
821+
:show-inheritance:
822+
823+
formula\_and\_function\_slo\_group\_mode
824+
----------------------------------------
825+
826+
.. automodule:: datadog_api_client.v1.model.formula_and_function_slo_group_mode
827+
:members:
828+
:show-inheritance:
829+
830+
formula\_and\_function\_slo\_measure
831+
------------------------------------
832+
833+
.. automodule:: datadog_api_client.v1.model.formula_and_function_slo_measure
834+
:members:
835+
:show-inheritance:
836+
837+
formula\_and\_function\_slo\_query\_definition
838+
----------------------------------------------
839+
840+
.. automodule:: datadog_api_client.v1.model.formula_and_function_slo_query_definition
841+
:members:
842+
:show-inheritance:
843+
844+
formula\_and\_function\_slo\_query\_type
845+
----------------------------------------
846+
847+
.. automodule:: datadog_api_client.v1.model.formula_and_function_slo_query_type
848+
:members:
849+
:show-inheritance:
850+
816851
free\_text\_widget\_definition
817852
------------------------------
818853

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
Create a new dashboard with a change widget using formulas and functions slo query
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
8+
from datadog_api_client.v1.model.change_widget_definition import ChangeWidgetDefinition
9+
from datadog_api_client.v1.model.change_widget_definition_type import ChangeWidgetDefinitionType
10+
from datadog_api_client.v1.model.change_widget_request import ChangeWidgetRequest
11+
from datadog_api_client.v1.model.dashboard import Dashboard
12+
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
13+
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat
14+
from datadog_api_client.v1.model.formula_and_function_slo_data_source import FormulaAndFunctionSLODataSource
15+
from datadog_api_client.v1.model.formula_and_function_slo_group_mode import FormulaAndFunctionSLOGroupMode
16+
from datadog_api_client.v1.model.formula_and_function_slo_measure import FormulaAndFunctionSLOMeasure
17+
from datadog_api_client.v1.model.formula_and_function_slo_query_definition import FormulaAndFunctionSLOQueryDefinition
18+
from datadog_api_client.v1.model.formula_and_function_slo_query_type import FormulaAndFunctionSLOQueryType
19+
from datadog_api_client.v1.model.widget import Widget
20+
from datadog_api_client.v1.model.widget_change_type import WidgetChangeType
21+
from datadog_api_client.v1.model.widget_formula import WidgetFormula
22+
from datadog_api_client.v1.model.widget_layout import WidgetLayout
23+
from datadog_api_client.v1.model.widget_order_by import WidgetOrderBy
24+
from datadog_api_client.v1.model.widget_sort import WidgetSort
25+
from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign
26+
from datadog_api_client.v1.model.widget_time import WidgetTime
27+
28+
# there is a valid "slo" in the system
29+
SLO_DATA_0_ID = environ["SLO_DATA_0_ID"]
30+
31+
body = Dashboard(
32+
title="Example-Dashboard",
33+
widgets=[
34+
Widget(
35+
definition=ChangeWidgetDefinition(
36+
title="",
37+
title_size="16",
38+
title_align=WidgetTextAlign.LEFT,
39+
time=WidgetTime(),
40+
type=ChangeWidgetDefinitionType.CHANGE,
41+
requests=[
42+
ChangeWidgetRequest(
43+
formulas=[
44+
WidgetFormula(
45+
formula="hour_before(query1)",
46+
),
47+
WidgetFormula(
48+
formula="query1",
49+
),
50+
],
51+
queries=[
52+
FormulaAndFunctionSLOQueryDefinition(
53+
name="query1",
54+
data_source=FormulaAndFunctionSLODataSource.SLO,
55+
slo_id=SLO_DATA_0_ID,
56+
measure=FormulaAndFunctionSLOMeasure.SLO_STATUS,
57+
group_mode=FormulaAndFunctionSLOGroupMode.OVERALL,
58+
slo_query_type=FormulaAndFunctionSLOQueryType.METRIC,
59+
),
60+
],
61+
response_format=FormulaAndFunctionResponseFormat.SCALAR,
62+
order_by=WidgetOrderBy.CHANGE,
63+
change_type=WidgetChangeType.ABSOLUTE,
64+
increase_good=True,
65+
order_dir=WidgetSort.ASCENDING,
66+
),
67+
],
68+
),
69+
layout=WidgetLayout(
70+
x=0,
71+
y=0,
72+
width=4,
73+
height=2,
74+
),
75+
),
76+
],
77+
layout_type=DashboardLayoutType.ORDERED,
78+
)
79+
80+
configuration = Configuration()
81+
with ApiClient(configuration) as api_client:
82+
api_instance = DashboardsApi(api_client)
83+
response = api_instance.create_dashboard(body=body)
84+
85+
print(response)

src/datadog_api_client/v1/model/change_widget_request.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
from datadog_api_client.v1.model.formula_and_function_apm_resource_stats_query_definition import (
3939
FormulaAndFunctionApmResourceStatsQueryDefinition,
4040
)
41+
from datadog_api_client.v1.model.formula_and_function_slo_query_definition import (
42+
FormulaAndFunctionSLOQueryDefinition,
43+
)
4144

4245

4346
class ChangeWidgetRequest(ModelNormal):
@@ -119,6 +122,7 @@ def __init__(
119122
FormulaAndFunctionProcessQueryDefinition,
120123
FormulaAndFunctionApmDependencyStatsQueryDefinition,
121124
FormulaAndFunctionApmResourceStatsQueryDefinition,
125+
FormulaAndFunctionSLOQueryDefinition,
122126
]
123127
],
124128
UnsetType,

src/datadog_api_client/v1/model/formula_and_function_query_definition.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ def __init__(self, **kwargs):
8383
8484
:param stat: APM statistic.
8585
:type stat: FormulaAndFunctionApmDependencyStatName
86+
87+
:param group_mode: Group mode to query measures.
88+
:type group_mode: FormulaAndFunctionSLOGroupMode, optional
89+
90+
:param measure: SLO measures queries.
91+
:type measure: FormulaAndFunctionSLOMeasure
92+
93+
:param slo_id: ID of an SLO to query measures.
94+
:type slo_id: str
95+
96+
:param slo_query_type: Name of the query for use in formulas.
97+
:type slo_query_type: FormulaAndFunctionSLOQueryType, optional
8698
"""
8799
super().__init__(kwargs)
88100

@@ -110,6 +122,9 @@ def _composed_schemas(_):
110122
from datadog_api_client.v1.model.formula_and_function_apm_resource_stats_query_definition import (
111123
FormulaAndFunctionApmResourceStatsQueryDefinition,
112124
)
125+
from datadog_api_client.v1.model.formula_and_function_slo_query_definition import (
126+
FormulaAndFunctionSLOQueryDefinition,
127+
)
113128

114129
return {
115130
"oneOf": [
@@ -118,5 +133,6 @@ def _composed_schemas(_):
118133
FormulaAndFunctionProcessQueryDefinition,
119134
FormulaAndFunctionApmDependencyStatsQueryDefinition,
120135
FormulaAndFunctionApmResourceStatsQueryDefinition,
136+
FormulaAndFunctionSLOQueryDefinition,
121137
],
122138
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class FormulaAndFunctionSLODataSource(ModelSimple):
16+
"""
17+
Data source for SLO measures queries.
18+
19+
:param value: If omitted defaults to "slo". Must be one of ["slo"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"slo",
25+
}
26+
SLO: ClassVar["FormulaAndFunctionSLODataSource"]
27+
28+
@cached_property
29+
def openapi_types(_):
30+
return {
31+
"value": (str,),
32+
}
33+
34+
35+
FormulaAndFunctionSLODataSource.SLO = FormulaAndFunctionSLODataSource("slo")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class FormulaAndFunctionSLOGroupMode(ModelSimple):
16+
"""
17+
Group mode to query measures.
18+
19+
:param value: Must be one of ["overall", "components"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"overall",
25+
"components",
26+
}
27+
OVERALL: ClassVar["FormulaAndFunctionSLOGroupMode"]
28+
COMPONENTS: ClassVar["FormulaAndFunctionSLOGroupMode"]
29+
30+
@cached_property
31+
def openapi_types(_):
32+
return {
33+
"value": (str,),
34+
}
35+
36+
37+
FormulaAndFunctionSLOGroupMode.OVERALL = FormulaAndFunctionSLOGroupMode("overall")
38+
FormulaAndFunctionSLOGroupMode.COMPONENTS = FormulaAndFunctionSLOGroupMode("components")

0 commit comments

Comments
 (0)