Skip to content

Commit 1fed16b

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 80bf871 of spec repo
1 parent abefb46 commit 1fed16b

File tree

10 files changed

+571
-22
lines changed

10 files changed

+571
-22
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11900,6 +11900,61 @@ components:
1190011900
example: UTC
1190111901
type: string
1190211902
type: object
11903+
SLOCountDefinition:
11904+
description: 'A count-based (metric) SLI specification, composed of three parts:
11905+
the good events formula, the total events formula,
11906+
11907+
and the underlying queries. Usage is not permitted when request payload contains
11908+
`query` field.'
11909+
example:
11910+
good_events_formula: query1 - query2
11911+
queries:
11912+
- data_source: metrics
11913+
name: query1
11914+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11915+
- data_source: metrics
11916+
name: query2
11917+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11918+
total_events_formula: query1
11919+
properties:
11920+
good_events_formula:
11921+
$ref: '#/components/schemas/SLOFormula'
11922+
queries:
11923+
example:
11924+
- data_source: metrics
11925+
name: query1
11926+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11927+
items:
11928+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
11929+
minItems: 1
11930+
type: array
11931+
total_events_formula:
11932+
$ref: '#/components/schemas/SLOFormula'
11933+
required:
11934+
- good_events_formula
11935+
- total_events_formula
11936+
- queries
11937+
type: object
11938+
SLOCountSpec:
11939+
additionalProperties: false
11940+
description: A metric SLI specification.
11941+
example:
11942+
count:
11943+
good_events_formula: query1 - query2
11944+
queries:
11945+
- data_source: metrics
11946+
name: query1
11947+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11948+
- data_source: metrics
11949+
name: query2
11950+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11951+
total_events_formula: query1
11952+
properties:
11953+
count:
11954+
$ref: '#/components/schemas/SLOCountDefinition'
11955+
required:
11956+
- count
11957+
type: object
1190311958
SLOCreator:
1190411959
description: The creator of the SLO
1190511960
nullable: true
@@ -12747,8 +12802,16 @@ components:
1274712802
type: string
1274812803
query:
1274912804
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
12805+
description: 'The metric query of good / total events. This is not allowed
12806+
if the `sli_specification` field
12807+
12808+
is used in the same request.'
1275012809
sli_specification:
1275112810
$ref: '#/components/schemas/SLOSliSpec'
12811+
description: 'A generic SLI specification. This is currently used for time-slice
12812+
and count-based (metric) SLOs only.
12813+
12814+
This is not allowed if the `query` field is used in the same request.'
1275212815
tags:
1275312816
description: 'A list of tags associated with this service level objective.
1275412817

@@ -12805,9 +12868,10 @@ components:
1280512868
type: object
1280612869
SLOSliSpec:
1280712870
description: A generic SLI specification. This is currently used for time-slice
12808-
SLOs only.
12871+
and count-based (metric) SLOs only.
1280912872
oneOf:
1281012873
- $ref: '#/components/schemas/SLOTimeSliceSpec'
12874+
- $ref: '#/components/schemas/SLOCountSpec'
1281112875
SLOState:
1281212876
description: State of the SLO.
1281312877
enum:
@@ -13959,13 +14023,15 @@ components:
1395914023
- type
1396014024
type: object
1396114025
ServiceLevelObjectiveQuery:
13962-
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
14026+
description: 'A count-based (metric) SLO query. This field has been superseded
14027+
by `sli_specification` but is retained for backwards compatibility. Note that
1396314028
Datadog only allows the sum by aggregator
1396414029

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

13968-
min of all of those requests.'
14033+
min of all of those requests. Usage is not permitted when request payload
14034+
contains `sli_specification` field.'
1396914035
properties:
1397014036
denominator:
1397114037
description: A Datadog metric query for total (valid) events.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Create a new metric SLO object using sli_specification returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi;
6+
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource;
7+
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition;
8+
import com.datadog.api.client.v1.model.SLOCountDefinition;
9+
import com.datadog.api.client.v1.model.SLOCountSpec;
10+
import com.datadog.api.client.v1.model.SLODataSourceQueryDefinition;
11+
import com.datadog.api.client.v1.model.SLOFormula;
12+
import com.datadog.api.client.v1.model.SLOListResponse;
13+
import com.datadog.api.client.v1.model.SLOSliSpec;
14+
import com.datadog.api.client.v1.model.SLOThreshold;
15+
import com.datadog.api.client.v1.model.SLOTimeframe;
16+
import com.datadog.api.client.v1.model.SLOType;
17+
import com.datadog.api.client.v1.model.ServiceLevelObjectiveRequest;
18+
import java.util.Arrays;
19+
import java.util.Collections;
20+
21+
public class Example {
22+
public static void main(String[] args) {
23+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
24+
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
25+
26+
ServiceLevelObjectiveRequest body =
27+
new ServiceLevelObjectiveRequest()
28+
.type(SLOType.METRIC)
29+
.description("Metric SLO using sli_specification")
30+
.name("Example-Service-Level-Objective")
31+
.sliSpecification(
32+
new SLOSliSpec(
33+
new SLOCountSpec()
34+
.count(
35+
new SLOCountDefinition()
36+
.goodEventsFormula(new SLOFormula().formula("query1 - query2"))
37+
.totalEventsFormula(new SLOFormula().formula("query1"))
38+
.queries(
39+
Arrays.asList(
40+
new SLODataSourceQueryDefinition(
41+
new FormulaAndFunctionMetricQueryDefinition()
42+
.dataSource(
43+
FormulaAndFunctionMetricDataSource.METRICS)
44+
.name("query1")
45+
.query("sum:httpservice.hits{*}.as_count()")),
46+
new SLODataSourceQueryDefinition(
47+
new FormulaAndFunctionMetricQueryDefinition()
48+
.dataSource(
49+
FormulaAndFunctionMetricDataSource.METRICS)
50+
.name("query2")
51+
.query("sum:httpservice.errors{*}.as_count()")))))))
52+
.tags(Arrays.asList("env:prod", "type:count"))
53+
.thresholds(
54+
Collections.singletonList(
55+
new SLOThreshold()
56+
.target(99.0)
57+
.targetDisplay("99.0")
58+
.timeframe(SLOTimeframe.SEVEN_DAYS)
59+
.warning(99.5)
60+
.warningDisplay("99.5")))
61+
.timeframe(SLOTimeframe.SEVEN_DAYS)
62+
.targetThreshold(99.0)
63+
.warningThreshold(99.5);
64+
65+
try {
66+
SLOListResponse result = apiInstance.createSLO(body);
67+
System.out.println(result);
68+
} catch (ApiException e) {
69+
System.err.println("Exception when calling ServiceLevelObjectivesApi#createSLO");
70+
System.err.println("Status code: " + e.getCode());
71+
System.err.println("Reason: " + e.getResponseBody());
72+
System.err.println("Response headers: " + e.getResponseHeaders());
73+
e.printStackTrace();
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)