Skip to content

Commit 1f3c9f5

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit ec4991e of spec repo
1 parent 7b1faf0 commit 1f3c9f5

8 files changed

Lines changed: 170 additions & 23 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12054,52 +12054,60 @@ components:
1205412054
type: object
1205512055
SLOCountDefinition:
1205612056
description: 'A count-based (metric) SLI specification, composed of three parts:
12057-
the good events formula, the total events formula,
12057+
the good events formula,
1205812058

12059-
and the underlying queries.'
12059+
the bad or total events formula, and the underlying queries.'
1206012060
example:
12061-
good_events_formula: query1 - query2
12061+
bad_events_formula: query2
12062+
good_events_formula: query1
1206212063
queries:
1206312064
- data_source: metrics
1206412065
name: query1
12065-
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
12066+
query: sum:trace.servlet.request.hits{http.status_code:2*} by {env}.as_count()
1206612067
- data_source: metrics
1206712068
name: query2
12068-
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
12069-
total_events_formula: query1
12069+
query: sum:trace.servlet.request.hits{http.status_code:5*} by {env}.as_count()
1207012070
properties:
12071+
bad_events_formula:
12072+
$ref: '#/components/schemas/SLOFormula'
12073+
description: The bad events formula (recommended). Total events queries
12074+
can be defined using the `total_events_formula` field as an alternative.
1207112075
good_events_formula:
1207212076
$ref: '#/components/schemas/SLOFormula'
1207312077
queries:
1207412078
example:
1207512079
- data_source: metrics
1207612080
name: query1
12077-
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
12081+
query: sum:trace.servlet.request.hits{http.status_code:2*} by {env}.as_count()
12082+
- data_source: metrics
12083+
name: query2
12084+
query: sum:trace.servlet.request.hits{http.status_code:5*} by {env}.as_count()
1207812085
items:
1207912086
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
1208012087
minItems: 1
1208112088
type: array
1208212089
total_events_formula:
1208312090
$ref: '#/components/schemas/SLOFormula'
12091+
description: The total events formula. Bad events queries can be defined
12092+
using the `bad_events_formula` field as an alternative.
1208412093
required:
1208512094
- good_events_formula
12086-
- total_events_formula
1208712095
- queries
1208812096
type: object
1208912097
SLOCountSpec:
1209012098
additionalProperties: false
1209112099
description: A metric SLI specification.
1209212100
example:
1209312101
count:
12094-
good_events_formula: query1 - query2
12102+
bad_events_formula: query2
12103+
good_events_formula: query1
1209512104
queries:
1209612105
- data_source: metrics
1209712106
name: query1
12098-
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
12107+
query: sum:trace.servlet.request.hits{!http.status_code:5*} by {env}.as_count()
1209912108
- data_source: metrics
1210012109
name: query2
12101-
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
12102-
total_events_formula: query1
12110+
query: sum:trace.servlet.request.hits{http.status_code:5*} by {env}.as_count()
1210312111
properties:
1210412112
count:
1210512113
$ref: '#/components/schemas/SLOCountDefinition'
@@ -13235,7 +13243,7 @@ components:
1323513243
name: query1
1323613244
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
1323713245
- data_source: metrics
13238-
name: query1
13246+
name: query2
1323913247
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
1324013248
threshold: 5
1324113249
properties:
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""
2+
Create a new metric SLO object using bad events formula returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
7+
from datadog_api_client.v1.model.formula_and_function_metric_data_source import FormulaAndFunctionMetricDataSource
8+
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
9+
FormulaAndFunctionMetricQueryDefinition,
10+
)
11+
from datadog_api_client.v1.model.service_level_objective_request import ServiceLevelObjectiveRequest
12+
from datadog_api_client.v1.model.slo_count_definition import SLOCountDefinition
13+
from datadog_api_client.v1.model.slo_count_spec import SLOCountSpec
14+
from datadog_api_client.v1.model.slo_formula import SLOFormula
15+
from datadog_api_client.v1.model.slo_threshold import SLOThreshold
16+
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
17+
from datadog_api_client.v1.model.slo_type import SLOType
18+
19+
body = ServiceLevelObjectiveRequest(
20+
type=SLOType.METRIC,
21+
description="Metric SLO using sli_specification",
22+
name="Example-Service-Level-Objective",
23+
sli_specification=SLOCountSpec(
24+
count=SLOCountDefinition(
25+
good_events_formula=SLOFormula(
26+
formula="query1 - query2",
27+
),
28+
bad_events_formula=SLOFormula(
29+
formula="query2",
30+
),
31+
queries=[
32+
FormulaAndFunctionMetricQueryDefinition(
33+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
34+
name="query1",
35+
query="sum:httpservice.hits{*}.as_count()",
36+
),
37+
FormulaAndFunctionMetricQueryDefinition(
38+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
39+
name="query2",
40+
query="sum:httpservice.errors{*}.as_count()",
41+
),
42+
],
43+
),
44+
),
45+
tags=[
46+
"env:prod",
47+
"type:count",
48+
],
49+
thresholds=[
50+
SLOThreshold(
51+
target=99.0,
52+
target_display="99.0",
53+
timeframe=SLOTimeframe.SEVEN_DAYS,
54+
warning=99.5,
55+
warning_display="99.5",
56+
),
57+
],
58+
timeframe=SLOTimeframe.SEVEN_DAYS,
59+
target_threshold=99.0,
60+
warning_threshold=99.5,
61+
)
62+
63+
configuration = Configuration()
64+
with ApiClient(configuration) as api_client:
65+
api_instance = ServiceLevelObjectivesApi(api_client)
66+
response = api_instance.create_slo(body=body)
67+
68+
print(response)

