Skip to content

Commit a78a04a

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 2aab4b8 of spec repo
1 parent 92b1cde commit a78a04a

File tree

11 files changed

+416
-25
lines changed

11 files changed

+416
-25
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11409,6 +11409,60 @@ components:
1140911409
example: UTC
1141011410
type: string
1141111411
type: object
11412+
SLOCountCondition:
11413+
description: 'A count-based SLI specification, composed of three parts: the
11414+
good events formula, the total events formula,
11415+
11416+
and the involved queries.'
11417+
example:
11418+
good_events_formula: query1 - query2
11419+
queries:
11420+
- data_source: metrics
11421+
name: query1
11422+
query: sum:trace.servlet.request.success{*} by {env}.as_count()
11423+
- data_source: metrics
11424+
name: query2
11425+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11426+
total_events_formula: query2
11427+
properties:
11428+
good_events_formula:
11429+
$ref: '#/components/schemas/SLOFormula'
11430+
queries:
11431+
example:
11432+
- data_source: metrics
11433+
name: query1
11434+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11435+
items:
11436+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
11437+
minItems: 1
11438+
type: array
11439+
total_events_formula:
11440+
$ref: '#/components/schemas/SLOFormula'
11441+
required:
11442+
- good_events_formula
11443+
- total_events_formula
11444+
- queries
11445+
type: object
11446+
SLOCountSpec:
11447+
additionalProperties: false
11448+
description: A count-based SLI specification.
11449+
example:
11450+
count:
11451+
good_events_formula: query1 - query2
11452+
queries:
11453+
- data_source: metrics
11454+
name: query1
11455+
query: sum:trace.servlet.request.success{*} by {env}.as_count()
11456+
- data_source: metrics
11457+
name: query2
11458+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11459+
total_events_formula: query2
11460+
properties:
11461+
count:
11462+
$ref: '#/components/schemas/SLOCountCondition'
11463+
required:
11464+
- count
11465+
type: object
1141211466
SLOCreator:
1141311467
description: The creator of the SLO
1141411468
nullable: true
@@ -12295,8 +12349,6 @@ components:
1229512349
type: array
1229612350
timeframe:
1229712351
$ref: '#/components/schemas/SLOTimeframe'
12298-
type:
12299-
$ref: '#/components/schemas/SLOType'
1230012352
warning_threshold:
1230112353
description: 'The optional warning threshold such that when the service
1230212354
level indicator is
@@ -12314,9 +12366,10 @@ components:
1231412366
type: object
1231512367
SLOSliSpec:
1231612368
description: A generic SLI specification. This is currently used for time-slice
12317-
SLOs only.
12369+
and count-based SLOs only.
1231812370
oneOf:
1231912371
- $ref: '#/components/schemas/SLOTimeSliceSpec'
12372+
- $ref: '#/components/schemas/SLOCountSpec'
1232012373
SLOState:
1232112374
description: State of the SLO.
1232212375
enum:
@@ -13468,8 +13521,7 @@ components:
1346813521
- type
1346913522
type: object
1347013523
ServiceLevelObjectiveQuery:
13471-
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
13472-
Datadog only allows the sum by aggregator
13524+
description: 'A metric-based SLO. Note that Datadog only allows the sum by aggregator
1347313525

1347413526
to be used because this will sum up all request counts instead of averaging
1347513527
them, or taking the max or
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Create a new metric SLO object using sli_specification returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
5+
6+
body = DatadogAPIClient::V1::ServiceLevelObjectiveRequest.new({
7+
type: DatadogAPIClient::V1::SLOType::METRIC,
8+
description: "Metric SLO using sli_specification",
9+
name: "Example-Service-Level-Objective",
10+
sli_specification: DatadogAPIClient::V1::SLOCountSpec.new({
11+
count: DatadogAPIClient::V1::SLOCountCondition.new({
12+
good_events_formula: DatadogAPIClient::V1::SLOFormula.new({
13+
formula: "query1",
14+
}),
15+
total_events_formula: DatadogAPIClient::V1::SLOFormula.new({
16+
formula: "query2",
17+
}),
18+
queries: [
19+
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
20+
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
21+
name: "query1",
22+
query: "sum:httpservice.success{*}.as_count()",
23+
}),
24+
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
25+
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
26+
name: "query2",
27+
query: "sum:httpservice.hits{*}.as_count()",
28+
}),
29+
],
30+
}),
31+
}),
32+
tags: [
33+
"env:prod",
34+
"type:count",
35+
],
36+
thresholds: [
37+
DatadogAPIClient::V1::SLOThreshold.new({
38+
target: 99.0,
39+
target_display: "99.0",
40+
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
41+
warning: 98,
42+
warning_display: "98.0",
43+
}),
44+
],
45+
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
46+
target_threshold: 99.0,
47+
warning_threshold: 98,
48+
})
49+
p api_instance.create_slo(body)

