- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
서비스 수준 목표(SLO, Service Level Objectives)는 사이트 안정성 엔지니어링 툴킷의 핵심 구성요소이며 애플리케이션 성능에 구체적인 목표를 정의할 수 있는 프레임워크를 제공합니다. 이를 통해 각 팀에서 일관된 고객 경험을 제공하고 기능 개발과 플랫폼 안정성의 균형을 유지하며 내부 및 외부 사용자와의 커뮤니케이션을 개선할 수 있도록 도와줍니다.
POST https://api.ap1.datadoghq.com/api/v1/slohttps://api.datadoghq.eu/api/v1/slohttps://api.ddog-gov.com/api/v1/slohttps://api.datadoghq.com/api/v1/slohttps://api.us3.datadoghq.com/api/v1/slohttps://api.us5.datadoghq.com/api/v1/slo
Create a service level objective object.
This endpoint requires the slos_write
permission.
OAuth apps require the slos_write
authorization scope to access this endpoint.
Service level objective request object.
항목
유형
설명
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
groups
[string]
A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective.
Included in service level objective responses if it is not empty. Optional in
create/update requests for monitor service level objectives, but may only be
used when then length of the monitor_ids
field is one.
monitor_ids
[integer]
A list of monitor IDs that defines the scope of a monitor service level
objective. Required if type is monitor
.
name [required]
string
The name of the service level objective object.
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator [required]
string
A Datadog metric query for total (valid) events.
numerator [required]
string
A Datadog metric query for good events.
sli_specification
<oneOf>
A generic SLI specification. This is currently used for time-slice SLOs only.
Option 1
object
A time-slice SLI specification.
time_slice [required]
object
The time-slice condition, composed of 3 parts: 1. the metric timeseries query, 2. the comparator, and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
comparator [required]
enum
The comparator used to compare the SLI value to the threshold.
Allowed enum values: >,>=,<,<=
query [required]
object
The queries and formula used to calculate the SLI value.
formulas [required]
[object]
A list that contains exactly one formula, as only a single formula may be used in a time-slice SLO.
formula [required]
string
The formula string, which is an expression involving named queries.
queries [required]
[ <oneOf>]
A list of queries that are used to calculate the SLI value.
Option 1
object
A formula and functions metrics query.
aggregator
enum
The aggregation methods available for metrics queries.
Allowed enum values: avg,min,max,sum,last,area,l2norm,percentile
cross_org_uuids
[string]
The source organization UUID for cross organization queries. Feature in Private Beta.
data_source [required]
enum
Data source for metrics queries.
Allowed enum values: metrics
name [required]
string
Name of the query for use in formulas.
query [required]
string
Metrics query definition.
query_interval_seconds
enum
The interval used when querying data, which defines the size of a time slice.
Two values are allowed: 60 (1 minute) and 300 (5 minutes).
If not provided, the value defaults to 300 (5 minutes).
Allowed enum values: 60,300
threshold [required]
double
The threshold value to which each SLI value will be compared.
tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.
target_threshold
double
The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.
thresholds [required]
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
type [required]
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
warning_threshold
double
The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.
{
"type": "time_slice",
"description": "string",
"name": "Example-Service-Level-Objective",
"sli_specification": {
"time_slice": {
"query": {
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "trace.servlet.request{env:prod}"
}
]
},
"comparator": ">",
"threshold": 5
}
},
"tags": [
"env:prod"
],
"thresholds": [
{
"target": 97.0,
"target_display": "97.0",
"timeframe": "7d",
"warning": 98,
"warning_display": "98.0"
}
],
"timeframe": "7d",
"target_threshold": 97.0,
"warning_threshold": 98
}
{
"type": "metric",
"description": "string",
"groups": [
"env:test",
"role:mysql"
],
"monitor_ids": [],
"name": "Example-Service-Level-Objective",
"query": {
"denominator": "sum:httpservice.hits{!code:3xx}.as_count()",
"numerator": "sum:httpservice.hits{code:2xx}.as_count()"
},
"tags": [
"env:prod",
"app:core"
],
"thresholds": [
{
"target": 97.0,
"target_display": "97.0",
"timeframe": "7d",
"warning": 98,
"warning_display": "98.0"
}
],
"timeframe": "7d",
"target_threshold": 97.0,
"warning_threshold": 98
}
OK
A response with one or more service level objective.
항목
유형
설명
data
[object]
An array of service level objective objects.
created_at
int64
Creation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creator
object
Object describing the creator of the shared element.
string
Email of the creator.
handle
string
Handle of the creator.
name
string
Name of the creator.
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
groups
[string]
A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective.
Included in service level objective responses if it is not empty. Optional in
create/update requests for monitor service level objectives, but may only be
used when then length of the monitor_ids
field is one.
id
string
A unique identifier for the service level objective object.
Always included in service level objective responses.
modified_at
int64
Modification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_ids
[integer]
A list of monitor ids that defines the scope of a monitor service level
objective. Required if type is monitor
.
monitor_tags
[string]
The union of monitor tags for all monitors referenced by the monitor_ids
field.
Always included in service level objective responses for monitor-based service level
objectives (but may be empty). Ignored in create/update requests. Does not
affect which monitors are included in the service level objective (that is
determined entirely by the monitor_ids
field).
name [required]
string
The name of the service level objective object.
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator [required]
string
A Datadog metric query for total (valid) events.
numerator [required]
string
A Datadog metric query for good events.
sli_specification
<oneOf>
A generic SLI specification. This is currently used for time-slice SLOs only.
Option 1
object
A time-slice SLI specification.
time_slice [required]
object
The time-slice condition, composed of 3 parts: 1. the metric timeseries query, 2. the comparator, and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
comparator [required]
enum
The comparator used to compare the SLI value to the threshold.
Allowed enum values: >,>=,<,<=
query [required]
object
The queries and formula used to calculate the SLI value.
formulas [required]
[object]
A list that contains exactly one formula, as only a single formula may be used in a time-slice SLO.
formula [required]
string
The formula string, which is an expression involving named queries.
queries [required]
[ <oneOf>]
A list of queries that are used to calculate the SLI value.
Option 1
object
A formula and functions metrics query.
aggregator
enum
The aggregation methods available for metrics queries.
Allowed enum values: avg,min,max,sum,last,area,l2norm,percentile
cross_org_uuids
[string]
The source organization UUID for cross organization queries. Feature in Private Beta.
data_source [required]
enum
Data source for metrics queries.
Allowed enum values: metrics
name [required]
string
Name of the query for use in formulas.
query [required]
string
Metrics query definition.
query_interval_seconds
enum
The interval used when querying data, which defines the size of a time slice.
Two values are allowed: 60 (1 minute) and 300 (5 minutes).
If not provided, the value defaults to 300 (5 minutes).
Allowed enum values: 60,300
threshold [required]
double
The threshold value to which each SLI value will be compared.
tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.
target_threshold
double
The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.
thresholds [required]
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
type [required]
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
warning_threshold
double
The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.
errors
[string]
An array of error messages. Each endpoint documents how/whether this field is used.
metadata
object
The metadata object containing additional information about the list of SLOs.
page
object
The object containing information about the pages of the list of SLOs.
total_count
int64
The total number of resources that could be retrieved ignoring the parameters and filters in the request.
total_filtered_count
int64
The total number of resources that match the parameters and filters in the request. This attribute can be used by a client to determine the total number of pages.
{
"data": [
{
"created_at": "integer",
"creator": {
"email": "string",
"handle": "string",
"name": "string"
},
"description": "string",
"groups": [
"env:prod",
"role:mysql"
],
"id": "string",
"modified_at": "integer",
"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": "query1 - default_zero(query2)"
}
],
"queries": [
[]
]
},
"query_interval_seconds": 300,
"threshold": 5
}
},
"tags": [
"env:prod",
"app:core"
],
"target_threshold": 99.9,
"thresholds": [
{
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
],
"timeframe": "30d",
"type": "metric",
"warning_threshold": 99.95
}
],
"errors": [],
"metadata": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"type": "time_slice",
"description": "string",
"name": "Example-Service-Level-Objective",
"sli_specification": {
"time_slice": {
"query": {
"formulas": [
{
"formula": "query1"
}
],
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "trace.servlet.request{env:prod}"
}
]
},
"comparator": ">",
"threshold": 5
}
},
"tags": [
"env:prod"
],
"thresholds": [
{
"target": 97.0,
"target_display": "97.0",
"timeframe": "7d",
"warning": 98,
"warning_display": "98.0"
}
],
"timeframe": "7d",
"target_threshold": 97.0,
"warning_threshold": 98
}
EOF
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"type": "metric",
"description": "string",
"groups": [
"env:test",
"role:mysql"
],
"monitor_ids": [],
"name": "Example-Service-Level-Objective",
"query": {
"denominator": "sum:httpservice.hits{!code:3xx}.as_count()",
"numerator": "sum:httpservice.hits{code:2xx}.as_count()"
},
"tags": [
"env:prod",
"app:core"
],
"thresholds": [
{
"target": 97.0,
"target_display": "97.0",
"timeframe": "7d",
"warning": 98,
"warning_display": "98.0"
}
],
"timeframe": "7d",
"target_threshold": 97.0,
"warning_threshold": 98
}
EOF
// Create a time-slice SLO object returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.ServiceLevelObjectiveRequest{
Type: datadogV1.SLOTYPE_TIME_SLICE,
Description: *datadog.NewNullableString(datadog.PtrString("string")),
Name: "Example-Service-Level-Objective",
SliSpecification: &datadogV1.SLOSliSpec{
SLOTimeSliceSpec: &datadogV1.SLOTimeSliceSpec{
TimeSlice: datadogV1.SLOTimeSliceCondition{
Query: datadogV1.SLOTimeSliceQuery{
Formulas: []datadogV1.SLOFormula{
{
Formula: "query1",
},
},
Queries: []datadogV1.SLODataSourceQueryDefinition{
datadogV1.SLODataSourceQueryDefinition{
FormulaAndFunctionMetricQueryDefinition: &datadogV1.FormulaAndFunctionMetricQueryDefinition{
DataSource: datadogV1.FORMULAANDFUNCTIONMETRICDATASOURCE_METRICS,
Name: "query1",
Query: "trace.servlet.request{env:prod}",
}},
},
},
Comparator: datadogV1.SLOTIMESLICECOMPARATOR_GREATER,
Threshold: 5,
},
}},
Tags: []string{
"env:prod",
},
Thresholds: []datadogV1.SLOThreshold{
{
Target: 97.0,
TargetDisplay: datadog.PtrString("97.0"),
Timeframe: datadogV1.SLOTIMEFRAME_SEVEN_DAYS,
Warning: datadog.PtrFloat64(98),
WarningDisplay: datadog.PtrString("98.0"),
},
},
Timeframe: datadogV1.SLOTIMEFRAME_SEVEN_DAYS.Ptr(),
TargetThreshold: datadog.PtrFloat64(97.0),
WarningThreshold: datadog.PtrFloat64(98),
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
resp, r, err := api.CreateSLO(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.CreateSLO`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.CreateSLO`:\n%s\n", responseContent)
}
// Create an SLO object returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.ServiceLevelObjectiveRequest{
Type: datadogV1.SLOTYPE_METRIC,
Description: *datadog.NewNullableString(datadog.PtrString("string")),
Groups: []string{
"env:test",
"role:mysql",
},
MonitorIds: []int64{},
Name: "Example-Service-Level-Objective",
Query: &datadogV1.ServiceLevelObjectiveQuery{
Denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
Numerator: "sum:httpservice.hits{code:2xx}.as_count()",
},
Tags: []string{
"env:prod",
"app:core",
},
Thresholds: []datadogV1.SLOThreshold{
{
Target: 97.0,
TargetDisplay: datadog.PtrString("97.0"),
Timeframe: datadogV1.SLOTIMEFRAME_SEVEN_DAYS,
Warning: datadog.PtrFloat64(98),
WarningDisplay: datadog.PtrString("98.0"),
},
},
Timeframe: datadogV1.SLOTIMEFRAME_SEVEN_DAYS.Ptr(),
TargetThreshold: datadog.PtrFloat64(97.0),
WarningThreshold: datadog.PtrFloat64(98),
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
resp, r, err := api.CreateSLO(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.CreateSLO`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.CreateSLO`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create a time-slice SLO object 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.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.SLOTimeSliceComparator;
import com.datadog.api.client.v1.model.SLOTimeSliceCondition;
import com.datadog.api.client.v1.model.SLOTimeSliceQuery;
import com.datadog.api.client.v1.model.SLOTimeSliceSpec;
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.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.TIME_SLICE)
.description("string")
.name("Example-Service-Level-Objective")
.sliSpecification(
new SLOSliSpec(
new SLOTimeSliceSpec()
.timeSlice(
new SLOTimeSliceCondition()
.query(
new SLOTimeSliceQuery()
.formulas(
Collections.singletonList(
new SLOFormula().formula("query1")))
.queries(
Collections.singletonList(
new SLODataSourceQueryDefinition(
new FormulaAndFunctionMetricQueryDefinition()
.dataSource(
FormulaAndFunctionMetricDataSource
.METRICS)
.name("query1")
.query(
"trace.servlet.request{env:prod}")))))
.comparator(SLOTimeSliceComparator.GREATER)
.threshold(5.0))))
.tags(Collections.singletonList("env:prod"))
.thresholds(
Collections.singletonList(
new SLOThreshold()
.target(97.0)
.targetDisplay("97.0")
.timeframe(SLOTimeframe.SEVEN_DAYS)
.warning(98.0)
.warningDisplay("98.0")))
.timeframe(SLOTimeframe.SEVEN_DAYS)
.targetThreshold(97.0)
.warningThreshold(98.0);
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();
}
}
}
// Create an SLO object 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.SLOListResponse;
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.ServiceLevelObjectiveQuery;
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("string")
.groups(Arrays.asList("env:test", "role:mysql"))
.name("Example-Service-Level-Objective")
.query(
new ServiceLevelObjectiveQuery()
.denominator("sum:httpservice.hits{!code:3xx}.as_count()")
.numerator("sum:httpservice.hits{code:2xx}.as_count()"))
.tags(Arrays.asList("env:prod", "app:core"))
.thresholds(
Collections.singletonList(
new SLOThreshold()
.target(97.0)
.targetDisplay("97.0")
.timeframe(SLOTimeframe.SEVEN_DAYS)
.warning(98.0)
.warningDisplay("98.0")))
.timeframe(SLOTimeframe.SEVEN_DAYS)
.targetThreshold(97.0)
.warningThreshold(98.0);
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
# Create a new SLO
thresholds = [
{"timeframe": "7d", "target": 95},
{"timeframe": "30d", "target": 95, "warning": 97},
]
tags = ["app:webserver", "frontend"]
api.ServiceLevelObjective.create(
type="metric",
name="Custom Metric SLO",
description="SLO tracking custom service SLO",
query={
"numerator": "sum:my.custom.metric{type:good}.as_count()",
"denominator": "sum:my.custom.metric{*}.as_count()"
},
tags=tags,
thresholds=thresholds
)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
"""
Create a time-slice SLO object returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
from datadog_api_client.v1.model.formula_and_function_metric_data_source import FormulaAndFunctionMetricDataSource
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
FormulaAndFunctionMetricQueryDefinition,
)
from datadog_api_client.v1.model.service_level_objective_request import ServiceLevelObjectiveRequest
from datadog_api_client.v1.model.slo_formula import SLOFormula
from datadog_api_client.v1.model.slo_threshold import SLOThreshold
from datadog_api_client.v1.model.slo_time_slice_comparator import SLOTimeSliceComparator
from datadog_api_client.v1.model.slo_time_slice_condition import SLOTimeSliceCondition
from datadog_api_client.v1.model.slo_time_slice_query import SLOTimeSliceQuery
from datadog_api_client.v1.model.slo_time_slice_spec import SLOTimeSliceSpec
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
from datadog_api_client.v1.model.slo_type import SLOType
body = ServiceLevelObjectiveRequest(
type=SLOType.TIME_SLICE,
description="string",
name="Example-Service-Level-Objective",
sli_specification=SLOTimeSliceSpec(
time_slice=SLOTimeSliceCondition(
query=SLOTimeSliceQuery(
formulas=[
SLOFormula(
formula="query1",
),
],
queries=[
FormulaAndFunctionMetricQueryDefinition(
data_source=FormulaAndFunctionMetricDataSource.METRICS,
name="query1",
query="trace.servlet.request{env:prod}",
),
],
),
comparator=SLOTimeSliceComparator.GREATER,
threshold=5.0,
),
),
tags=[
"env:prod",
],
thresholds=[
SLOThreshold(
target=97.0,
target_display="97.0",
timeframe=SLOTimeframe.SEVEN_DAYS,
warning=98.0,
warning_display="98.0",
),
],
timeframe=SLOTimeframe.SEVEN_DAYS,
target_threshold=97.0,
warning_threshold=98.0,
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.create_slo(body=body)
print(response)
"""
Create an SLO object returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
from datadog_api_client.v1.model.service_level_objective_query import ServiceLevelObjectiveQuery
from datadog_api_client.v1.model.service_level_objective_request import ServiceLevelObjectiveRequest
from datadog_api_client.v1.model.slo_threshold import SLOThreshold
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
from datadog_api_client.v1.model.slo_type import SLOType
body = ServiceLevelObjectiveRequest(
type=SLOType.METRIC,
description="string",
groups=[
"env:test",
"role:mysql",
],
monitor_ids=[],
name="Example-Service-Level-Objective",
query=ServiceLevelObjectiveQuery(
denominator="sum:httpservice.hits{!code:3xx}.as_count()",
numerator="sum:httpservice.hits{code:2xx}.as_count()",
),
tags=[
"env:prod",
"app:core",
],
thresholds=[
SLOThreshold(
target=97.0,
target_display="97.0",
timeframe=SLOTimeframe.SEVEN_DAYS,
warning=98.0,
warning_display="98.0",
),
],
timeframe=SLOTimeframe.SEVEN_DAYS,
target_threshold=97.0,
warning_threshold=98.0,
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.create_slo(body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
# Create a new SLO
thresholds = [
{ timeframe: '7d', target: 95 },
{ timeframe: '30d', target: 95, warning: 97 }
]
tags = ['app:webserver', 'frontend']
dog.create_service_level_objective(
type: 'metric',
name: 'Custom Metric SLO',
description: 'SLO tracking custom service SLO',
numerator: 'sum:my.custom.metric{type:good}.as_count()',
denominator: 'sum:my.custom.metric{*}.as_count()',
tags: tags,
thresholds: thresholds
)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
# Create a time-slice SLO object returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
body = DatadogAPIClient::V1::ServiceLevelObjectiveRequest.new({
type: DatadogAPIClient::V1::SLOType::TIME_SLICE,
description: "string",
name: "Example-Service-Level-Objective",
sli_specification: DatadogAPIClient::V1::SLOTimeSliceSpec.new({
time_slice: DatadogAPIClient::V1::SLOTimeSliceCondition.new({
query: DatadogAPIClient::V1::SLOTimeSliceQuery.new({
formulas: [
DatadogAPIClient::V1::SLOFormula.new({
formula: "query1",
}),
],
queries: [
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
name: "query1",
query: "trace.servlet.request{env:prod}",
}),
],
}),
comparator: DatadogAPIClient::V1::SLOTimeSliceComparator::GREATER,
threshold: 5,
}),
}),
tags: [
"env:prod",
],
thresholds: [
DatadogAPIClient::V1::SLOThreshold.new({
target: 97.0,
target_display: "97.0",
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
warning: 98,
warning_display: "98.0",
}),
],
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
target_threshold: 97.0,
warning_threshold: 98,
})
p api_instance.create_slo(body)
# Create an SLO object returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
body = DatadogAPIClient::V1::ServiceLevelObjectiveRequest.new({
type: DatadogAPIClient::V1::SLOType::METRIC,
description: "string",
groups: [
"env:test",
"role:mysql",
],
monitor_ids: [],
name: "Example-Service-Level-Objective",
query: DatadogAPIClient::V1::ServiceLevelObjectiveQuery.new({
denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
numerator: "sum:httpservice.hits{code:2xx}.as_count()",
}),
tags: [
"env:prod",
"app:core",
],
thresholds: [
DatadogAPIClient::V1::SLOThreshold.new({
target: 97.0,
target_display: "97.0",
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
warning: 98,
warning_display: "98.0",
}),
],
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
target_threshold: 97.0,
warning_threshold: 98,
})
p api_instance.create_slo(body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Create a time-slice SLO object returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricDataSource;
use datadog_api_client::datadogV1::model::FormulaAndFunctionMetricQueryDefinition;
use datadog_api_client::datadogV1::model::SLODataSourceQueryDefinition;
use datadog_api_client::datadogV1::model::SLOFormula;
use datadog_api_client::datadogV1::model::SLOSliSpec;
use datadog_api_client::datadogV1::model::SLOThreshold;
use datadog_api_client::datadogV1::model::SLOTimeSliceComparator;
use datadog_api_client::datadogV1::model::SLOTimeSliceCondition;
use datadog_api_client::datadogV1::model::SLOTimeSliceQuery;
use datadog_api_client::datadogV1::model::SLOTimeSliceSpec;
use datadog_api_client::datadogV1::model::SLOTimeframe;
use datadog_api_client::datadogV1::model::SLOType;
use datadog_api_client::datadogV1::model::ServiceLevelObjectiveRequest;
#[tokio::main]
async fn main() {
let body = ServiceLevelObjectiveRequest::new(
"Example-Service-Level-Objective".to_string(),
vec![SLOThreshold::new(97.0, SLOTimeframe::SEVEN_DAYS)
.target_display("97.0".to_string())
.warning(98.0 as f64)
.warning_display("98.0".to_string())],
SLOType::TIME_SLICE,
)
.description(Some("string".to_string()))
.sli_specification(SLOSliSpec::SLOTimeSliceSpec(Box::new(
SLOTimeSliceSpec::new(SLOTimeSliceCondition::new(
SLOTimeSliceComparator::GREATER,
SLOTimeSliceQuery::new(
vec![SLOFormula::new("query1".to_string())],
vec![
SLODataSourceQueryDefinition::FormulaAndFunctionMetricQueryDefinition(
Box::new(FormulaAndFunctionMetricQueryDefinition::new(
FormulaAndFunctionMetricDataSource::METRICS,
"query1".to_string(),
"trace.servlet.request{env:prod}".to_string(),
)),
),
],
),
5.0,
)),
)))
.tags(vec!["env:prod".to_string()])
.target_threshold(97.0 as f64)
.timeframe(SLOTimeframe::SEVEN_DAYS)
.warning_threshold(98.0 as f64);
let configuration = datadog::Configuration::new();
let api = ServiceLevelObjectivesAPI::with_config(configuration);
let resp = api.create_slo(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
// Create an SLO object returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
use datadog_api_client::datadogV1::model::SLOThreshold;
use datadog_api_client::datadogV1::model::SLOTimeframe;
use datadog_api_client::datadogV1::model::SLOType;
use datadog_api_client::datadogV1::model::ServiceLevelObjectiveQuery;
use datadog_api_client::datadogV1::model::ServiceLevelObjectiveRequest;
#[tokio::main]
async fn main() {
let body = ServiceLevelObjectiveRequest::new(
"Example-Service-Level-Objective".to_string(),
vec![SLOThreshold::new(97.0, SLOTimeframe::SEVEN_DAYS)
.target_display("97.0".to_string())
.warning(98.0 as f64)
.warning_display("98.0".to_string())],
SLOType::METRIC,
)
.description(Some("string".to_string()))
.groups(vec!["env:test".to_string(), "role:mysql".to_string()])
.monitor_ids(vec![])
.query(ServiceLevelObjectiveQuery::new(
"sum:httpservice.hits{!code:3xx}.as_count()".to_string(),
"sum:httpservice.hits{code:2xx}.as_count()".to_string(),
))
.tags(vec!["env:prod".to_string(), "app:core".to_string()])
.target_threshold(97.0 as f64)
.timeframe(SLOTimeframe::SEVEN_DAYS)
.warning_threshold(98.0 as f64);
let configuration = datadog::Configuration::new();
let api = ServiceLevelObjectivesAPI::with_config(configuration);
let resp = api.create_slo(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Create a time-slice SLO object returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);
const params: v1.ServiceLevelObjectivesApiCreateSLORequest = {
body: {
type: "time_slice",
description: "string",
name: "Example-Service-Level-Objective",
sliSpecification: {
timeSlice: {
query: {
formulas: [
{
formula: "query1",
},
],
queries: [
{
dataSource: "metrics",
name: "query1",
query: "trace.servlet.request{env:prod}",
},
],
},
comparator: ">",
threshold: 5,
},
},
tags: ["env:prod"],
thresholds: [
{
target: 97.0,
targetDisplay: "97.0",
timeframe: "7d",
warning: 98,
warningDisplay: "98.0",
},
],
timeframe: "7d",
targetThreshold: 97.0,
warningThreshold: 98,
},
};
apiInstance
.createSLO(params)
.then((data: v1.SLOListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
/**
* Create an SLO object returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);
const params: v1.ServiceLevelObjectivesApiCreateSLORequest = {
body: {
type: "metric",
description: "string",
groups: ["env:test", "role:mysql"],
monitorIds: [],
name: "Example-Service-Level-Objective",
query: {
denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
numerator: "sum:httpservice.hits{code:2xx}.as_count()",
},
tags: ["env:prod", "app:core"],
thresholds: [
{
target: 97.0,
targetDisplay: "97.0",
timeframe: "7d",
warning: 98,
warningDisplay: "98.0",
},
],
timeframe: "7d",
targetThreshold: 97.0,
warningThreshold: 98,
},
};
apiInstance
.createSLO(params)
.then((data: v1.SLOListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v1/slo/searchhttps://api.datadoghq.eu/api/v1/slo/searchhttps://api.ddog-gov.com/api/v1/slo/searchhttps://api.datadoghq.com/api/v1/slo/searchhttps://api.us3.datadoghq.com/api/v1/slo/searchhttps://api.us5.datadoghq.com/api/v1/slo/search
Get a list of service level objective objects for your organization.
This endpoint requires the slos_read
permission.
OAuth apps require the slos_read
authorization scope to access this endpoint.
이름
유형
설명
query
string
The query string to filter results based on SLO names.
Some examples of queries include service:<service-name>
and <slo-name>
.
page[size]
integer
The number of files to return in the response [default=10]
.
page[number]
integer
The identifier of the first page to return. This parameter is used for the pagination feature [default=0]
.
include_facets
boolean
Whether or not to return facet information in the response [default=false]
.
OK
A search SLO response containing results from the search query.
항목
유형
설명
data
object
Data from search SLO response.
attributes
object
Attributes
facets
object
Facets
all_tags
[object]
All tags associated with an SLO.
count
int64
Count
name
string
Facet
creator_name
[object]
Creator of an SLO.
count
int64
Count
name
string
Facet
env_tags
[object]
Tags with the env
tag key.
count
int64
Count
name
string
Facet
service_tags
[object]
Tags with the service
tag key.
count
int64
Count
name
string
Facet
slo_type
[object]
Type of SLO.
count
int64
Count
name
double
Facet
target
[object]
SLO Target
count
int64
Count
name
double
Facet
team_tags
[object]
Tags with the team
tag key.
count
int64
Count
name
string
Facet
timeframe
[object]
Timeframes of SLOs.
count
int64
Count
name
string
Facet
slos
[object]
SLOs
data
object
A service level objective ID and attributes.
attributes
object
A service level objective object includes a service level indicator, thresholds
for one or more timeframes, and metadata (name
, description
, and tags
).
all_tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty).
created_at
int64
Creation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creator
object
The creator of the SLO
string
Email of the creator.
id
int64
User ID of the creator.
name
string
Name of the creator.
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
env_tags
[string]
Tags with the env
tag key.
groups
[string]
A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective. Included in service level objective responses if it is not empty.
modified_at
int64
Modification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_ids
[integer]
A list of monitor ids that defines the scope of a monitor service level objective.
name
string
The name of the service level objective object.
overall_status
[object]
calculated status and error budget remaining.
error
string
Error message if SLO status or error budget could not be calculated.
error_budget_remaining
double
Remaining error budget of the SLO in percentage.
indexed_at
int64
timestamp (UNIX time in seconds) of when the SLO status and error budget were calculated.
raw_error_budget_remaining
object
Error budget remaining for an SLO.
unit
string
Error budget remaining unit.
value
double
Error budget remaining value.
span_precision
int64
The amount of decimal places the SLI value is accurate to.
state
enum
State of the SLO.
Allowed enum values: breached,warning,ok,no_data
status
double
The status of the SLO.
target
double
The target of the SLO.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator
string
A Datadog metric query for total (valid) events.
metrics
[string]
Metric names used in the query's numerator and denominator. This field will return null and will be implemented in the next version of this endpoint.
numerator
string
A Datadog metric query for good events.
service_tags
[string]
Tags with the service
tag key.
slo_type
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
status
object
Status of the SLO's primary timeframe.
calculation_error
string
Error message if SLO status or error budget could not be calculated.
error_budget_remaining
double
Remaining error budget of the SLO in percentage.
indexed_at
int64
timestamp (UNIX time in seconds) of when the SLO status and error budget were calculated.
raw_error_budget_remaining
object
Error budget remaining for an SLO.
unit
string
Error budget remaining unit.
value
double
Error budget remaining value.
sli
double
The current service level indicator (SLI) of the SLO, also known as 'status'. This is a percentage value from 0-100 (inclusive).
span_precision
int64
The number of decimal places the SLI value is accurate to.
state
enum
State of the SLO.
Allowed enum values: breached,warning,ok,no_data
team_tags
[string]
Tags with the team
tag key.
thresholds
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options.
Allowed enum values: 7d,30d,90d
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
id
string
A unique identifier for the service level objective object.
Always included in service level objective responses.
type
string
The type of the object, must be slo
.
type
string
Type of service level objective result.
links
object
Pagination links.
first
string
Link to last page.
last
string
Link to first page.
next
string
Link to the next page.
prev
string
Link to previous page.
self
string
Link to current page.
meta
object
Searches metadata returned by the API.
pagination
object
Pagination metadata returned by the API.
first_number
int64
The first number.
last_number
int64
The last number.
next_number
int64
The next number.
number
int64
The page number.
prev_number
int64
The previous page number.
size
int64
The size of the response.
total
int64
The total number of SLOs in the response.
type
string
Type of pagination.
{
"data": {
"attributes": {
"facets": {
"all_tags": [
{
"count": "integer",
"name": "string"
}
],
"creator_name": [
{
"count": "integer",
"name": "string"
}
],
"env_tags": [
{
"count": "integer",
"name": "string"
}
],
"service_tags": [
{
"count": "integer",
"name": "string"
}
],
"slo_type": [
{
"count": "integer",
"name": "number"
}
],
"target": [
{
"count": "integer",
"name": "number"
}
],
"team_tags": [
{
"count": "integer",
"name": "string"
}
],
"timeframe": [
{
"count": "integer",
"name": "string"
}
]
},
"slos": [
{
"data": {
"attributes": {
"all_tags": [
"env:prod",
"app:core"
],
"created_at": "integer",
"creator": {
"email": "string",
"id": "integer",
"name": "string"
},
"description": "string",
"env_tags": [],
"groups": [
"env:prod",
"role:mysql"
],
"modified_at": "integer",
"monitor_ids": [],
"name": "Custom Metric SLO",
"overall_status": [
{
"error": "string",
"error_budget_remaining": 100,
"indexed_at": 1662496260,
"raw_error_budget_remaining": {
"unit": "requests",
"value": 60
},
"span_precision": 2,
"state": "ok",
"status": 100,
"target": 99,
"timeframe": "30d"
}
],
"query": {
"denominator": "sum:my.custom.metric{*}.as_count()",
"metrics": [
"my.custom.metric",
"my.other.custom.metric"
],
"numerator": "sum:my.custom.metric{type:good}.as_count()"
},
"service_tags": [],
"slo_type": "metric",
"status": {
"calculation_error": "string",
"error_budget_remaining": 100,
"indexed_at": 1662496260,
"raw_error_budget_remaining": {
"unit": "requests",
"value": 60
},
"sli": 100,
"span_precision": 2,
"state": "ok"
},
"team_tags": [],
"thresholds": [
{
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
]
},
"id": "string",
"type": "string"
}
}
]
},
"type": ""
},
"links": {
"first": "string",
"last": "string",
"next": "string",
"prev": "string",
"self": "string"
},
"meta": {
"pagination": {
"first_number": "integer",
"last_number": "integer",
"next_number": "integer",
"number": "integer",
"prev_number": "integer",
"size": "integer",
"total": "integer",
"type": "string"
}
}
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo/search" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Search for SLOs returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
# there is a valid "slo" in the system
SLO_DATA_0_NAME = environ["SLO_DATA_0_NAME"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.search_slo(
query=SLO_DATA_0_NAME,
page_size=20,
page_number=0,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Search for SLOs returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
# there is a valid "slo" in the system
SLO_DATA_0_NAME = ENV["SLO_DATA_0_NAME"]
opts = {
query: SLO_DATA_0_NAME,
page_size: 20,
page_number: 0,
}
p api_instance.search_slo(opts)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Search for SLOs returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
// there is a valid "slo" in the system
SloData0Name := os.Getenv("SLO_DATA_0_NAME")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
resp, r, err := api.SearchSLO(ctx, *datadogV1.NewSearchSLOOptionalParameters().WithQuery(SloData0Name).WithPageSize(20).WithPageNumber(0))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.SearchSLO`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.SearchSLO`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Search for SLOs 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.api.ServiceLevelObjectivesApi.SearchSLOOptionalParameters;
import com.datadog.api.client.v1.model.SearchSLOResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
// there is a valid "slo" in the system
String SLO_DATA_0_NAME = System.getenv("SLO_DATA_0_NAME");
try {
SearchSLOResponse result =
apiInstance.searchSLO(
new SearchSLOOptionalParameters()
.query(SLO_DATA_0_NAME)
.pageSize(20L)
.pageNumber(0L));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ServiceLevelObjectivesApi#searchSLO");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Search for SLOs returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::SearchSLOOptionalParams;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
#[tokio::main]
async fn main() {
// there is a valid "slo" in the system
let slo_data_0_name = std::env::var("SLO_DATA_0_NAME").unwrap();
let configuration = datadog::Configuration::new();
let api = ServiceLevelObjectivesAPI::with_config(configuration);
let resp = api
.search_slo(
SearchSLOOptionalParams::default()
.query(slo_data_0_name.clone())
.page_size(20)
.page_number(0),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Search for SLOs returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);
// there is a valid "slo" in the system
const SLO_DATA_0_NAME = process.env.SLO_DATA_0_NAME as string;
const params: v1.ServiceLevelObjectivesApiSearchSLORequest = {
query: SLO_DATA_0_NAME,
pageSize: 20,
pageNumber: 0,
};
apiInstance
.searchSLO(params)
.then((data: v1.SearchSLOResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v1/slohttps://api.datadoghq.eu/api/v1/slohttps://api.ddog-gov.com/api/v1/slohttps://api.datadoghq.com/api/v1/slohttps://api.us3.datadoghq.com/api/v1/slohttps://api.us5.datadoghq.com/api/v1/slo
Get a list of service level objective objects for your organization.
This endpoint requires the slos_read
permission.
OAuth apps require the slos_read
authorization scope to access this endpoint.
이름
유형
설명
ids
string
A comma separated list of the IDs of the service level objectives objects.
query
string
The query string to filter results based on SLO names.
tags_query
string
The query string to filter results based on a single SLO tag.
metrics_query
string
The query string to filter results based on SLO numerator and denominator.
limit
integer
The number of SLOs to return in the response.
offset
integer
The specific offset to use as the beginning of the returned response.
OK
A response with one or more service level objective.
항목
유형
설명
data
[object]
An array of service level objective objects.
created_at
int64
Creation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creator
object
Object describing the creator of the shared element.
string
Email of the creator.
handle
string
Handle of the creator.
name
string
Name of the creator.
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
groups
[string]
A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective.
Included in service level objective responses if it is not empty. Optional in
create/update requests for monitor service level objectives, but may only be
used when then length of the monitor_ids
field is one.
id
string
A unique identifier for the service level objective object.
Always included in service level objective responses.
modified_at
int64
Modification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_ids
[integer]
A list of monitor ids that defines the scope of a monitor service level
objective. Required if type is monitor
.
monitor_tags
[string]
The union of monitor tags for all monitors referenced by the monitor_ids
field.
Always included in service level objective responses for monitor-based service level
objectives (but may be empty). Ignored in create/update requests. Does not
affect which monitors are included in the service level objective (that is
determined entirely by the monitor_ids
field).
name [required]
string
The name of the service level objective object.
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator [required]
string
A Datadog metric query for total (valid) events.
numerator [required]
string
A Datadog metric query for good events.
sli_specification
<oneOf>
A generic SLI specification. This is currently used for time-slice SLOs only.
Option 1
object
A time-slice SLI specification.
time_slice [required]
object
The time-slice condition, composed of 3 parts: 1. the metric timeseries query, 2. the comparator, and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
comparator [required]
enum
The comparator used to compare the SLI value to the threshold.
Allowed enum values: >,>=,<,<=
query [required]
object
The queries and formula used to calculate the SLI value.
formulas [required]
[object]
A list that contains exactly one formula, as only a single formula may be used in a time-slice SLO.
formula [required]
string
The formula string, which is an expression involving named queries.
queries [required]
[ <oneOf>]
A list of queries that are used to calculate the SLI value.
Option 1
object
A formula and functions metrics query.
aggregator
enum
The aggregation methods available for metrics queries.
Allowed enum values: avg,min,max,sum,last,area,l2norm,percentile
cross_org_uuids
[string]
The source organization UUID for cross organization queries. Feature in Private Beta.
data_source [required]
enum
Data source for metrics queries.
Allowed enum values: metrics
name [required]
string
Name of the query for use in formulas.
query [required]
string
Metrics query definition.
query_interval_seconds
enum
The interval used when querying data, which defines the size of a time slice.
Two values are allowed: 60 (1 minute) and 300 (5 minutes).
If not provided, the value defaults to 300 (5 minutes).
Allowed enum values: 60,300
threshold [required]
double
The threshold value to which each SLI value will be compared.
tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.
target_threshold
double
The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.
thresholds [required]
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
type [required]
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
warning_threshold
double
The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.
errors
[string]
An array of error messages. Each endpoint documents how/whether this field is used.
metadata
object
The metadata object containing additional information about the list of SLOs.
page
object
The object containing information about the pages of the list of SLOs.
total_count
int64
The total number of resources that could be retrieved ignoring the parameters and filters in the request.
total_filtered_count
int64
The total number of resources that match the parameters and filters in the request. This attribute can be used by a client to determine the total number of pages.
{
"data": [
{
"created_at": "integer",
"creator": {
"email": "string",
"handle": "string",
"name": "string"
},
"description": "string",
"groups": [
"env:prod",
"role:mysql"
],
"id": "string",
"modified_at": "integer",
"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": "query1 - default_zero(query2)"
}
],
"queries": [
[]
]
},
"query_interval_seconds": 300,
"threshold": 5
}
},
"tags": [
"env:prod",
"app:core"
],
"target_threshold": 99.9,
"thresholds": [
{
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
],
"timeframe": "30d",
"type": "metric",
"warning_threshold": 99.95
}
],
"errors": [],
"metadata": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Not Found
Error response object.
{
"errors": [
"Bad Request"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get all SLOs returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
# there is a valid "slo" in the system
SLO_DATA_0_ID = environ["SLO_DATA_0_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.list_slos(
ids=SLO_DATA_0_ID,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all SLOs returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
# there is a valid "slo" in the system
SLO_DATA_0_ID = ENV["SLO_DATA_0_ID"]
opts = {
ids: SLO_DATA_0_ID,
}
p api_instance.list_slos(opts)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
# Search with a list of IDs
slo_ids = ['<YOUR_SLO_ID>']
dog.search_service_level_objective(slo_ids: slo_ids, offset: 0)
# Search with a query on your SLO Name.
query = 'my team'
dog.search_service_level_objective(query: query, offset: 0)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get all SLOs returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
// there is a valid "slo" in the system
SloData0ID := os.Getenv("SLO_DATA_0_ID")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
resp, r, err := api.ListSLOs(ctx, *datadogV1.NewListSLOsOptionalParameters().WithIds(SloData0ID))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.ListSLOs`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.ListSLOs`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all SLOs 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.api.ServiceLevelObjectivesApi.ListSLOsOptionalParameters;
import com.datadog.api.client.v1.model.SLOListResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
// there is a valid "slo" in the system
String SLO_DATA_0_ID = System.getenv("SLO_DATA_0_ID");
try {
SLOListResponse result =
apiInstance.listSLOs(new ListSLOsOptionalParameters().ids(SLO_DATA_0_ID));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ServiceLevelObjectivesApi#listSLOs");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
# Search with a list of IDs
slo_ids = ["<YOUR_SLO_ID>", "<YOUR_SLO_ID>"]
api.ServiceLevelObjective.get_all(ids=slo_ids, offset=0)
# Search with a query on your SLO Name.
query = "my team"
api.ServiceLevelObjective.get_all(query=query, offset=0)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
// Get all SLOs returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::ListSLOsOptionalParams;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
#[tokio::main]
async fn main() {
// there is a valid "slo" in the system
let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = ServiceLevelObjectivesAPI::with_config(configuration);
let resp = api
.list_slos(ListSLOsOptionalParams::default().ids(slo_data_0_id.clone()))
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Get all SLOs returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);
// there is a valid "slo" in the system
const SLO_DATA_0_ID = process.env.SLO_DATA_0_ID as string;
const params: v1.ServiceLevelObjectivesApiListSLOsRequest = {
ids: SLO_DATA_0_ID,
};
apiInstance
.listSLOs(params)
.then((data: v1.SLOListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
PUT https://api.ap1.datadoghq.com/api/v1/slo/{slo_id}https://api.datadoghq.eu/api/v1/slo/{slo_id}https://api.ddog-gov.com/api/v1/slo/{slo_id}https://api.datadoghq.com/api/v1/slo/{slo_id}https://api.us3.datadoghq.com/api/v1/slo/{slo_id}https://api.us5.datadoghq.com/api/v1/slo/{slo_id}
Update the specified service level objective object.
This endpoint requires the slos_write
permission.
OAuth apps require the slos_write
authorization scope to access this endpoint.
이름
유형
설명
slo_id [required]
string
The ID of the service level objective object.
The edited service level objective request object.
항목
유형
설명
created_at
int64
Creation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creator
object
Object describing the creator of the shared element.
string
Email of the creator.
handle
string
Handle of the creator.
name
string
Name of the creator.
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
groups
[string]
A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective.
Included in service level objective responses if it is not empty. Optional in
create/update requests for monitor service level objectives, but may only be
used when then length of the monitor_ids
field is one.
id
string
A unique identifier for the service level objective object.
Always included in service level objective responses.
modified_at
int64
Modification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_ids
[integer]
A list of monitor ids that defines the scope of a monitor service level
objective. Required if type is monitor
.
monitor_tags
[string]
The union of monitor tags for all monitors referenced by the monitor_ids
field.
Always included in service level objective responses for monitor-based service level
objectives (but may be empty). Ignored in create/update requests. Does not
affect which monitors are included in the service level objective (that is
determined entirely by the monitor_ids
field).
name [required]
string
The name of the service level objective object.
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator [required]
string
A Datadog metric query for total (valid) events.
numerator [required]
string
A Datadog metric query for good events.
sli_specification
<oneOf>
A generic SLI specification. This is currently used for time-slice SLOs only.
Option 1
object
A time-slice SLI specification.
time_slice [required]
object
The time-slice condition, composed of 3 parts: 1. the metric timeseries query, 2. the comparator, and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
comparator [required]
enum
The comparator used to compare the SLI value to the threshold.
Allowed enum values: >,>=,<,<=
query [required]
object
The queries and formula used to calculate the SLI value.
formulas [required]
[object]
A list that contains exactly one formula, as only a single formula may be used in a time-slice SLO.
formula [required]
string
The formula string, which is an expression involving named queries.
queries [required]
[ <oneOf>]
A list of queries that are used to calculate the SLI value.
Option 1
object
A formula and functions metrics query.
aggregator
enum
The aggregation methods available for metrics queries.
Allowed enum values: avg,min,max,sum,last,area,l2norm,percentile
cross_org_uuids
[string]
The source organization UUID for cross organization queries. Feature in Private Beta.
data_source [required]
enum
Data source for metrics queries.
Allowed enum values: metrics
name [required]
string
Name of the query for use in formulas.
query [required]
string
Metrics query definition.
query_interval_seconds
enum
The interval used when querying data, which defines the size of a time slice.
Two values are allowed: 60 (1 minute) and 300 (5 minutes).
If not provided, the value defaults to 300 (5 minutes).
Allowed enum values: 60,300
threshold [required]
double
The threshold value to which each SLI value will be compared.
tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.
target_threshold
double
The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.
thresholds [required]
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
type [required]
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
warning_threshold
double
The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.
{
"type": "metric",
"name": "Custom Metric SLO",
"thresholds": [
{
"target": 97.0,
"timeframe": "7d",
"warning": 98.0
}
],
"timeframe": "7d",
"target_threshold": 97.0,
"warning_threshold": 98,
"query": {
"numerator": "sum:httpservice.hits{code:2xx}.as_count()",
"denominator": "sum:httpservice.hits{!code:3xx}.as_count()"
}
}
OK
A response with one or more service level objective.
항목
유형
설명
data
[object]
An array of service level objective objects.
created_at
int64
Creation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creator
object
Object describing the creator of the shared element.
string
Email of the creator.
handle
string
Handle of the creator.
name
string
Name of the creator.
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
groups
[string]
A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective.
Included in service level objective responses if it is not empty. Optional in
create/update requests for monitor service level objectives, but may only be
used when then length of the monitor_ids
field is one.
id
string
A unique identifier for the service level objective object.
Always included in service level objective responses.
modified_at
int64
Modification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_ids
[integer]
A list of monitor ids that defines the scope of a monitor service level
objective. Required if type is monitor
.
monitor_tags
[string]
The union of monitor tags for all monitors referenced by the monitor_ids
field.
Always included in service level objective responses for monitor-based service level
objectives (but may be empty). Ignored in create/update requests. Does not
affect which monitors are included in the service level objective (that is
determined entirely by the monitor_ids
field).
name [required]
string
The name of the service level objective object.
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator [required]
string
A Datadog metric query for total (valid) events.
numerator [required]
string
A Datadog metric query for good events.
sli_specification
<oneOf>
A generic SLI specification. This is currently used for time-slice SLOs only.
Option 1
object
A time-slice SLI specification.
time_slice [required]
object
The time-slice condition, composed of 3 parts: 1. the metric timeseries query, 2. the comparator, and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
comparator [required]
enum
The comparator used to compare the SLI value to the threshold.
Allowed enum values: >,>=,<,<=
query [required]
object
The queries and formula used to calculate the SLI value.
formulas [required]
[object]
A list that contains exactly one formula, as only a single formula may be used in a time-slice SLO.
formula [required]
string
The formula string, which is an expression involving named queries.
queries [required]
[ <oneOf>]
A list of queries that are used to calculate the SLI value.
Option 1
object
A formula and functions metrics query.
aggregator
enum
The aggregation methods available for metrics queries.
Allowed enum values: avg,min,max,sum,last,area,l2norm,percentile
cross_org_uuids
[string]
The source organization UUID for cross organization queries. Feature in Private Beta.
data_source [required]
enum
Data source for metrics queries.
Allowed enum values: metrics
name [required]
string
Name of the query for use in formulas.
query [required]
string
Metrics query definition.
query_interval_seconds
enum
The interval used when querying data, which defines the size of a time slice.
Two values are allowed: 60 (1 minute) and 300 (5 minutes).
If not provided, the value defaults to 300 (5 minutes).
Allowed enum values: 60,300
threshold [required]
double
The threshold value to which each SLI value will be compared.
tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.
target_threshold
double
The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.
thresholds [required]
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
type [required]
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
warning_threshold
double
The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.
errors
[string]
An array of error messages. Each endpoint documents how/whether this field is used.
metadata
object
The metadata object containing additional information about the list of SLOs.
page
object
The object containing information about the pages of the list of SLOs.
total_count
int64
The total number of resources that could be retrieved ignoring the parameters and filters in the request.
total_filtered_count
int64
The total number of resources that match the parameters and filters in the request. This attribute can be used by a client to determine the total number of pages.
{
"data": [
{
"created_at": "integer",
"creator": {
"email": "string",
"handle": "string",
"name": "string"
},
"description": "string",
"groups": [
"env:prod",
"role:mysql"
],
"id": "string",
"modified_at": "integer",
"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": "query1 - default_zero(query2)"
}
],
"queries": [
[]
]
},
"query_interval_seconds": 300,
"threshold": 5
}
},
"tags": [
"env:prod",
"app:core"
],
"target_threshold": 99.9,
"thresholds": [
{
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
],
"timeframe": "30d",
"type": "metric",
"warning_threshold": 99.95
}
],
"errors": [],
"metadata": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Not Found
Error response object.
{
"errors": [
"Bad Request"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export slo_id="CHANGE_ME"
# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo/${slo_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"type": "metric",
"name": "Custom Metric SLO",
"thresholds": [
{
"target": 97.0,
"timeframe": "7d",
"warning": 98.0
}
],
"timeframe": "7d",
"target_threshold": 97.0,
"warning_threshold": 98,
"query": {
"numerator": "sum:httpservice.hits{code:2xx}.as_count()",
"denominator": "sum:httpservice.hits{!code:3xx}.as_count()"
}
}
EOF
// Update an SLO returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
// there is a valid "slo" in the system
SloData0ID := os.Getenv("SLO_DATA_0_ID")
SloData0Name := os.Getenv("SLO_DATA_0_NAME")
body := datadogV1.ServiceLevelObjective{
Type: datadogV1.SLOTYPE_METRIC,
Name: SloData0Name,
Thresholds: []datadogV1.SLOThreshold{
{
Target: 97.0,
Timeframe: datadogV1.SLOTIMEFRAME_SEVEN_DAYS,
Warning: datadog.PtrFloat64(98.0),
},
},
Timeframe: datadogV1.SLOTIMEFRAME_SEVEN_DAYS.Ptr(),
TargetThreshold: datadog.PtrFloat64(97.0),
WarningThreshold: datadog.PtrFloat64(98),
Query: &datadogV1.ServiceLevelObjectiveQuery{
Numerator: "sum:httpservice.hits{code:2xx}.as_count()",
Denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
resp, r, err := api.UpdateSLO(ctx, SloData0ID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.UpdateSLO`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.UpdateSLO`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Update an SLO 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.SLOListResponse;
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.ServiceLevelObjective;
import com.datadog.api.client.v1.model.ServiceLevelObjectiveQuery;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
// there is a valid "slo" in the system
String SLO_DATA_0_ID = System.getenv("SLO_DATA_0_ID");
String SLO_DATA_0_NAME = System.getenv("SLO_DATA_0_NAME");
ServiceLevelObjective body =
new ServiceLevelObjective()
.type(SLOType.METRIC)
.name(SLO_DATA_0_NAME)
.thresholds(
Collections.singletonList(
new SLOThreshold()
.target(97.0)
.timeframe(SLOTimeframe.SEVEN_DAYS)
.warning(98.0)))
.timeframe(SLOTimeframe.SEVEN_DAYS)
.targetThreshold(97.0)
.warningThreshold(98.0)
.query(
new ServiceLevelObjectiveQuery()
.numerator("sum:httpservice.hits{code:2xx}.as_count()")
.denominator("sum:httpservice.hits{!code:3xx}.as_count()"));
try {
SLOListResponse result = apiInstance.updateSLO(SLO_DATA_0_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ServiceLevelObjectivesApi#updateSLO");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Update an SLO returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
from datadog_api_client.v1.model.service_level_objective import ServiceLevelObjective
from datadog_api_client.v1.model.service_level_objective_query import ServiceLevelObjectiveQuery
from datadog_api_client.v1.model.slo_threshold import SLOThreshold
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe
from datadog_api_client.v1.model.slo_type import SLOType
# there is a valid "slo" in the system
SLO_DATA_0_ID = environ["SLO_DATA_0_ID"]
SLO_DATA_0_NAME = environ["SLO_DATA_0_NAME"]
body = ServiceLevelObjective(
type=SLOType.METRIC,
name=SLO_DATA_0_NAME,
thresholds=[
SLOThreshold(
target=97.0,
timeframe=SLOTimeframe.SEVEN_DAYS,
warning=98.0,
),
],
timeframe=SLOTimeframe.SEVEN_DAYS,
target_threshold=97.0,
warning_threshold=98.0,
query=ServiceLevelObjectiveQuery(
numerator="sum:httpservice.hits{code:2xx}.as_count()",
denominator="sum:httpservice.hits{!code:3xx}.as_count()",
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.update_slo(slo_id=SLO_DATA_0_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Update an SLO returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
# there is a valid "slo" in the system
SLO_DATA_0_ID = ENV["SLO_DATA_0_ID"]
SLO_DATA_0_NAME = ENV["SLO_DATA_0_NAME"]
body = DatadogAPIClient::V1::ServiceLevelObjective.new({
type: DatadogAPIClient::V1::SLOType::METRIC,
name: SLO_DATA_0_NAME,
thresholds: [
DatadogAPIClient::V1::SLOThreshold.new({
target: 97.0,
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
warning: 98.0,
}),
],
timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
target_threshold: 97.0,
warning_threshold: 98,
query: DatadogAPIClient::V1::ServiceLevelObjectiveQuery.new({
numerator: "sum:httpservice.hits{code:2xx}.as_count()",
denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
}),
})
p api_instance.update_slo(SLO_DATA_0_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Update an SLO returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
use datadog_api_client::datadogV1::model::SLOThreshold;
use datadog_api_client::datadogV1::model::SLOTimeframe;
use datadog_api_client::datadogV1::model::SLOType;
use datadog_api_client::datadogV1::model::ServiceLevelObjective;
use datadog_api_client::datadogV1::model::ServiceLevelObjectiveQuery;
#[tokio::main]
async fn main() {
// there is a valid "slo" in the system
let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
let slo_data_0_name = std::env::var("SLO_DATA_0_NAME").unwrap();
let body = ServiceLevelObjective::new(
slo_data_0_name.clone(),
vec![SLOThreshold::new(97.0, SLOTimeframe::SEVEN_DAYS).warning(98.0 as f64)],
SLOType::METRIC,
)
.query(ServiceLevelObjectiveQuery::new(
"sum:httpservice.hits{!code:3xx}.as_count()".to_string(),
"sum:httpservice.hits{code:2xx}.as_count()".to_string(),
))
.target_threshold(97.0 as f64)
.timeframe(SLOTimeframe::SEVEN_DAYS)
.warning_threshold(98.0 as f64);
let configuration = datadog::Configuration::new();
let api = ServiceLevelObjectivesAPI::with_config(configuration);
let resp = api.update_slo(slo_data_0_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Update an SLO returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);
// there is a valid "slo" in the system
const SLO_DATA_0_ID = process.env.SLO_DATA_0_ID as string;
const SLO_DATA_0_NAME = process.env.SLO_DATA_0_NAME as string;
const params: v1.ServiceLevelObjectivesApiUpdateSLORequest = {
body: {
type: "metric",
name: SLO_DATA_0_NAME,
thresholds: [
{
target: 97.0,
timeframe: "7d",
warning: 98.0,
},
],
timeframe: "7d",
targetThreshold: 97.0,
warningThreshold: 98,
query: {
numerator: "sum:httpservice.hits{code:2xx}.as_count()",
denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
},
},
sloId: SLO_DATA_0_ID,
};
apiInstance
.updateSLO(params)
.then((data: v1.SLOListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v1/slo/{slo_id}https://api.datadoghq.eu/api/v1/slo/{slo_id}https://api.ddog-gov.com/api/v1/slo/{slo_id}https://api.datadoghq.com/api/v1/slo/{slo_id}https://api.us3.datadoghq.com/api/v1/slo/{slo_id}https://api.us5.datadoghq.com/api/v1/slo/{slo_id}
Get a service level objective object.
This endpoint requires the slos_read
permission.
OAuth apps require the slos_read
authorization scope to access this endpoint.
이름
유형
설명
slo_id [required]
string
The ID of the service level objective object.
이름
유형
설명
with_configured_alert_ids
boolean
Get the IDs of SLO monitors that reference this SLO.
OK
A service level objective response containing a single service level objective.
항목
유형
설명
data
object
A service level objective object includes a service level indicator, thresholds
for one or more timeframes, and metadata (name
, description
, tags
, etc.).
configured_alert_ids
[integer]
A list of SLO monitors IDs that reference this SLO. This field is returned only when with_configured_alert_ids
parameter is true in query.
created_at
int64
Creation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creator
object
Object describing the creator of the shared element.
string
Email of the creator.
handle
string
Handle of the creator.
name
string
Name of the creator.
description
string
A user-defined description of the service level objective.
Always included in service level objective responses (but may be null
).
Optional in create/update requests.
groups
[string]
A list of (up to 20) monitor groups that narrow the scope of a monitor service level objective.
Included in service level objective responses if it is not empty. Optional in
create/update requests for monitor service level objectives, but may only be
used when then length of the monitor_ids
field is one.
id
string
A unique identifier for the service level objective object.
Always included in service level objective responses.
modified_at
int64
Modification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_ids
[integer]
A list of monitor ids that defines the scope of a monitor service level
objective. Required if type is monitor
.
monitor_tags
[string]
The union of monitor tags for all monitors referenced by the monitor_ids
field.
Always included in service level objective responses for monitor service level
objectives (but may be empty). Ignored in create/update requests. Does not
affect which monitors are included in the service level objective (that is
determined entirely by the monitor_ids
field).
name
string
The name of the service level objective object.
query
object
A metric-based SLO. Required if type is metric
. 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.
denominator [required]
string
A Datadog metric query for total (valid) events.
numerator [required]
string
A Datadog metric query for good events.
sli_specification
<oneOf>
A generic SLI specification. This is currently used for time-slice SLOs only.
Option 1
object
A time-slice SLI specification.
time_slice [required]
object
The time-slice condition, composed of 3 parts: 1. the metric timeseries query, 2. the comparator, and 3. the threshold. Optionally, a fourth part, the query interval, can be provided.
comparator [required]
enum
The comparator used to compare the SLI value to the threshold.
Allowed enum values: >,>=,<,<=
query [required]
object
The queries and formula used to calculate the SLI value.
formulas [required]
[object]
A list that contains exactly one formula, as only a single formula may be used in a time-slice SLO.
formula [required]
string
The formula string, which is an expression involving named queries.
queries [required]
[ <oneOf>]
A list of queries that are used to calculate the SLI value.
Option 1
object
A formula and functions metrics query.
aggregator
enum
The aggregation methods available for metrics queries.
Allowed enum values: avg,min,max,sum,last,area,l2norm,percentile
cross_org_uuids
[string]
The source organization UUID for cross organization queries. Feature in Private Beta.
data_source [required]
enum
Data source for metrics queries.
Allowed enum values: metrics
name [required]
string
Name of the query for use in formulas.
query [required]
string
Metrics query definition.
query_interval_seconds
enum
The interval used when querying data, which defines the size of a time slice.
Two values are allowed: 60 (1 minute) and 300 (5 minutes).
If not provided, the value defaults to 300 (5 minutes).
Allowed enum values: 60,300
threshold [required]
double
The threshold value to which each SLI value will be compared.
tags
[string]
A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty). Optional in create/update requests.
target_threshold
double
The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.
thresholds
[object]
The thresholds (timeframes and associated targets) for this service level objective object.
target [required]
double
The target value for the service level indicator within the corresponding timeframe.
target_display
string
A string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00
).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
warning
double
The warning value for the service level objective.
warning_display
string
A string representation of the warning target (see the description of
the target_display
field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
timeframe
enum
The SLO time window options. Note that "custom" is not a valid option for creating
or updating SLOs. It is only used when querying SLO history over custom timeframes.
Allowed enum values: 7d,30d,90d,custom
type
enum
The type of the service level objective.
Allowed enum values: metric,monitor,time_slice
warning_threshold
double
The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.
errors
[string]
An array of error messages. Each endpoint documents how/whether this field is used.
{
"data": {
"configured_alert_ids": [
123,
456,
789
],
"created_at": "integer",
"creator": {
"email": "string",
"handle": "string",
"name": "string"
},
"description": "string",
"groups": [
"env:prod",
"role:mysql"
],
"id": "string",
"modified_at": "integer",
"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": "query1 - default_zero(query2)"
}
],
"queries": [
[]
]
},
"query_interval_seconds": 300,
"threshold": 5
}
},
"tags": [
"env:prod",
"app:core"
],
"target_threshold": 99.9,
"thresholds": [
{
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
],
"timeframe": "30d",
"type": "metric",
"warning_threshold": 99.95
},
"errors": []
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Not found
Error response object.
{
"errors": [
"Bad Request"
]
}
Too many requests
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export slo_id="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo/${slo_id}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get an SLO's details returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
# there is a valid "slo" in the system
SLO_DATA_0_ID = environ["SLO_DATA_0_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.get_slo(
slo_id=SLO_DATA_0_ID,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get an SLO's details returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
# there is a valid "slo" in the system
SLO_DATA_0_ID = ENV["SLO_DATA_0_ID"]
p api_instance.get_slo(SLO_DATA_0_ID)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY=