Skip to content
Open
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
64 changes: 52 additions & 12 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12338,33 +12338,73 @@ components:
type: object
SLOCountDefinition:
description: 'A count-based (metric) SLI specification, composed of three parts:
the good events formula, the total events formula,
the good events formula,

and the underlying queries.'
the bad or total events formula, and the underlying queries.

Exactly one of `total_events_formula` or `bad_events_formula` must be provided.'
example:
good_events_formula: query1 - query2
bad_events_formula: query2
good_events_formula: query1
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
total_events_formula: query1
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
oneOf:
- $ref: '#/components/schemas/SLOCountDefinitionWithTotalEventsFormula'
- $ref: '#/components/schemas/SLOCountDefinitionWithBadEventsFormula'
SLOCountDefinitionWithBadEventsFormula:
additionalProperties: false
properties:
bad_events_formula:
$ref: '#/components/schemas/SLOFormula'
description: The bad events formula (recommended). Total events queries
can be defined using the `total_events_formula` field as an alternative.
Only one of `total_events_formula` or `bad_events_formula` must be provided.
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
required:
- good_events_formula
- bad_events_formula
- queries
type: object
SLOCountDefinitionWithTotalEventsFormula:
additionalProperties: false
properties:
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
total_events_formula:
$ref: '#/components/schemas/SLOFormula'
description: The total events formula. Bad events queries can be defined
using the `bad_events_formula` field as an alternative. Only one of `total_events_formula`
or `bad_events_formula` must be provided.
required:
- good_events_formula
- total_events_formula
Expand All @@ -12375,15 +12415,15 @@ components:
description: A metric SLI specification.
example:
count:
good_events_formula: query1 - query2
bad_events_formula: query2
good_events_formula: query1
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
total_events_formula: query1
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
properties:
count:
$ref: '#/components/schemas/SLOCountDefinition'
Expand Down Expand Up @@ -13519,7 +13559,7 @@ components:
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
- data_source: metrics
name: query1
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
threshold: 5
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2026-02-25T17:45:38.518Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
description: "Metric SLO using sli_specification",
name: "Example-Service-Level-Objective",
sli_specification: DatadogAPIClient::V1::SLOCountSpec.new({
count: DatadogAPIClient::V1::SLOCountDefinition.new({
count: DatadogAPIClient::V1::SLOCountDefinitionWithTotalEventsFormula.new({
good_events_formula: DatadogAPIClient::V1::SLOFormula.new({
formula: "query1 - query2",
}),
Expand Down
49 changes: 49 additions & 0 deletions examples/v1/service-level-objectives/CreateSLO_707861409.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Create a new metric SLO object using bad events formula returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new

body = DatadogAPIClient::V1::ServiceLevelObjectiveRequest.new({
type: DatadogAPIClient::V1::SLOType::METRIC,
description: "Metric SLO using sli_specification",
name: "Example-Service-Level-Objective",
sli_specification: DatadogAPIClient::V1::SLOCountSpec.new({
count: DatadogAPIClient::V1::SLOCountDefinitionWithBadEventsFormula.new({
good_events_formula: DatadogAPIClient::V1::SLOFormula.new({
formula: "query1 - query2",
}),
bad_events_formula: DatadogAPIClient::V1::SLOFormula.new({
formula: "query2",
}),
queries: [
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
name: "query1",
query: "sum:httpservice.hits{*}.as_count()",
}),
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
name: "query2",
query: "sum:httpservice.errors{*}.as_count()",
}),
],
}),
}),
tags: [
"env:prod",
"type:count",
],
thresholds: [
DatadogAPIClient::V1::SLOThreshold.new({
target: 99.0,
target_display: "99.0",
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
warning: 99.5,
warning_display: "99.5",
}),
],
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
target_threshold: 99.0,
warning_threshold: 99.5,
})
p api_instance.create_slo(body)
15 changes: 14 additions & 1 deletion features/v1/service_level_objectives.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ Feature: Service Level Objectives
When the request is sent
Then the response status is 200 OK

@team:DataDog/slo-app
Scenario: Create a new metric SLO object using bad events formula returns "OK" response
Given new "CreateSLO" request
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}
When the request is sent
Then the response status is 200 OK
And the response "data[0]" has field "sli_specification"
And the response "data[0].sli_specification" has field "count"
And the response "data[0].sli_specification.count" has field "good_events_formula"
And the response "data[0].sli_specification.count" has field "bad_events_formula"
And the response "data[0].sli_specification.count" has field "queries"
And the response "data[0].sli_specification.count.queries" has length 2

@team:DataDog/slo-app
Scenario: Create a new metric SLO object using sli_specification returns "OK" response
Given new "CreateSLO" request
Expand Down Expand Up @@ -247,7 +260,7 @@ Feature: Service Level Objectives
Scenario: Update an SLO returns "Not Found" response
Given new "UpdateSLO" request
And request contains "slo_id" parameter from "REPLACE.ME"
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}
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}
When the request is sent
Then the response status is 404 Not Found

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ def overrides
"v1.slo_correction_update_request" => "SLOCorrectionUpdateRequest",
"v1.slo_correction_update_request_attributes" => "SLOCorrectionUpdateRequestAttributes",
"v1.slo_count_definition" => "SLOCountDefinition",
"v1.slo_count_definition_with_bad_events_formula" => "SLOCountDefinitionWithBadEventsFormula",
"v1.slo_count_definition_with_total_events_formula" => "SLOCountDefinitionWithTotalEventsFormula",
"v1.slo_count_spec" => "SLOCountSpec",
"v1.slo_creator" => "SLOCreator",
"v1.slo_data_source_query_definition" => "SLODataSourceQueryDefinition",
Expand Down
Loading
Loading