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
72 changes: 69 additions & 3 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11548,6 +11548,61 @@ components:
example: UTC
type: string
type: object
SLOCountDefinition:
description: 'A count-based (metric) SLI specification, composed of three parts:
the good events formula, the total events formula,

and the underlying queries. Usage is not permitted when request payload contains
`query` field.'
example:
good_events_formula: query1 - query2
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()
total_events_formula: query1
properties:
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
total_events_formula:
$ref: '#/components/schemas/SLOFormula'
required:
- good_events_formula
- total_events_formula
- queries
type: object
SLOCountSpec:
additionalProperties: false
description: A metric SLI specification.
example:
count:
good_events_formula: query1 - query2
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()
total_events_formula: query1
properties:
count:
$ref: '#/components/schemas/SLOCountDefinition'
required:
- count
type: object
SLOCreator:
description: The creator of the SLO
nullable: true
Expand Down Expand Up @@ -12395,8 +12450,16 @@ components:
type: string
query:
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
description: 'The metric query of good / total events. This is not allowed
if the `sli_specification` field

is used in the same request.'
sli_specification:
$ref: '#/components/schemas/SLOSliSpec'
description: 'A generic SLI specification. This is currently used for time-slice
and count-based (metric) SLOs only.

This is not allowed if the `query` field is used in the same request.'
tags:
description: 'A list of tags associated with this service level objective.

Expand Down Expand Up @@ -12453,9 +12516,10 @@ components:
type: object
SLOSliSpec:
description: A generic SLI specification. This is currently used for time-slice
SLOs only.
and count-based (metric) SLOs only.
oneOf:
- $ref: '#/components/schemas/SLOTimeSliceSpec'
- $ref: '#/components/schemas/SLOCountSpec'
SLOState:
description: State of the SLO.
enum:
Expand Down Expand Up @@ -13607,13 +13671,15 @@ components:
- type
type: object
ServiceLevelObjectiveQuery:
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
description: 'A count-based (metric) SLO query. This field has been superseded
by `sli_specification` but is retained for backwards compatibility. Note that
Datadog only allows the sum by aggregator

to be used because this will sum up all request counts instead of averaging
them, or taking the max or

min of all of those requests.'
min of all of those requests. Usage is not permitted when request payload
contains `sli_specification` field.'
properties:
denominator:
description: A Datadog metric query for total (valid) events.
Expand Down
76 changes: 76 additions & 0 deletions examples/v1/service-level-objectives/CreateSLO_512760759.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Create a new metric SLO object using sli_specification returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi;
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource;
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition;
import com.datadog.api.client.v1.model.SLOCountDefinition;
import com.datadog.api.client.v1.model.SLOCountSpec;
import com.datadog.api.client.v1.model.SLODataSourceQueryDefinition;
import com.datadog.api.client.v1.model.SLOFormula;
import com.datadog.api.client.v1.model.SLOListResponse;
import com.datadog.api.client.v1.model.SLOSliSpec;
import com.datadog.api.client.v1.model.SLOThreshold;
import com.datadog.api.client.v1.model.SLOTimeframe;
import com.datadog.api.client.v1.model.SLOType;
import com.datadog.api.client.v1.model.ServiceLevelObjectiveRequest;
import java.util.Arrays;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);

ServiceLevelObjectiveRequest body =
new ServiceLevelObjectiveRequest()
.type(SLOType.METRIC)
.description("Metric SLO using sli_specification")
.name("Example-Service-Level-Objective")
.sliSpecification(
new SLOSliSpec(
new SLOCountSpec()
.count(
new SLOCountDefinition()
.goodEventsFormula(new SLOFormula().formula("query1 - query2"))
.totalEventsFormula(new SLOFormula().formula("query1"))
.queries(
Arrays.asList(
new SLODataSourceQueryDefinition(
new FormulaAndFunctionMetricQueryDefinition()
.dataSource(
FormulaAndFunctionMetricDataSource.METRICS)
.name("query1")
.query("sum:httpservice.hits{*}.as_count()")),
new SLODataSourceQueryDefinition(
new FormulaAndFunctionMetricQueryDefinition()
.dataSource(
FormulaAndFunctionMetricDataSource.METRICS)
.name("query2")
.query("sum:httpservice.errors{*}.as_count()")))))))
.tags(Arrays.asList("env:prod", "type:count"))
.thresholds(
Collections.singletonList(
new SLOThreshold()
.target(99.0)
.targetDisplay("99.0")
.timeframe(SLOTimeframe.SEVEN_DAYS)
.warning(99.5)
.warningDisplay("99.5")))
.timeframe(SLOTimeframe.SEVEN_DAYS)
.targetThreshold(99.0)
.warningThreshold(99.5);

try {
SLOListResponse result = apiInstance.createSLO(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ServiceLevelObjectivesApi#createSLO");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Loading
Loading