Search for SLOs

GET https://api.ap1.datadoghq.com/api/v1/slo/searchhttps://api.ap2.datadoghq.com/api/v1/slo/searchhttps://api.datadoghq.eu/api/v1/slo/searchhttps://api.ddog-gov.com/api/v1/slo/searchhttps://api.us2.ddog-gov.com/api/v1/slo/searchhttps://api.datadoghq.com/api/v1/slo/searchhttps://api.us3.datadoghq.com/api/v1/slo/searchhttps://api.us5.datadoghq.com/api/v1/slo/search

Overview

Get a list of service level objective objects for your organization. This endpoint requires the slos_read permission.

OAuth apps require the slos_read authorization scope to access this endpoint.

Arguments

Query Strings

Name

Type

Description

query

string

The query string to filter results based on SLO names. Some examples of queries include service:<service-name> and <slo-name>.

page[size]

integer

The number of files to return in the response [default=10].

page[number]

integer

The identifier of the first page to return. This parameter is used for the pagination feature [default=0].

include_facets

boolean

Whether or not to return facet information in the response [default=false].

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

slos

[object]

SLOs

data

object

A service level objective ID and attributes.

attributes

object

A service level objective object includes a service level indicator, thresholds for one or more timeframes, and metadata (name, description, and tags).

all_tags

[string]

A list of tags associated with this service level objective. Always included in service level objective responses (but may be empty).

created_at

int64

Creation timestamp (UNIX time in seconds)

Always included in service level objective responses.

creator

object

The creator of the SLO

email

string

Email of the creator.

id

int64

User ID of the creator.

name

string

Name of the creator.

description

string

A user-defined description of the service level objective.

Always included in service level objective responses (but may be null). Optional in create/update requests.

env_tags

[string]

Tags with the env tag key.

groups

[string]

A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective. Included in service level objective responses if it is not empty.

modified_at

int64

Modification timestamp (UNIX time in seconds)

Always included in service level objective responses.

monitor_ids

[integer]

A list of monitor ids that defines the scope of a monitor service level objective.

name

string

The name of the service level objective object.

overall_status

[object]

calculated status and error budget remaining.

error

string

Error message if SLO status or error budget could not be calculated.

error_budget_remaining

double

Remaining error budget of the SLO in percentage.

indexed_at

int64

timestamp (UNIX time in seconds) of when the SLO status and error budget were calculated.

raw_error_budget_remaining

object

Error budget remaining for an SLO.

unit

string

Error budget remaining unit.

value

double

Error budget remaining value.

span_precision

int64

The amount of decimal places the SLI value is accurate to.

state

enum

State of the SLO. Allowed enum values: breached,warning,ok,no_data

status

double

The status of the SLO.

target

double

The target of the SLO.

timeframe

enum

The SLO time window options. Note that "custom" is not a valid option for creating or updating SLOs. It is only used when querying SLO history over custom timeframes. Allowed enum values: 7d,30d,90d,custom

query

object

A metric-based SLO. Required if type is metric. Note that Datadog only allows the sum by aggregator to be used because this will sum up all request counts instead of averaging them, or taking the max or min of all of those requests.

denominator

string

A Datadog metric query for total (valid) events.

metrics

[string]

Metric names used in the query's numerator and denominator. This field will return null and will be implemented in the next version of this endpoint.

numerator

string

A Datadog metric query for good events.

service_tags

[string]

Tags with the service tag key.

slo_type

enum

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

status

object

Status of the SLO's primary timeframe.

calculation_error

string

Error message if SLO status or error budget could not be calculated.

error_budget_remaining

double

Remaining error budget of the SLO in percentage.

indexed_at

int64

timestamp (UNIX time in seconds) of when the SLO status and error budget were calculated.

raw_error_budget_remaining

object

Error budget remaining for an SLO.

unit

string

Error budget remaining unit.

value

double

Error budget remaining value.

sli

double

The current service level indicator (SLI) of the SLO, also known as 'status'. This is a percentage value from 0-100 (inclusive).

span_precision

int64

The number of decimal places the SLI value is accurate to.

state

enum

State of the SLO. Allowed enum values: breached,warning,ok,no_data

team_tags

[string]

Tags with the team tag key.

thresholds

[object]

The thresholds (timeframes and associated targets) for this service level objective object.

target [required]

double

The target value for the service level indicator within the corresponding timeframe.

target_display

string

A string representation of the target that indicates its precision. It uses trailing zeros to show significant decimal places (for example 98.00).

Always included in service level objective responses. Ignored in create/update requests.

timeframe [required]

enum

The SLO time window options. Allowed enum values: 7d,30d,90d

warning

double

The warning value for the service level objective.

warning_display

string

A string representation of the warning target (see the description of the target_display field for details).

Included in service level objective responses if a warning target exists. Ignored in create/update requests.

id

string

A unique identifier for the service level objective object.

Always included in service level objective responses.

type

string

The type of the object, must be slo.

type

string

Type of service level objective result.

links

object

Pagination links.

first

string

Link to last page.

last

string

Link to first page.

next

string

Link to the next page.

prev

string

Link to previous page.

self

string

Link to current page.

meta

object

Searches metadata returned by the API.

pagination

object

Pagination metadata returned by the API.

first_number

int64

The first number.

last_number

int64

The last number.

next_number

int64

The next number.

number

int64

The page number.

prev_number

int64

The previous page number.

size

int64

The size of the response.

total

int64

The total number of SLOs in the response.

type

string

Type of pagination.

