Service Level Objectives

Service Level Objectives (or SLOs) are a key part of the site reliability engineering toolkit. SLOs provide a framework for defining clear targets around application performance, which ultimately help teams provide a consistent customer experience, balance feature development with platform stability, and improve communication with internal and external users.

POST https://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

Overview

Create a service level objective object.

Request

Body Data (required)

Service level objective request object.

Expand All

Field

Type

Description

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.

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.

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. 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.

type [required]

enum

The type of the service level objective. Allowed enum values: metric,monitor

{
  "type": "metric",
  "description": "string",
  "groups": [
    "env:test",
    "role:mysql"
  ],
  "monitor_ids": [],
  "name": "Example-Create_an_SLO_object_returns_OK_response",
  "query": {
    "denominator": "sum:httpservice.hits{!code:3xx}.as_count()",
    "numerator": "sum:httpservice.hits{code:2xx}.as_count()"
  },
  "tags": [
    "env:prod",
    "app:core"
  ],
  "thresholds": [
    {
      "target": 95.0,
      "target_display": "95.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ]
}

Response

OK

A response with one or more service level objective.

Expand All

Field

Type

Description

data

[]

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.

email

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.

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.

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. 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.

type [required]

enum

The type of the service level objective. Allowed enum values: metric,monitor

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()"
      },
      "tags": [
        "env:prod",
        "app:core"
      ],
      "thresholds": [
        {
          "target": 99.9,
          "target_display": "99.9",
          "timeframe": "30d",
          "warning": 90,
          "warning_display": "90.0"
        }
      ],
      "type": "metric"
    }
  ],
  "errors": [],
  "metadata": {
    "page": {
      "total_count": "integer",
      "total_filtered_count": "integer"
    }
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

  
  # Curl command
curl -X POST "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 "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-Create_an_SLO_object_returns_OK_response",
  "query": {
    "denominator": "sum:httpservice.hits{!code:3xx}.as_count()",
    "numerator": "sum:httpservice.hits{code:2xx}.as_count()"
  },
  "tags": [
    "env:prod",
    "app:core"
  ],
  "thresholds": [
    {
      "target": 95.0,
      "target_display": "95.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ]
}
EOF
// Create an SLO object returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	body := datadog.ServiceLevelObjectiveRequest{
		Type:        datadog.SLOTYPE_METRIC,
		Description: *datadog.NewNullableString(datadog.PtrString("string")),
		Groups: []string{
			"env:test",
			"role:mysql",
		},
		MonitorIds: []int64{},
		Name:       "Example-Create_an_SLO_object_returns_OK_response",
		Query: &datadog.ServiceLevelObjectiveQuery{
			Denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
			Numerator:   "sum:httpservice.hits{code:2xx}.as_count()",
		},
		Tags: []string{
			"env:prod",
			"app:core",
		},
		Thresholds: []datadog.SLOThreshold{
			{
				Target:         95.0,
				TargetDisplay:  datadog.PtrString("95.0"),
				Timeframe:      datadog.SLOTIMEFRAME_SEVEN_DAYS,
				Warning:        datadog.PtrFloat64(98),
				WarningDisplay: datadog.PtrString("98.0"),
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.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)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Create an SLO object returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.SLOListResponse;
import com.datadog.api.v1.client.model.SLOThreshold;
import com.datadog.api.v1.client.model.SLOTimeframe;
import com.datadog.api.v1.client.model.SLOType;
import com.datadog.api.v1.client.model.ServiceLevelObjectiveQuery;
import com.datadog.api.v1.client.model.ServiceLevelObjectiveRequest;
import java.util.Arrays;
import java.util.Collections;

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

    ServiceLevelObjectiveRequest body =
        new ServiceLevelObjectiveRequest()
            .type(SLOType.METRIC)
            .description("string")
            .groups(Arrays.asList("env:test", "role:mysql"))
            .name("Example-Create_an_SLO_object_returns_OK_response")
            .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(95.0)
                        .targetDisplay("95.0")
                        .timeframe(SLOTimeframe.SEVEN_DAYS)
                        .warning(98.0)
                        .warningDisplay("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();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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
)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"
"""
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-Create_an_SLO_object_returns_OK_response",
    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=95.0,
            target_display="95.0",
            timeframe=SLOTimeframe("7d"),
            warning=98.0,
            warning_display="98.0",
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ServiceLevelObjectivesApi(api_client)
    response = api_instance.create_slo(body=body)

    print(response)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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
)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
# 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-Create_an_SLO_object_returns_OK_response",
  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: 95.0,
      target_display: "95.0",
      timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
      warning: 98,
      warning_display: "98.0",
    }),
  ],
})
p api_instance.create_slo(body)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * 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-Create_an_SLO_object_returns_OK_response",
    query: {
      denominator: "sum:httpservice.hits{!code:3xx}.as_count()",
      numerator: "sum:httpservice.hits{code:2xx}.as_count()",
    },
    tags: ["env:prod", "app:core"],
    thresholds: [
      {
        target: 95.0,
        targetDisplay: "95.0",
        timeframe: "7d",
        warning: 98,
        warningDisplay: "98.0",
      },
    ],
  },
};

apiInstance
  .createSLO(params)
  .then((data: v1.SLOListResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

Note: Note: This endpoint is in public beta for US regions. It is not currently supported in the EU region. If you have any feedback, contact Datadog support.

GET https://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/searchNot supported in the EU region

Overview

Get a list of service level objective objects for your organization.

Arguments

Query Strings

Name

Type

Description

query

string

The query string to filter results based on SLO names.

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].

Response

OK

A search SLO response containing results from the search query.

Expand All

Field

Type

Description

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

slo

[]

SLOs

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.

email

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.

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.

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. 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.

type [required]

enum

The type of the service level objective. Allowed enum values: metric,monitor

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"
          }
        ]
      },
      "slo": [
        {
          "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()"
          },
          "tags": [
            "env:prod",
            "app:core"
          ],
          "thresholds": [
            {
              "target": 99.9,
              "target_display": "99.9",
              "timeframe": "30d",
              "warning": 90,
              "warning_display": "90.0"
            }
          ],
          "type": "metric"
        }
      ]
    },
    "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.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X GET "https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo/search" \
-H "Content-Type: 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()
configuration.unstable_operations["search_slo"] = True
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)

Instructions

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.comNot supported in the EU regionddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"

GET https://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

Overview

Get a list of service level objective objects for your organization.

Arguments

Query Strings

Name

Type

Description

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.

Response

OK

A response with one or more service level objective.

Expand All

Field

Type

Description

data

[]

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.

email

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.

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.

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. 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.

type [required]

enum

The type of the service level objective. Allowed enum values: metric,monitor

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()"
      },
      "tags": [
        "env:prod",
        "app:core"
      ],
      "thresholds": [
        {
          "target": 99.9,
          "target_display": "99.9",
          "timeframe": "30d",
          "warning": 90,
          "warning_display": "90.0"
        }
      ],
      "type": "metric"
    }
  ],
  "errors": [],
  "metadata": {
    "page": {
      "total_count": "integer",
      "total_filtered_count": "integer"
    }
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X GET "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 "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
// Get all SLOs returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

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)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.ListSLOs(ctx, *datadog.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)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Get all SLOs returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi.ListSLOsOptionalParameters;
import com.datadog.api.v1.client.model.SLOListResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"
"""
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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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)

# 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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
# 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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * 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));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

PUT 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}

Overview

Update the specified service level objective object.

Arguments

Path Parameters

Name

Type

Description

slo_id [required]

string

The ID of the service level objective object.

Request

Body Data (required)

The edited service level objective request object.

Expand All

Field

Type

Description

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.

email

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.

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.

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. 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.

type [required]

enum

The type of the service level objective. Allowed enum values: metric,monitor

{
  "type": "metric",
  "name": "Custom Metric SLO",
  "thresholds": [
    {
      "target": 97.0,
      "timeframe": "7d",
      "warning": 98.0
    }
  ],
  "query": {
    "numerator": "sum:httpservice.hits{code:2xx}.as_count()",
    "denominator": "sum:httpservice.hits{!code:3xx}.as_count()"
  }
}

Response

OK

A response with one or more service level objective.

Expand All

Field

Type

Description

data

[]

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.

email

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.

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.

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. 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.

type [required]

enum

The type of the service level objective. Allowed enum values: metric,monitor

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()"
      },
      "tags": [
        "env:prod",
        "app:core"
      ],
      "thresholds": [
        {
          "target": 99.9,
          "target_display": "99.9",
          "timeframe": "30d",
          "warning": 90,
          "warning_display": "90.0"
        }
      ],
      "type": "metric"
    }
  ],
  "errors": [],
  "metadata": {
    "page": {
      "total_count": "integer",
      "total_filtered_count": "integer"
    }
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

  
  # Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X PUT "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 "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 } ], "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"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

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 := datadog.ServiceLevelObjective{
		Type: datadog.SLOTYPE_METRIC,
		Name: SloData0Name,
		Thresholds: []datadog.SLOThreshold{
			{
				Target:    97.0,
				Timeframe: datadog.SLOTIMEFRAME_SEVEN_DAYS,
				Warning:   datadog.PtrFloat64(98.0),
			},
		},
		Query: &datadog.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)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.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)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Update an SLO returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.SLOListResponse;