features/v1/service_level_objectives.feature

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,30 @@ 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 metric SLO with both sli_specification and query returns "Bad Request" response
53+
Given new "CreateSLO" request
54+
And body with value {"type":"metric","description":"Invalid SLO with both sli_specification and query","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1"},"total_events_formula":{"formula":"query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.success{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.hits{*}.as_count()"}]}},"query":{"numerator":"sum:httpservice.success{*}.as_count()","denominator":"sum:httpservice.hits{*}.as_count()"},"tags":["env:prod"],"thresholds":[{"target":99.0,"target_display":"99.0","timeframe":"7d","warning":98,"warning_display":"98.0"}],"timeframe":"7d","target_threshold":99.0,"warning_threshold":98}
55+
When the request is sent
56+
Then the response status is 400 Bad Request
57+
58+
@team:DataDog/slo-app
59+
Scenario: Create a new metric SLO object using sli_specification returns "OK" response
60+
Given new "CreateSLO" request
61+
And body with value {"type":"metric","description":"Metric SLO using sli_specification","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1"},"total_events_formula":{"formula":"query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.success{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.hits{*}.as_count()"}]}},"tags":["env:prod","type:count"],"thresholds":[{"target":99.0,"target_display":"99.0","timeframe":"7d","warning":98,"warning_display":"98.0"}],"timeframe":"7d","target_threshold":99.0,"warning_threshold":98}
62+
When the request is sent
63+
Then the response status is 200 OK
64+
And the response "data[0].timeframe" is equal to "7d"
65+
And the response "data[0].target_threshold" is equal to 99.0
66+
And the response "data[0].warning_threshold" is equal to 98.0
67+
And the response "data[0]" has field "sli_specification"
68+
And the response "data[0].sli_specification" has field "count"
69+
And the response "data[0].sli_specification.count" has field "good_events_formula"
70+
And the response "data[0].sli_specification.count" has field "total_events_formula"
71+
And the response "data[0].sli_specification.count" has field "queries"
72+
And the response "data[0].sli_specification.count.queries" has length 2
73+
And the response "data[0]" does not have field "query"
74+
5175
@team:DataDog/slo-app
5276
Scenario: Create a time-slice SLO object returns "OK" response
5377
Given new "CreateSLO" request
@@ -74,6 +98,8 @@ Feature: Service Level Objectives
7498
And the response "data[0].timeframe" is equal to "7d"
7599
And the response "data[0].target_threshold" is equal to 97.0
76100
And the response "data[0].warning_threshold" is equal to 98.0
101+
And the response "data[0]" has field "query"
102+
And the response "data[0]" does not have field "sli_specification"
77103

78104
@generated @skip @team:DataDog/slo-app
79105
Scenario: Delete an SLO returns "Conflict" response

lib/datadog_api_client/inflector.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ def overrides
518518
"v1.slo_correction_update_data" => "SLOCorrectionUpdateData",
519519
"v1.slo_correction_update_request" => "SLOCorrectionUpdateRequest",
520520
"v1.slo_correction_update_request_attributes" => "SLOCorrectionUpdateRequestAttributes",
521+
"v1.slo_count_condition" => "SLOCountCondition",
522+
"v1.slo_count_spec" => "SLOCountSpec",
521523
"v1.slo_creator" => "SLOCreator",
522524
"v1.slo_data_source_query_definition" => "SLODataSourceQueryDefinition",
523525
"v1.slo_delete_response" => "SLODeleteResponse",

lib/datadog_api_client/v1/models/service_level_objective.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ class ServiceLevelObjective
6868
# The name of the service level objective object.
6969
attr_reader :name
7070

71-
# A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
71+
# A metric-based SLO. Note that Datadog only allows the sum by aggregator
7272
# to be used because this will sum up all request counts instead of averaging them, or taking the max or
7373
# min of all of those requests.
7474
attr_accessor :query
7575

76-
# A generic SLI specification. This is currently used for time-slice SLOs only.
76+
# A generic SLI specification. This is currently used for time-slice and count-based SLOs only.
7777
attr_accessor :sli_specification
7878

7979
# A list of tags associated with this service level objective.

lib/datadog_api_client/v1/models/service_level_objective_query.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
require 'time'
1818

1919
module DatadogAPIClient::V1
20-
# A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
20+
# A metric-based SLO. Note that Datadog only allows the sum by aggregator
2121
# to be used because this will sum up all request counts instead of averaging them, or taking the max or
2222
# min of all of those requests.
2323
class ServiceLevelObjectiveQuery

lib/datadog_api_client/v1/models/service_level_objective_request.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class ServiceLevelObjectiveRequest
4242
# The name of the service level objective object.
4343
attr_reader :name
4444

45-
# A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
45+
# A metric-based SLO. Note that Datadog only allows the sum by aggregator
4646
# to be used because this will sum up all request counts instead of averaging them, or taking the max or
4747
# min of all of those requests.
4848
attr_accessor :query
4949

50-
# A generic SLI specification. This is currently used for time-slice SLOs only.
50+
# A generic SLI specification. This is currently used for time-slice and count-based SLOs only.
5151
attr_accessor :sli_specification
5252

5353
# A list of tags associated with this service level objective.

0 commit comments

Comments
 (0)