src/datadog_api_client/v1/model/slo_count_definition.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from datadog_api_client.model_utils import (
99
ModelNormal,
1010
cached_property,
11+
unset,
12+
UnsetType,
1113
)
1214

1315

@@ -32,12 +34,14 @@ def openapi_types(_):
3234
from datadog_api_client.v1.model.slo_data_source_query_definition import SLODataSourceQueryDefinition
3335

3436
return {
37+
"bad_events_formula": (SLOFormula,),
3538
"good_events_formula": (SLOFormula,),
3639
"queries": ([SLODataSourceQueryDefinition],),
3740
"total_events_formula": (SLOFormula,),
3841
}
3942

4043
attribute_map = {
44+
"bad_events_formula": "bad_events_formula",
4145
"good_events_formula": "good_events_formula",
4246
"queries": "queries",
4347
"total_events_formula": "total_events_formula",
@@ -47,12 +51,16 @@ def __init__(
4751
self_,
4852
good_events_formula: SLOFormula,
4953
queries: List[Union[SLODataSourceQueryDefinition, FormulaAndFunctionMetricQueryDefinition]],
50-
total_events_formula: SLOFormula,
54+
bad_events_formula: Union[SLOFormula, UnsetType] = unset,
55+
total_events_formula: Union[SLOFormula, UnsetType] = unset,
5156
**kwargs,
5257
):
5358
"""
54-
A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
55-
and the underlying queries.
59+
A count-based (metric) SLI specification, composed of three parts: the good events formula,
60+
the bad or total events formula, and the underlying queries.
61+
62+
:param bad_events_formula: A formula that specifies how to combine the results of multiple queries.
63+
:type bad_events_formula: SLOFormula, optional
5664
5765
:param good_events_formula: A formula that specifies how to combine the results of multiple queries.
5866
:type good_events_formula: SLOFormula
@@ -61,10 +69,13 @@ def __init__(
6169
:type queries: [SLODataSourceQueryDefinition]
6270
6371
:param total_events_formula: A formula that specifies how to combine the results of multiple queries.
64-
:type total_events_formula: SLOFormula
72+
:type total_events_formula: SLOFormula, optional
6573
"""
74+
if bad_events_formula is not unset:
75+
kwargs["bad_events_formula"] = bad_events_formula
76+
if total_events_formula is not unset:
77+
kwargs["total_events_formula"] = total_events_formula
6678
super().__init__(kwargs)
6779

6880
self_.good_events_formula = good_events_formula
6981
self_.queries = queries
70-
self_.total_events_formula = total_events_formula

src/datadog_api_client/v1/model/slo_count_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def __init__(self_, count: SLOCountDefinition, **kwargs):
3636
"""
3737
A metric SLI specification.
3838
39-
:param count: A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
40-
and the underlying queries.
39+
:param count: A count-based (metric) SLI specification, composed of three parts: the good events formula,
40+
the bad or total events formula, and the underlying queries.
4141
:type count: SLOCountDefinition
4242
"""
4343
super().__init__(kwargs)

src/datadog_api_client/v1/model/slo_sli_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def __init__(self, **kwargs):
1919
and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
2020
:type time_slice: SLOTimeSliceCondition
2121
22-
:param count: A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
23-
and the underlying queries.
22+
:param count: A count-based (metric) SLI specification, composed of three parts: the good events formula,
23+
the bad or total events formula, and the underlying queries.
2424
:type count: SLOCountDefinition
2525
"""
2626
super().__init__(kwargs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-02-25T17:45:38.518Z
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: '{"description":"Metric SLO using sli_specification","name":"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538","sli_specification":{"count":{"bad_events_formula":{"formula":"query2"},"good_events_formula":{"formula":"query1
4+
- query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}},"tags":["env:prod","type:count"],"target_threshold":99,"thresholds":[{"target":99,"target_display":"99.0","timeframe":"7d","warning":99.5,"warning_display":"99.5"}],"timeframe":"7d","type":"metric","warning_threshold":99.5}'
5+
headers:
6+
accept:
7+
- application/json
8+
content-type:
9+
- application/json
10+
method: POST
11+
uri: https://api.datadoghq.com/api/v1/slo
12+
response:
13+
body:
14+
string: '{"data":[{"id":"7309ff3752fd519f80f65a2ed3247dbb","name":"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538","tags":["env:prod","type:count"],"monitor_tags":[],"thresholds":[{"timeframe":"7d","target":99.0,"target_display":"99.","warning":99.5,"warning_display":"99.5"}],"type":"metric","type_id":1,"description":"Metric
15+
SLO using sli_specification","timeframe":"7d","warning_threshold":99.5,"target_threshold":99,"query":{"numerator":"sum:httpservice.hits{*}.as_count()
16+
- sum:httpservice.errors{*}.as_count()","denominator":"(sum:httpservice.hits{*}.as_count()
17+
- sum:httpservice.errors{*}.as_count()) + (sum:httpservice.errors{*}.as_count())"},"creator":{"name":"CI
18+
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"team-intg-tools-libs-spam@datadoghq.com"},"created_at":1772041538,"modified_at":1772041538,"sli_specification":{"count":{"bad_events_formula":{"formula":"query2"},"good_events_formula":{"formula":"query1
19+
- query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}}}],"error":null}
20+
21+
'
22+
headers:
23+
content-type:
24+
- application/json
25+
status:
26+
code: 200
27+
message: OK
28+
- request:
29+
body: null
30+
headers:
31+
accept:
32+
- application/json
33+
method: DELETE
34+
uri: https://api.datadoghq.com/api/v1/slo/7309ff3752fd519f80f65a2ed3247dbb
35+
response:
36+
body:
37+
string: '{"data":["7309ff3752fd519f80f65a2ed3247dbb"],"error":null}
38+
39+
'
40+
headers:
41+
content-type:
42+
- application/json
43+
status:
44+
code: 200
45+
message: OK
46+
version: 1

tests/v1/features/service_level_objectives.feature

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ Feature: Service Level Objectives
4848
When the request is sent
4949
Then the response status is 200 OK
5050

51+
@team:DataDog/slo-app
52+
Scenario: Create a new metric SLO object using bad events formula returns "OK" response
53+
Given new "CreateSLO" request
54+
And body with value {"type":"metric","description":"Metric SLO using sli_specification","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1 - query2"},"bad_events_formula":{"formula":"query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}},"tags":["env:prod","type:count"],"thresholds":[{"target":99.0,"target_display":"99.0","timeframe":"7d","warning":99.5,"warning_display":"99.5"}],"timeframe":"7d","target_threshold":99.0,"warning_threshold":99.5}
55+
When the request is sent
56+
Then the response status is 200 OK
57+
And the response "data[0]" has field "sli_specification"
58+
And the response "data[0].sli_specification" has field "count"
59+
And the response "data[0].sli_specification.count" has field "good_events_formula"
60+
And the response "data[0].sli_specification.count" has field "bad_events_formula"
61+
And the response "data[0].sli_specification.count" has field "queries"
62+
And the response "data[0].sli_specification.count.queries" has length 2
63+
5164
@team:DataDog/slo-app
5265
Scenario: Create a new metric SLO object using sli_specification returns "OK" response
5366
Given new "CreateSLO" request
@@ -247,7 +260,7 @@ Feature: Service Level Objectives
247260
Scenario: Update an SLO returns "Not Found" response
248261
Given new "UpdateSLO" request
249262
And request contains "slo_id" parameter from "REPLACE.ME"
250-
And body with value {"description": null, "groups": ["env:prod", "role:mysql"], "monitor_ids": [], "monitor_tags": [], "name": "Custom Metric SLO", "query": {"denominator": "sum:my.custom.metric{*}.as_count()", "numerator": "sum:my.custom.metric{type:good}.as_count()"}, "sli_specification": {"time_slice": {"comparator": "<", "query": {"formulas": [{"formula": "query2/query1"}], "queries": [{"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.hits{*} by {env}.as_count()"}, {"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.errors{*} by {env}.as_count()"}]}, "threshold": 5}}, "tags": ["env:prod", "app:core"], "target_threshold": 99.9, "thresholds": [{"target": 95, "timeframe": "7d"}, {"target": 95, "timeframe": "30d", "warning": 97}], "timeframe": "30d", "type": "metric", "warning_threshold": 99.95}
263+
And body with value {"description": null, "groups": ["env:prod", "role:mysql"], "monitor_ids": [], "monitor_tags": [], "name": "Custom Metric SLO", "query": {"denominator": "sum:my.custom.metric{*}.as_count()", "numerator": "sum:my.custom.metric{type:good}.as_count()"}, "sli_specification": {"time_slice": {"comparator": "<", "query": {"formulas": [{"formula": "query2/query1"}], "queries": [{"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.hits{*} by {env}.as_count()"}, {"data_source": "metrics", "name": "query2", "query": "sum:trace.servlet.request.errors{*} by {env}.as_count()"}]}, "threshold": 5}}, "tags": ["env:prod", "app:core"], "target_threshold": 99.9, "thresholds": [{"target": 95, "timeframe": "7d"}, {"target": 95, "timeframe": "30d", "warning": 97}], "timeframe": "30d", "type": "metric", "warning_threshold": 99.95}
251264
When the request is sent
252265
Then the response status is 404 Not Found
253266

0 commit comments

Comments
 (0)