import com.datadog.api.v1.client.model.SLOThreshold;
import com.datadog.api.v1.client.model.SLOTimeframe;
import com.datadog.api.v1.client.model.SLOType;
import com.datadog.api.v1.client.model.ServiceLevelObjective;
import com.datadog.api.v1.client.model.ServiceLevelObjectiveQuery;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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)))
            .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();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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("7d"),
            warning=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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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,
    }),
  ],
  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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * 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,
      },
    ],
    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));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

GET 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}

Overview

Get a service level objective object.

Arguments

Path Parameters

Name

Type

Description

slo_id [required]

string

The ID of the service level objective object.

Query Strings

Name

Type

Description

with_configured_alert_ids

boolean

Get the IDs of SLO monitors that reference this SLO.

Response

OK

A service level objective response containing a single service level objective.

Expand All

Field

Type

Description

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.

email

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.

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.

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,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.

type

enum

The type of the service level objective. Allowed enum values: metric,monitor

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()"
    },
    "tags": [
      "env:prod",
      "app:core"
    ],
    "thresholds": [
      {
        "target": 99.9,
        "target_display": "99.9",
        "timeframe": "30d",
        "warning": 90,
        "warning_display": "90.0"
      }
    ],
    "type": "metric"
  },
  "errors": []
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X GET "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
// Get an SLO's details returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

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)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.GetSLO(ctx, SloData0ID, *datadog.NewGetSLOOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.GetSLO`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLO`:\n%s\n", responseContent)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Get an SLO's details returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.SLOResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 {
      SLOResponse result = apiInstance.getSLO(SLO_DATA_0_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ServiceLevelObjectivesApi#getSLO");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

slo_id = '<YOUR_SLO_ID>'

initialize(**options)

api.ServiceLevelObjective.get(slo_id)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"
"""
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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# This is not currently available for the Ruby API.

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
# 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)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Get an SLO's details 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.ServiceLevelObjectivesApiGetSLORequest = {
  sloId: SLO_DATA_0_ID,
};

apiInstance
  .getSLO(params)
  .then((data: v1.SLOResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

DELETE 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}

Overview

Permanently delete the specified service level objective object.

If an SLO is used in a dashboard, the DELETE /v1/slo/ endpoint returns a 409 conflict error because the SLO is referenced in a dashboard.

Arguments

Path Parameters

Name

Type

Description

slo_id [required]

string

The ID of the service level objective.

Query Strings

Name

Type

Description

force

string

Delete the monitor even if it’s referenced by other resources (for example SLO, composite monitor).

Response

OK

A response list of all service level objective deleted.

Expand All

Field

Type

Description

data

[string]

An array containing the ID of the deleted service level objective object.

errors

object

An dictionary containing the ID of the SLO as key and a deletion error as value.

<any-key>

string

Error preventing the SLO deletion.

{
  "data": [],
  "errors": {
    "<any-key>": "string"
  }
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Conflict

A response list of all service level objective deleted.

Expand All

Field

Type

Description

data

[string]

An array containing the ID of the deleted service level objective object.

errors

object

An dictionary containing the ID of the SLO as key and a deletion error as value.

<any-key>

string

Error preventing the SLO deletion.

{
  "data": [],
  "errors": {
    "<any-key>": "string"
  }
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X DELETE "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 "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
// Delete an SLO returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

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)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.DeleteSLO(ctx, SloData0ID, *datadog.NewDeleteSLOOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.DeleteSLO`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.DeleteSLO`:\n%s\n", responseContent)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Delete an SLO returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.SLODeleteResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 {
      SLODeleteResponse result = apiInstance.deleteSLO(SLO_DATA_0_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ServiceLevelObjectivesApi#deleteSLO");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

slo_id = '<YOUR_SLO_ID>'

initialize(**options)

api.ServiceLevelObjective.delete(slo_id)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"
"""
Delete 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

# 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.delete_slo(
        slo_id=SLO_DATA_0_ID,
    )

    print(response)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
slo_id  = '<YOUR_SLO_ID>'

dog = Dogapi::Client.new(api_key, app_key)

dog.delete_service_level_objective(slo_id)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
# Delete 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"]
p api_instance.delete_slo(SLO_DATA_0_ID)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Delete 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 params: v1.ServiceLevelObjectivesApiDeleteSLORequest = {
  sloId: SLO_DATA_0_ID,
};

apiInstance
  .deleteSLO(params)
  .then((data: v1.SLODeleteResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

Note: This endpoint is in public beta. If you have any feedback, contact Datadog support.

GET https://api.datadoghq.eu/api/v1/slo/{slo_id}/historyhttps://api.ddog-gov.com/api/v1/slo/{slo_id}/historyhttps://api.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.us3.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.us5.datadoghq.com/api/v1/slo/{slo_id}/history

Overview

Get a specific SLO’s history, regardless of its SLO type.

The detailed history data is structured according to the source data type. For example, metric data is included for event SLOs that use the metric source, and monitor SLO types include the monitor transition history.

Note: There are different response formats for event based and time based SLOs. Examples of both are shown.

Arguments

Path Parameters

Name

Type

Description

slo_id [required]

string

The ID of the service level objective object.

Query Strings

Name

Type

Description

from_ts [required]

integer

The from timestamp for the query window in epoch seconds.

to_ts [required]

integer

The to timestamp for the query window in epoch seconds.

target

number

The SLO target. If target is passed in, the response will include the remaining error budget and a timeframe value of custom.

apply_correction

boolean

Defaults to true. If any SLO corrections are applied and this parameter is set to false, then the corrections will not be applied and the SLI values will not be affected.

Response

OK

A service level objective history response.

Expand All

Field

Type

Description

data

object

An array of service level objective objects.

from_ts

int64

The from timestamp in epoch seconds.

group_by

[string]

For metric based SLOs where the query includes a group-by clause, this represents the list of grouping parameters.

This is not included in responses for monitor based SLOs.

groups

[object]

For grouped SLOs, this represents SLI data for specific groups.

This is not included in the responses for metric based SLOs.

error_budget_remaining

object

A mapping of threshold timeframe to the remaining error budget.

<any-key>

double

Remaining error budget.

errors

[object]

An array of error objects returned while querying the history data for the service level objective.

error_message [required]

string

A message with more details about the error.

error_type [required]

string

Type of the error.

group

string

For groups in a grouped SLO, this is the group name.

history

[array]

For monitor based SLOs, this includes the aggregated history as arrays that include time series and uptime data where 0=monitor is in OK state and 1=monitor is in alert state.

monitor_modified

int64

For monitor based SLOs, this is the last modified timestamp in epoch seconds of the monitor.

monitor_type

string

For monitor based SLOs, this describes the type of monitor.

name

string

For groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.

precision

double

DEPRECATED: The amount of decimal places the SLI value is accurate to for the given from && to timestamp. Use span_precision instead.

preview

boolean

For monitor based SLOs, when true this indicates that a replay is in progress to give an accurate uptime calculation.

sli_value

double

The current SLI value of the SLO over the history window.

span_precision

double

The amount of decimal places the SLI value is accurate to for the given from && to timestamp.

uptime

double

DEPRECATED: Use sli_value instead.

monitors

[object]

For multi-monitor SLOs, this represents SLI data for specific monitors.

This is not included in the responses for metric based SLOs.

error_budget_remaining

object

A mapping of threshold timeframe to the remaining error budget.

<any-key>

double

Remaining error budget.

errors

[object]

An array of error objects returned while querying the history data for the service level objective.

error_message [required]

string

A message with more details about the error.

error_type [required]

string

Type of the error.

group

string

For groups in a grouped SLO, this is the group name.

history

[array]

For monitor based SLOs, this includes the aggregated history as arrays that include time series and uptime data where 0=monitor is in OK state and 1=monitor is in alert state.

monitor_modified

int64

For monitor based SLOs, this is the last modified timestamp in epoch seconds of the monitor.

monitor_type

string

For monitor based SLOs, this describes the type of monitor.

name

string

For groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.

precision

double

DEPRECATED: The amount of decimal places the SLI value is accurate to for the given from && to timestamp. Use span_precision instead.

preview

boolean

For monitor based SLOs, when true this indicates that a replay is in progress to give an accurate uptime calculation.

sli_value

double

The current SLI value of the SLO over the history window.

span_precision

double

The amount of decimal places the SLI value is accurate to for the given from && to timestamp.

uptime

double

DEPRECATED: Use sli_value instead.

overall

object

An object that holds an SLI value and its associated data. It can represent an SLO's overall SLI value. This can also represent the SLI value for a specific monitor in multi-monitor SLOs, or a group in grouped SLOs.

error_budget_remaining

object

A mapping of threshold timeframe to the remaining error budget.

<any-key>

double

Remaining error budget.

errors

[object]

An array of error objects returned while querying the history data for the service level objective.

error_message [required]

string

A message with more details about the error.

error_type [required]

string

Type of the error.

group

string

For groups in a grouped SLO, this is the group name.

history

[array]

For monitor based SLOs, this includes the aggregated history as arrays that include time series and uptime data where 0=monitor is in OK state and 1=monitor is in alert state.

monitor_modified

int64

For monitor based SLOs, this is the last modified timestamp in epoch seconds of the monitor.

monitor_type

string

For monitor based SLOs, this describes the type of monitor.

name

string

For groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.

precision

object

A mapping of threshold timeframe to number of accurate decimals, regardless of the from && to timestamp.

<any-key>

double

The number of accurate decimals.

preview

boolean

For monitor based SLOs, when true this indicates that a replay is in progress to give an accurate uptime calculation.

sli_value

double

The current SLI value of the SLO over the history window.

span_precision

double

The amount of decimal places the SLI value is accurate to for the given from && to timestamp.

uptime

double

DEPRECATED: Use sli_value instead.

series

object

A metric based SLO history response.

This is not included in responses for monitor based SLOs.

denominator [required]

object

A representation of metric based SLO time series for the provided queries. This is the same response type from batch_query endpoint.

count [required]

int64

Count of submitted metrics.

metadata

object

Query metadata.

aggr

string

Query aggregator function.

expression

string

Query expression.

metric

string

Query metric used.

query_index

int64

Query index from original combined query.

scope

string

Query scope.

unit

[object]

An array of metric units that contains up to two unit objects. For example, bytes represents one unit object and bytes per second represents two unit objects. If a metric query only has one unit object, the second array element is null.

family

string

The family of metric unit, for example bytes is the family for kibibyte, byte, and bit units.

id

int64

The ID of the metric unit.

name

string

The unit of the metric, for instance byte.

plural

string

The plural Unit of metric, for instance bytes.

scale_factor

double

The scale factor of metric unit, for instance 1.0.

short_name

string

A shorter and abbreviated version of the metric unit, for instance B.

sum [required]

double

Total sum of the query.

values [required]

[number]

The query values for each metric.

interval [required]

int64

The aggregated query interval for the series data. It's implicit based on the query time window.

message

string

Optional message if there are specific query issues/warnings.

numerator [required]

object

A representation of metric based SLO time series for the provided queries. This is the same response type from batch_query endpoint.

count [required]

int64

Count of submitted metrics.

metadata

object

Query metadata.

aggr

string

Query aggregator function.

expression

string

Query expression.

metric

string

Query metric used.

query_index

int64

Query index from original combined query.

scope

string

Query scope.

unit

[object]

An array of metric units that contains up to two unit objects. For example, bytes represents one unit object and bytes per second represents two unit objects. If a metric query only has one unit object, the second array element is null.

family

string

The family of metric unit, for example bytes is the family for kibibyte, byte, and bit units.

id

int64

The ID of the metric unit.

name

string

The unit of the metric, for instance byte.

plural

string

The plural Unit of metric, for instance bytes.

scale_factor

double

The scale factor of metric unit, for instance 1.0.

short_name

string

A shorter and abbreviated version of the metric unit, for instance B.

sum [required]

double

Total sum of the query.

values [required]

[number]

The query values for each metric.

query [required]

string

The combined numerator and denominator query CSV.

res_type [required]

string

The series result type. This mimics batch_query response type.

resp_version [required]

int64

The series response version type. This mimics batch_query response type.

times [required]

[number]

An array of query timestamps in EPOCH milliseconds.

thresholds

object

mapping of string timeframe to the SLO threshold.

<any-key>

object

SLO thresholds (target and optionally warning) for a single time window.

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,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.

to_ts

int64

The to timestamp in epoch seconds.

type

enum

The type of the service level objective. Allowed enum values: metric,monitor

type_id

enum

A numeric representation of the type of the service level objective (0 for monitor, 1 for metric). Always included in service level objective responses. Ignored in create/update requests. Allowed enum values: 0,1

errors

[object]

A list of errors while querying the history data for the service level objective.

error

string

Human readable error.

{
  "data": {
    "from_ts": 1615323990,
    "group_by": [],
    "groups": [
      {
        "error_budget_remaining": {
          "<any-key>": "number"
        },
        "errors": [
          {
            "error_message": "",
            "error_type": ""
          }
        ],
        "group": "name",
        "history": [
          [
            1579212382,
            0
          ]
        ],
        "monitor_modified": 1615867200,
        "monitor_type": "string",
        "name": "string",
        "precision": 2,
        "preview": true,
        "sli_value": 99.99,
        "span_precision": 2,
        "uptime": 99.99
      }
    ],
    "monitors": [
      {
        "error_budget_remaining": {
          "<any-key>": "number"
        },
        "errors": [
          {
            "error_message": "",
            "error_type": ""
          }
        ],
        "group": "name",
        "history": [
          [
            1579212382,
            0
          ]
        ],
        "monitor_modified": 1615867200,
        "monitor_type": "string",
        "name": "string",
        "precision": 2,
        "preview": true,
        "sli_value": 99.99,
        "span_precision": 2,
        "uptime": 99.99
      }
    ],
    "overall": {
      "error_budget_remaining": {
        "<any-key>": "number"
      },
      "errors": [
        {
          "error_message": "",
          "error_type": ""
        }
      ],
      "group": "name",
      "history": [
        [
          1579212382,
          0
        ]
      ],
      "monitor_modified": 1615867200,
      "monitor_type": "string",
      "name": "string",
      "precision": {
        "<any-key>": "number"
      },
      "preview": true,
      "sli_value": 99.99,
      "span_precision": 2,
      "uptime": 99.99
    },
    "series": {
      "denominator": {
        "count": 0,
        "metadata": {
          "aggr": "string",
          "expression": "string",
          "metric": "string",
          "query_index": "integer",
          "scope": "string",
          "unit": [
            {
              "family": "bytes",
              "id": 2,
              "name": "byte",
              "plural": "bytes",
              "scale_factor": 1,
              "short_name": "B"
            }
          ]
        },
        "sum": 0,
        "values": [
          []
        ]
      },
      "interval": 0,
      "message": "",
      "numerator": {
        "count": 0,
        "metadata": {
          "aggr": "string",
          "expression": "string",
          "metric": "string",
          "query_index": "integer",
          "scope": "string",
          "unit": [
            {
              "family": "bytes",
              "id": 2,
              "name": "byte",
              "plural": "bytes",
              "scale_factor": 1,
              "short_name": "B"
            }
          ]
        },
        "sum": 0,
        "values": [
          []
        ]
      },
      "query": "",
      "res_type": "",
      "resp_version": 0,
      "times": [
        []
      ]
    },
    "thresholds": {
      "<any-key>": {
        "target": 99.9,
        "target_display": "99.9",
        "timeframe": "30d",
        "warning": 90,
        "warning_display": "90.0"
      }
    },
    "to_ts": 1615928790,
    "type": "metric",
    "type_id": 0
  },
  "errors": [
    {
      "error": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Curl command curl -X GET "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}/history?from_ts=${from_ts}&to_ts=${to_ts}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
// Get an SLO's history returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

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()
	configuration.SetUnstableOperationEnabled("GetSLOHistory", true)
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.GetSLOHistory(ctx, SloData0ID, time.Now().AddDate(0, 0, -1).Unix(), time.Now().Unix(), *datadog.NewGetSLOHistoryOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.GetSLOHistory`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLOHistory`:\n%s\n", responseContent)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Get an SLO's history returns "OK" response
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.SLOHistoryResponse;
import java.time.OffsetDateTime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("getSloHistory", true);
    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 {
      SLOHistoryResponse result =
          apiInstance.getSLOHistory(
              SLO_DATA_0_ID,
              OffsetDateTime.now().plusDays(-1).toInstant().getEpochSecond(),
              OffsetDateTime.now().toInstant().getEpochSecond());
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ServiceLevelObjectivesApi#getSLOHistory");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
from datadog import initialize, api
import time

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

slo_id = '<YOUR_SLO_ID>'

initialize(**options)

to_ts = int(time.time())
from_ts = to_ts - 60*60*24*30

api.ServiceLevelObjective.history(slo_id, from_ts=from_ts, to_ts=to_ts)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"
"""
Get an SLO's history returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
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()
configuration.unstable_operations["get_slo_history"] = True
with ApiClient(configuration) as api_client:
    api_instance = ServiceLevelObjectivesApi(api_client)
    response = api_instance.get_slo_history(
        slo_id=SLO_DATA_0_ID,
        from_ts=int((datetime.now() + relativedelta(days=-1)).timestamp()),
        to_ts=int(datetime.now().timestamp()),
    )

    print(response)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
slo_id  = '<YOUR_SLO_ID>'

dog = Dogapi::Client.new(api_key, app_key)

to_ts = 1_571_320_613
from_ts = to_ts - 60 * 60 * 24 * 30

dog.get_service_level_objective_history(slo_id, from_ts, to_ts)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
# Get an SLO's history returns "OK" response

require "datadog_api_client"
DatadogAPIClient::V2.configure do |config|
  config.unstable_operations[:get_slo_history] = true
end
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_history(SLO_DATA_0_ID, (Time.now + -1 * 86400).to_i, Time.now.to_i)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Get an SLO's history returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["getSLOHistory"] = true;
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.ServiceLevelObjectivesApiGetSLOHistoryRequest = {
  sloId: SLO_DATA_0_ID,
  fromTs: new Date(new Date().getTime() / 1000 + -1 * 86400).getTime() / 1000,
  toTs: new Date().getTime() / 1000,
};

apiInstance
  .getSLOHistory(params)
  .then((data: v1.SLOHistoryResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

GET https://api.datadoghq.eu/api/v1/slo/{slo_id}/correctionshttps://api.ddog-gov.com/api/v1/slo/{slo_id}/correctionshttps://api.datadoghq.com/api/v1/slo/{slo_id}/correctionshttps://api.us3.datadoghq.com/api/v1/slo/{slo_id}/correctionshttps://api.us5.datadoghq.com/api/v1/slo/{slo_id}/corrections

Overview

Get corrections applied to an SLO

Arguments

Path Parameters

Name

Type

Description

slo_id [required]

string

The ID of the service level objective object.

Response

OK

A list of SLO correction objects.

Expand All

Field

Type

Description

data

[object]

The list of of SLO corrections objects.

attributes

object

The attribute object associated with the SLO correction.

category

enum

Category the SLO correction belongs to. Allowed enum values: Scheduled Maintenance,Outside Business Hours,Deployment,Other

created_at

int64

The epoch timestamp of when the correction was created at.

creator

object

Object describing the creator of the shared element.

email

string

Email of the creator.

handle

string

Handle of the creator.

name

string

Name of the creator.

description

string

Description of the correction being made.

duration

int64

Length of time (in seconds) for a specified rrule recurring SLO correction.

end

int64

Ending time of the correction in epoch seconds.

modified_at

int64

The epoch timestamp of when the correction was modified at.

modifier

object

Modifier of the object.

email

string

Email of the Modifier.

handle

string

Handle of the Modifier.

name

string

Name of the Modifier.

rrule

string

The recurrence rules as defined in the iCalendar RFC 5545. The supported rules for SLO corrections are FREQ, INTERVAL, COUNT, and UNTIL.

slo_id

string

ID of the SLO that this correction applies to.

start

int64

Starting time of the correction in epoch seconds.

timezone

string

The timezone to display in the UI for the correction times (defaults to "UTC").

id

string

The ID of the SLO correction.

type

enum

SLO correction resource type. Allowed enum values: correction

meta

object

Object describing meta attributes of response.

page

object

Pagination object.

total_count

int64

Total count.

total_filtered_count

int64

Total count of elements matched by the filter.

{
  "data": [
    {
      "attributes": {
        "category": "Scheduled Maintenance",
        "created_at": "integer",
        "creator": {
          "email": "string",
          "handle": "string",
          "name": "string"
        },
        "description": "string",
        "duration": 3600,
        "end": "integer",
        "modified_at": "integer",
        "modifier": {
          "email": "string",
          "handle": "string",
          "name": "string"
        },
        "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
        "slo_id": "string",
        "start": "integer",
        "timezone": "string"
      },
      "id": "string",
      "type": "correction"
    }
  ],
  "meta": {
    "page": {
      "total_count": "integer",
      "total_filtered_count": "integer"
    }
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X GET "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}/corrections" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
// Get Corrections For an SLO returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

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()
	configuration.SetUnstableOperationEnabled("GetSLOCorrections", true)
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.GetSLOCorrections(ctx, SloData0ID)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.GetSLOCorrections`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLOCorrections`:\n%s\n", responseContent)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Get Corrections For an SLO returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.SLOCorrectionListResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.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 {
      SLOCorrectionListResponse result = apiInstance.getSLOCorrections(SLO_DATA_0_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ServiceLevelObjectivesApi#getSLOCorrections");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
"""
Get Corrections For 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

# 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_corrections(
        slo_id=SLO_DATA_0_ID,
    )

    print(response)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Get Corrections For 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"]
p api_instance.get_slo_corrections(SLO_DATA_0_ID)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Get Corrections For 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 params: v1.ServiceLevelObjectivesApiGetSLOCorrectionsRequest = {
  sloId: SLO_DATA_0_ID,
};

apiInstance
  .getSLOCorrections(params)
  .then((data: v1.SLOCorrectionListResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"

GET https://api.datadoghq.eu/api/v1/slo/can_deletehttps://api.ddog-gov.com/api/v1/slo/can_deletehttps://api.datadoghq.com/api/v1/slo/can_deletehttps://api.us3.datadoghq.com/api/v1/slo/can_deletehttps://api.us5.datadoghq.com/api/v1/slo/can_delete

Overview

Check if an SLO can be safely deleted. For example, assure an SLO can be deleted without disrupting a dashboard.

Arguments

Query Strings

Name

Type

Description

ids [required]

string

A comma separated list of the IDs of the service level objectives objects.

Response

OK

A service level objective response containing the requested object.

Expand All

Field

Type

Description

data

object

An array of service level objective objects.

ok

[string]

An array of of SLO IDs that can be safely deleted.

errors

object

A mapping of SLO id to it's current usages.

<any-key>

string

Description of the service level objective reference.

{
  "data": {
    "ok": []
  },
  "errors": {
    "<any-key>": "string"
  }
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Conflict

A service level objective response containing the requested object.

Expand All

Field

Type

Description

data

object

An array of service level objective objects.

ok

[string]

An array of of SLO IDs that can be safely deleted.

errors

object

A mapping of SLO id to it's current usages.

<any-key>

string

Description of the service level objective reference.

{
  "data": {
    "ok": []
  },
  "errors": {
    "<any-key>": "string"
  }
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Required query arguments
export ids="id1, id2, id3"
# Curl command curl -X GET "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/can_delete?ids=${ids}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Check if SLOs can be safely deleted returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ServiceLevelObjectivesApi(api_client)
    response = api_instance.check_can_delete_slo(
        ids="ids",
    )

    print(response)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Check if SLOs can be safely deleted returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
p api_instance.check_can_delete_slo("ids")

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<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)

slo_ids = ['<YOUR_SLO_ID>']
dog.can_delete_service_level_objective(slo_ids)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Check if SLOs can be safely deleted returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);

const params: v1.ServiceLevelObjectivesApiCheckCanDeleteSLORequest = {
  ids: "ids",
};

apiInstance
  .checkCanDeleteSLO(params)
  .then((data: v1.CheckCanDeleteSLOResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// Check if SLOs can be safely deleted returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.CheckCanDeleteSLO(ctx, "ids")

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.CheckCanDeleteSLO`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.CheckCanDeleteSLO`:\n%s\n", responseContent)
}

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Check if SLOs can be safely deleted returns "OK" response

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;
import com.datadog.api.v1.client.model.CheckCanDeleteSLOResponse;

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

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

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

slo_ids = ['<YOUR_SLO_ID>']

initialize(**options)

api.ServiceLevelObjective.can_delete(slo_ids)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python "example.py"

POST https://api.datadoghq.eu/api/v1/slo/bulk_deletehttps://api.ddog-gov.com/api/v1/slo/bulk_deletehttps://api.datadoghq.com/api/v1/slo/bulk_deletehttps://api.us3.datadoghq.com/api/v1/slo/bulk_deletehttps://api.us5.datadoghq.com/api/v1/slo/bulk_delete

Overview

Delete (or partially delete) multiple service level objective objects.

This endpoint facilitates deletion of one or more thresholds for one or more service level objective objects. If all thresholds are deleted, the service level objective object is deleted as well.

Request

Body Data (required)

Delete multiple service level objective objects request body.

Expand All

Field

Type

Description

<any-key>

[string]

An array of all SLO timeframes.

{
  "id1": [
    "7d",
    "30d"
  ],
  "id2": [
    "7d",
    "30d"
  ]
}

Response

OK

The bulk partial delete service level objective object endpoint response.

This endpoint operates on multiple service level objective objects, so it may be partially successful. In such cases, the “data” and “error” fields in this response indicate which deletions succeeded and failed.

Expand All

Field

Type

Description

data

object

An array of service level objective objects.

deleted

[string]

An array of service level objective object IDs that indicates which objects that were completely deleted.

updated

[string]

An array of service level objective object IDs that indicates which objects that were modified (objects for which at least one threshold was deleted, but that were not completely deleted).

errors

[object]

Array of errors object returned.

id [required]

string

The ID of the service level objective object associated with this error.

message [required]

string

The error message.

timeframe [required]

enum

The timeframe of the threshold associated with this error or "all" if all thresholds are affected. Allowed enum values: 7d,30d,90d,all

{
  "data": {
    "deleted": [],
    "updated": []
  },
  "errors": [
    {
      "id": "",
      "message": "",
      "timeframe": "30d"
    }
  ]
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example


# Curl command
curl -X POST "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/bulk_delete" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "id1": [
    "7d",
    "30d"
  ],
  "id2": [
    "7d",
    "30d"
  ]
}
EOF
"""
Bulk Delete SLO Timeframes 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.slo_bulk_delete import SLOBulkDelete
from datadog_api_client.v1.model.slo_timeframe import SLOTimeframe

body = SLOBulkDelete(
    id1=[
        SLOTimeframe("7d"),
        SLOTimeframe("30d"),
    ],
    id2=[
        SLOTimeframe("7d"),
        SLOTimeframe("30d"),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ServiceLevelObjectivesApi(api_client)
    response = api_instance.delete_slo_timeframe_in_bulk(body=body)

    print(response)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Bulk Delete SLO Timeframes returns "OK" response

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

body = DatadogAPIClient::V1::SLOBulkDelete.new({
  id1: [
    DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
    DatadogAPIClient::V1::SLOTimeframe::THIRTY_DAYS,
  ], id2: [
    DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS,
    DatadogAPIClient::V1::SLOTimeframe::THIRTY_DAYS,
  ],
})
p api_instance.delete_slo_timeframe_in_bulk(body)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

slo_id_one = '<YOUR_FIRST_SLO_ID>'.freeze
slo_id_two = '<YOUR_SECOND_SLO_ID>'.freeze

dog = Dogapi::Client.new(api_key, app_key)

# Delete multiple timeframes
thresholds = {
  slo_id_one => %w[7d],
  slo_id_two => %w[7d 30d]
}
dog.delete_timeframes_service_level_objective(thresholds)

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
/**
 * Bulk Delete SLO Timeframes returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);

const params: v1.ServiceLevelObjectivesApiDeleteSLOTimeframeInBulkRequest = {
  body: {
    id1: ["7d", "30d"],
    id2: ["7d", "30d"],
  },
};

apiInstance
  .deleteSLOTimeframeInBulk(params)
  .then((data: v1.SLOBulkDeleteResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

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.euddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
// Bulk Delete SLO Timeframes returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
	body := map[string][]datadog.SLOTimeframe{
		"id1": []datadog.SLOTimeframe{
			datadog.SLOTIMEFRAME_SEVEN_DAYS,
			datadog.SLOTIMEFRAME_THIRTY_DAYS,
		},
		"id2": []datadog.SLOTimeframe{
			datadog.SLOTIMEFRAME_SEVEN_DAYS,
			datadog.SLOTIMEFRAME_THIRTY_DAYS,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	resp, r, err := apiClient.ServiceLevelObjectivesApi.DeleteSLOTimeframeInBulk(ctx, body)