{
  "data": {
    "attributes": {
      "facets": {
        "all_tags": [
          {
            "count": "integer",
            "name": "string"
          }
        ],
        "creator_name": [
          {
            "count": "integer",
            "name": "string"
          }
        ],
        "env_tags": [
          {
            "count": "integer",
            "name": "string"
          }
        ],
        "service_tags": [
          {
            "count": "integer",
            "name": "string"
          }
        ],
        "slo_type": [
          {
            "count": "integer",
            "name": "number"
          }
        ],
        "target": [
          {
            "count": "integer",
            "name": "number"
          }
        ],
        "team_tags": [
          {
            "count": "integer",
            "name": "string"
          }
        ],
        "timeframe": [
          {
            "count": "integer",
            "name": "string"
          }
        ]
      },
      "slos": [
        {
          "data": {
            "attributes": {
              "all_tags": [
                "env:prod",
                "app:core"
              ],
              "created_at": "integer",
              "creator": {
                "email": "string",
                "id": "integer",
                "name": "string"
              },
              "description": "string",
              "env_tags": [],
              "groups": [
                "env:prod",
                "role:mysql"
              ],
              "modified_at": "integer",
              "monitor_ids": [],
              "name": "Custom Metric SLO",
              "overall_status": [
                {
                  "error": "string",
                  "error_budget_remaining": 100,
                  "indexed_at": 1662496260,
                  "raw_error_budget_remaining": {
                    "unit": "requests",
                    "value": 60
                  },
                  "span_precision": 2,
                  "state": "ok",
                  "status": 100,
                  "target": 99,
                  "timeframe": "30d"
                }
              ],
              "query": {
                "denominator": "sum:my.custom.metric{*}.as_count()",
                "metrics": [
                  "my.custom.metric",
                  "my.other.custom.metric"
                ],
                "numerator": "sum:my.custom.metric{type:good}.as_count()"
              },
              "service_tags": [],
              "slo_type": "metric",
              "status": {
                "calculation_error": "string",
                "error_budget_remaining": 100,
                "indexed_at": 1662496260,
                "raw_error_budget_remaining": {
                  "unit": "requests",
                  "value": 60
                },
                "sli": 100,
                "span_precision": 2,
                "state": "ok"
              },
              "team_tags": [],
              "thresholds": [
                {
                  "target": 99.9,
                  "target_display": "99.9",
                  "timeframe": "30d",
                  "warning": 90,
                  "warning_display": "90.0"
                }
              ]
            },
            "id": "string",
            "type": "string"
          }
        }
      ]
    },
    "type": ""
  },
  "links": {
    "first": "string",
    "last": "string",
    "next": "string",
    "prev": "string",
    "self": "string"
  },
  "meta": {
    "pagination": {
      "first_number": "integer",
      "last_number": "integer",
      "next_number": "integer",
      "number": "integer",
      "prev_number": "integer",
      "size": "integer",
      "total": "integer",
      "type": "string"
    }
  }
}

Bad Request

Error response object.

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.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/slo/search" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Search for SLOs returns "OK" response
"""

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

# there is a valid "slo" in the system
SLO_DATA_0_NAME = environ["SLO_DATA_0_NAME"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ServiceLevelObjectivesApi(api_client)
    response = api_instance.search_slo(
        query=SLO_DATA_0_NAME,
        page_size=20,
        page_number=0,
    )

    print(response)

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.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Search for SLOs returns "OK" response

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

# there is a valid "slo" in the system
SLO_DATA_0_NAME = ENV["SLO_DATA_0_NAME"]
opts = {
  query: SLO_DATA_0_NAME,
  page_size: 20,
  page_number: 0,
}
p api_instance.search_slo(opts)

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.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Search for SLOs returns "OK" response

package main

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

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

func main() {
	// there is a valid "slo" in the system
	SloData0Name := os.Getenv("SLO_DATA_0_NAME")

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
	resp, r, err := api.SearchSLO(ctx, *datadogV1.NewSearchSLOOptionalParameters().WithQuery(SloData0Name).WithPageSize(20).WithPageNumber(0))

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

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

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.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Search for SLOs returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi;
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi.SearchSLOOptionalParameters;
import com.datadog.api.client.v1.model.SearchSLOResponse;

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

    // there is a valid "slo" in the system
    String SLO_DATA_0_NAME = System.getenv("SLO_DATA_0_NAME");

    try {
      SearchSLOResponse result =
          apiInstance.searchSLO(
              new SearchSLOOptionalParameters()
                  .query(SLO_DATA_0_NAME)
                  .pageSize(20L)
                  .pageNumber(0L));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ServiceLevelObjectivesApi#searchSLO");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

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.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Search for SLOs returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::SearchSLOOptionalParams;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;

#[tokio::main]
async fn main() {
    // there is a valid "slo" in the system
    let slo_data_0_name = std::env::var("SLO_DATA_0_NAME").unwrap();
    let configuration = datadog::Configuration::new();
    let api = ServiceLevelObjectivesAPI::with_config(configuration);
    let resp = api
        .search_slo(
            SearchSLOOptionalParams::default()
                .query(slo_data_0_name.clone())
                .page_size(20)
                .page_number(0),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Search for SLOs returns "OK" response
 */

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

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

// there is a valid "slo" in the system
const SLO_DATA_0_NAME = process.env.SLO_DATA_0_NAME as string;

const params: v1.ServiceLevelObjectivesApiSearchSLORequest = {
  query: SLO_DATA_0_NAME,
  pageSize: 20,
  pageNumber: 0,
};

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

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.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"