SLO を検索する
https://api.datadoghq.com/api/v1/slo/searchhttps://api.us3.datadoghq.com/api/v1/slo/searchhttps://api.us5.datadoghq.com/api/v1/slo/searchhttps://api.datadoghq.eu/api/v1/slo/searchhttps://api.ap1.datadoghq.com/api/v1/slo/searchhttps://api.ap2.datadoghq.com/api/v1/slo/searchhttps://api.uk1.datadoghq.com/api/v1/slo/searchhttps://api.ddog-gov.com/api/v1/slo/searchhttps://api.us2.ddog-gov.com/api/v1/slo/search概要
組織の SLO オブジェクトのリストを取得します。
OAuth apps require the slos_read authorization scope to access this endpoint.
引数
クエリ文字列
queryThe query string to filter results based on SLO names.
Some examples of queries include service:<service-name>
and <slo-name>.
page[size]The number of files to return in the response [default=10].
page[number]The identifier of the first page to return. This parameter is used for the pagination feature [default=0].
include_facetsWhether or not to return facet information in the response [default=false].
応答
OK
A search SLO response containing results from the search query.
dataData from search SLO response.
attributesAttributes
facetsFacets
all_tagsAll tags associated with an SLO.
countCount
nameFacet
creator_nameCreator of an SLO.
countCount
nameFacet
env_tagsTags with the env tag key.
countCount
nameFacet
service_tagsTags with the service tag key.
countCount
nameFacet
slo_typeType of SLO.
countCount
nameFacet
targetSLO Target
countCount
nameFacet
team_tagsTags with the team tag key.
countCount
nameFacet
timeframeTimeframes of SLOs.
countCount
nameFacet
slosSLOs
dataA service level objective ID and attributes.
attributesA service level objective object includes a service level indicator, thresholds
for one or more timeframes, and metadata (name, description, and tags).
all_tagsA list of tags associated with this service level objective. Always included in service level objective responses (but may be empty).
created_atCreation timestamp (UNIX time in seconds)
Always included in service level objective responses.
creatorThe creator of the SLO
emailEmail of the creator.
idUser ID of the creator.
nameName of the creator.
descriptionA 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_tagsTags with the env tag key.
groupsA 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_atModification timestamp (UNIX time in seconds)
Always included in service level objective responses.
monitor_idsA list of monitor ids that defines the scope of a monitor service level objective.
nameThe name of the service level objective object.
overall_statuscalculated status and error budget remaining.
errorError message if SLO status or error budget could not be calculated.
error_budget_remainingRemaining error budget of the SLO in percentage.
indexed_attimestamp (UNIX time in seconds) of when the SLO status and error budget were calculated.
raw_error_budget_remainingError budget remaining for an SLO.
unitError budget remaining unit.
valueError budget remaining value.
span_precisionThe amount of decimal places the SLI value is accurate to.
stateState of the SLO.
breached, warning, ok, no_datastatusThe status of the SLO.
targetThe target of the SLO.
timeframeThe 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.
7d, 30d, 90d, customqueryA 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.
denominatorA Datadog metric query for total (valid) events.
metricsMetric 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.
numeratorA Datadog metric query for good events.
service_tagsTags with the service tag key.
slo_typeThe type of the service level objective.
metric, monitor, time_slicestatusStatus of the SLO's primary timeframe.
calculation_errorError message if SLO status or error budget could not be calculated.
error_budget_remainingRemaining error budget of the SLO in percentage.
indexed_attimestamp (UNIX time in seconds) of when the SLO status and error budget were calculated.
raw_error_budget_remainingError budget remaining for an SLO.
unitError budget remaining unit.
valueError budget remaining value.
sliThe current service level indicator (SLI) of the SLO, also known as 'status'. This is a percentage value from 0-100 (inclusive).
span_precisionThe number of decimal places the SLI value is accurate to.
stateState of the SLO.
breached, warning, ok, no_datateam_tagsTags with the team tag key.
thresholdsThe thresholds (timeframes and associated targets) for this service level objective object.
target [required]The target value for the service level indicator within the corresponding timeframe.
target_displayA 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]The SLO time window options.
7d, 30d, 90dwarningThe warning value for the service level objective.
warning_displayA 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.
idA unique identifier for the service level objective object.
Always included in service level objective responses.
typeThe type of the object, must be slo.
typeType of service level objective result.
linksPagination links.
firstLink to last page.
lastLink to first page.
nextLink to the next page.
prevLink to previous page.
selfLink to current page.
metaSearches metadata returned by the API.
paginationPagination metadata returned by the API.
first_numberThe first number.
last_numberThe last number.
next_numberThe next number.
numberThe page number.
prev_numberThe previous page number.
sizeThe size of the response.
totalThe total number of SLOs in the response.
typeType of pagination.
{
"data": {
"attributes": {
"facets": {
"all_tags": [
{
"count": "integer",
"name": "string"
}
],
"creator_name": [
{
"count": "integer",
"name": "string"
}
],
"env_tags": [
{
"count": "integer",
"name": "string"
}
],
"service_tags": [
{
"count": "integer",
"name": "string"
}
],
"slo_type": [
{
"count": "integer",
"name": "number"
}
],
"target": [
{
"count": "integer",
"name": "number"
}
],
"team_tags": [
{
"count": "integer",
"name": "string"
}
],
"timeframe": [
{
"count": "integer",
"name": "string"
}
]
},
"slos": [
{
"data": {
"attributes": {
"all_tags": [
"env:prod",
"app:core"
],
"created_at": "integer",
"creator": {
"email": "string",
"id": "integer",
"name": "string"
},
"description": "string",
"env_tags": [],
"groups": [
"env:prod",
"role:mysql"
],
"modified_at": "integer",
"monitor_ids": [],
"name": "Custom Metric SLO",
"overall_status": [
{
"error": "string",
"error_budget_remaining": 100,
"indexed_at": 1662496260,
"raw_error_budget_remaining": {
"unit": "requests",
"value": 60
},
"span_precision": 2,
"state": "ok",
"status": 100,
"target": 99,
"timeframe": "30d"
}
],
"query": {
"denominator": "sum:my.custom.metric{*}.as_count()",
"metrics": [
"my.custom.metric",
"my.other.custom.metric"
],
"numerator": "sum:my.custom.metric{type:good}.as_count()"
},
"service_tags": [],
"slo_type": "metric",
"status": {
"calculation_error": "string",
"error_budget_remaining": 100,
"indexed_at": 1662496260,
"raw_error_budget_remaining": {
"unit": "requests",
"value": 60
},
"sli": 100,
"span_precision": 2,
"state": "ok"
},
"team_tags": [],
"thresholds": [
{
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
]
},
"id": "string",
"type": "string"
}
}
]
},
"type": ""
},
"links": {
"first": "string",
"last": "string",
"next": "string",
"prev": "string",
"self": "string"
},
"meta": {
"pagination": {
"first_number": "integer",
"last_number": "integer",
"next_number": "integer",
"number": "integer",
"prev_number": "integer",
"size": "integer",
"total": "integer",
"type": "string"
}
}
}Bad Request
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Forbidden
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}コード例
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/search" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"// 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())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" 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();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
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.access_token = environ["DD_BEARER_TOKEN"]
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Search for SLOs returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// 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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.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({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"