Skip to content

Commit 80692a3

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 2ce6d32 of spec repo
1 parent b8b3790 commit 80692a3

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
@@ -11548,6 +11548,61 @@ components:
1154811548
example: UTC
1154911549
type: string
1155011550
type: object
11551+
SLOCountDefinition:
11552+
description: 'A count-based (metric) SLI specification, composed of three parts:
11553+
the good events formula, the total events formula,
11554+
11555+
and the underlying queries. Usage is not permitted when request payload contains
11556+
`query` field.'
11557+
example:
11558+
good_events_formula: query1 - query2
11559+
queries:
11560+
- data_source: metrics
11561+
name: query1
11562+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11563+
- data_source: metrics
11564+
name: query2
11565+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11566+
total_events_formula: query1
11567+
properties:
11568+
good_events_formula:
11569+
$ref: '#/components/schemas/SLOFormula'
11570+
queries:
11571+
example:
11572+
- data_source: metrics
11573+
name: query1
11574+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11575+
items:
11576+
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
11577+
minItems: 1
11578+
type: array
11579+
total_events_formula:
11580+
$ref: '#/components/schemas/SLOFormula'
11581+
required:
11582+
- good_events_formula
11583+
- total_events_formula
11584+
- queries
11585+
type: object
11586+
SLOCountSpec:
11587+
additionalProperties: false
11588+
description: A metric SLI specification.
11589+
example:
11590+
count:
11591+
good_events_formula: query1 - query2
11592+
queries:
11593+
- data_source: metrics
11594+
name: query1
11595+
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
11596+
- data_source: metrics
11597+
name: query2
11598+
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
11599+
total_events_formula: query1
11600+
properties:
11601+
count:
11602+
$ref: '#/components/schemas/SLOCountDefinition'
11603+
required:
11604+
- count
11605+
type: object
1155111606
SLOCreator:
1155211607
description: The creator of the SLO
1155311608
nullable: true
@@ -12395,8 +12450,16 @@ components:
1239512450
type: string
1239612451
query:
1239712452
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
12453+
description: 'The metric query of good / total events. This is not allowed
12454+
if the `sli_specification` field
12455+
12456+
is used in the same request.'
1239812457
sli_specification:
1239912458
$ref: '#/components/schemas/SLOSliSpec'
12459+
description: 'A generic SLI specification. This is currently used for time-slice
12460+
and count-based (metric) SLOs only.
12461+
12462+
This is not allowed if the `query` field is used in the same request.'
1240012463
tags:
1240112464
description: 'A list of tags associated with this service level objective.
1240212465

@@ -12453,9 +12516,10 @@ components:
1245312516
type: object
1245412517
SLOSliSpec:
1245512518
description: A generic SLI specification. This is currently used for time-slice
12456-
SLOs only.
12519+
and count-based (metric) SLOs only.
1245712520
oneOf:
1245812521
- $ref: '#/components/schemas/SLOTimeSliceSpec'
12522+
- $ref: '#/components/schemas/SLOCountSpec'
1245912523
SLOState:
1246012524
description: State of the SLO.
1246112525
enum:
@@ -13607,13 +13671,15 @@ components:
1360713671
- type
1360813672
type: object
1360913673
ServiceLevelObjectiveQuery:
13610-
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
13674+
description: 'A count-based (metric) SLO query. This field has been superseded
13675+
by `sli_specification` but is retained for backwards compatibility. Note that
1361113676
Datadog only allows the sum by aggregator
1361213677

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

13616-
min of all of those requests.'
13681+
min of all of those requests. Usage is not permitted when request payload
13682+
contains `sli_specification` field.'
1361713683
properties:
1361813684
denominator:
1361913685
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)