サービスレベル目標
Dash が新機能を発表!インシデントマネジメント、Continuous Profiler など多数の機能が追加されました! Dash イベントで発表された新機能!

サービスレベル目標

サービスレベル目標 (SLO) は、サイト信頼性エンジニアリングツールキットの重要な要素です。SLO を使用し、アプリケーションのパフォーマンスに明確なターゲットを定義するためのフレームワークを整えることで、一貫したカスタマーエクスペリエンを提供したり、プラットフォームの安定性を保ちつつ機能を開発したり、内部および外部ユーザーとのコミュニケーションを改善するために役立てることができます。

SLO タイムフレームを一括削除する

POST https://api.datadoghq.eu/api/v1/slo/bulk_deletehttps://api.datadoghq.com/api/v1/slo/bulk_delete

概要

複数のサービスレベル目標オブジェクトを削除 (または一部削除) します。

このエンドポイントは 1 つ以上のサービスレベル目標オブジェクトに関わる 1 つ以上のしきい値の削除を行います。すべてのしきい値が削除された場合は、 サービスレベル目標オブジェクトも同様に削除されます。

リクエスト

Body Data (required)

複数のサービスレベル目標オブジェクトのリクエスト本文を削除します。

Expand All

フィールド

種類

説明

<any-key>

[string]

An array of all SLO timeframes.

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

応答

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

フィールド

種類

説明

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": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo/bulk_delete" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "id1": [
    "7d",
    "30d"
  ],
  "id2": [
    "7d",
    "30d"
  ]
}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := map[string][]datadog.SLOTimeframe{"key": []datadog.SLOTimeframe{datadog.SLOTimeframe("7d")}} // map[string][]SLOTimeframe | Delete multiple service level objective objects request body.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.DeleteSLOTimeframeInBulk(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.DeleteSLOTimeframeInBulk``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteSLOTimeframeInBulk`: SLOBulkDeleteResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.DeleteSLOTimeframeInBulk`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        Map<String, List<SLOTimeframe>> body = new HashMap(); // Map<String, List<SLOTimeframe>> | Delete multiple service level objective objects request body.
        try {
            SLOBulkDeleteResponse result = apiInstance.deleteSLOTimeframeInBulk()
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling ServiceLevelObjectivesApi#deleteSLOTimeframeInBulk");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

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

slo_id_1 = '<YOUR_SLO_ID>'
slo_id_2 = '<YOUR_SLO_ID>'

initialize(**options)

delete_timeframes = {
  slo_id_1: ["7d"]
  slo_id_2: ["7d", "30d"]
}

api.ServiceLevelObjective.bulk_delete(delete_timeframes)
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)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    body = SLOBulkDelete(
        "key": [
            SLOTimeframe("7d"),
        ],
    ) # SLOBulkDelete | Delete multiple service level objective objects request body.

    # example passing only required values which don't have defaults set
    try:
        # Bulk Delete SLO Timeframes
        api_response = api_instance.delete_slo_timeframe_in_bulk(body)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->delete_slo_timeframe_in_bulk: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
body = nil # Hash<String, Array<SLOTimeframe>> | Delete multiple service level objective objects request body.

begin
  #Bulk Delete SLO Timeframes
  result = api_instance.delete_slo_timeframe_in_bulk(body)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->delete_slo_timeframe_in_bulk: #{e}"
end

SLO を安全に削除できるかどうかを確認する

GET https://api.datadoghq.eu/api/v1/slo/can_deletehttps://api.datadoghq.com/api/v1/slo/can_delete

概要

SLO が安全に削除されたかを確認します。たとえば、 SLO の削除によりダッシュボードに問題が発生していないことを確認します。

引数

クエリ文字列

名前

種類

説明

ids [required]

string

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

応答

OK

A service level objective response containing the requested object.

Expand All

フィールド

種類

説明

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

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

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

フィールド

種類

説明

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

コード例


                                        # Required query arguments
export ids="id1, id2, id3"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo/can_delete?ids=${ids}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    ids := "id1, id2, id3" // string | A comma separated list of the IDs of the service level objectives objects.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.CheckCanDeleteSLO(ctx).Ids(ids).Execute()
    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)
    }
    // response from `CheckCanDeleteSLO`: CheckCanDeleteSLOResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.CheckCanDeleteSLO`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        String ids = "id1, id2, id3"; // String | A comma separated list of the IDs of the service level objectives objects.
        try {
            CheckCanDeleteSLOResponse result = apiInstance.checkCanDeleteSLO()
                .ids(ids)
                .execute();
            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();
        }
    }
}
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)
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)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    ids = "id1, id2, id3" # str | A comma separated list of the IDs of the service level objectives objects.

    # example passing only required values which don't have defaults set
    try:
        # Check if SLOs can be safely deleted
        api_response = api_instance.check_can_delete_slo(ids)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->check_can_delete_slo: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
ids = 'id1, id2, id3' # String | A comma separated list of the IDs of the service level objectives objects.

begin
  #Check if SLOs can be safely deleted
  result = api_instance.check_can_delete_slo(ids)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->check_can_delete_slo: #{e}"
end

SLO オブジェクトを作成する

POST https://api.datadoghq.eu/api/v1/slohttps://api.datadoghq.com/api/v1/slo

概要

サービスレベル目標オブジェクトを作成します。

リクエスト

Body Data (required)

サービスレベル目標のリクエストオブジェクト。

Expand All

フィールド

種類

説明

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 [required]

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.

name [required]

string

The name of the service level objective object.

query

object

A metric SLI query. 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 (e.g. 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.

type [required]

enum

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

{
  "description": "string",
  "groups": [
    "env:prod",
    "role:mysql"
  ],
  "monitor_ids": [],
  "name": "",
  "query": {
    "denominator": "",
    "numerator": ""
  },
  "tags": [
    "env:prod",
    "app:core"
  ],
  "thresholds": [
    {
      "target": 0,
      "target_display": "99.9",
      "timeframe": "string",
      "warning": "number",
      "warning_display": "string"
    }
  ],
  "type": "string"
}

応答

OK

A response with one or more service level objective.

Expand All

フィールド

種類

説明

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 [required]

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 [required]

string

The name of the service level objective object.

query

object

A metric SLI query. 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 (e.g. 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.

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.

{
  "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": "",
      "query": {
        "denominator": "",
        "numerator": ""
      },
      "tags": [
        "env:prod",
        "app:core"
      ],
      "thresholds": [
        {
          "target": 0,
          "target_display": "99.9",
          "timeframe": "string",
          "warning": "number",
          "warning_display": "string"
        }
      ],
      "type": "string"
    }
  ],
  "errors": []
}

Bad Request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "name": "",
  "query": {
    "denominator": "",
    "numerator": ""
  },
  "thresholds": [
    {
      "target": 0,
      "timeframe": null
    }
  ],
  "type": null
}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := *datadog.NewServiceLevelObjectiveRequest("Name_example", []datadog.SLOThreshold{*datadog.NewSLOThreshold(float64(0.0), datadog.SLOTimeframe("7d"))}, datadog.SLOType("metric")) // ServiceLevelObjectiveRequest | Service level objective request object.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.CreateSLO(ctx).Body(body).Execute()
    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)
    }
    // response from `CreateSLO`: SLOListResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.CreateSLO`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        ServiceLevelObjectiveRequest body = new ServiceLevelObjectiveRequest(); // ServiceLevelObjectiveRequest | Service level objective request object.
        try {
            SLOListResponse result = apiInstance.createSLO()
                .body(body)
                .execute();
            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();
        }
    }
}
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
)
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
)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    body = ServiceLevelObjectiveRequest(
        created_at=1,
        creator=Creator(
            email="email_example",
            handle="handle_example",
            name="name_example",
        ),
        description="description_example",
        groups=["env:prod","role:mysql"],
        id="id_example",
        modified_at=1,
        monitor_ids=[
            1,
        ],
        name="name_example",
        query=ServiceLevelObjectiveQuery(
            denominator="denominator_example",
            numerator="numerator_example",
        ),
        tags=["env:prod","app:core"],
        thresholds=[],
        type=SLOType("metric"),
    ) # ServiceLevelObjectiveRequest | Service level objective request object.

    # example passing only required values which don't have defaults set
    try:
        # Create a SLO object
        api_response = api_instance.create_slo(body)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->create_slo: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
body = DatadogAPIClient::V1::ServiceLevelObjectiveRequest.new # ServiceLevelObjectiveRequest | Service level objective request object.

begin
  #Create a SLO object
  result = api_instance.create_slo(body)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->create_slo: #{e}"
end

SLO を削除する

DELETE https://api.datadoghq.eu/api/v1/slo/{slo_id}https://api.datadoghq.com/api/v1/slo/{slo_id}

概要

指定のサービスレベル目標オブジェクトを完全に削除します。

SLO を使用するダッシュボードの場合はダッシュボード内で SLO が参照されているため、 DELETE /v1/slo/ エンドポイントは 409 競合エラーを返します。

引数

パスパラメーター

名前

種類

説明

slo_id [required]

string

The ID of the service level objective.

クエリ文字列

名前

種類

説明

force

string

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

応答

OK

A response list of all service level objective deleted.

Expand All

フィールド

種類

説明

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

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Not found

Error response object.

Expand All

フィールド

種類

説明

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

フィールド

種類

説明

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

コード例


                                        # Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo/${slo_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    sloId := "sloId_example" // string | The ID of the service level objective.
    force := "force_example" // string | Delete the monitor even if it's referenced by other resources (e.g. SLO, composite monitor). (optional)

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.DeleteSLO(ctx, sloId).Force(force).Execute()
    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)
    }
    // response from `DeleteSLO`: SLODeleteResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.DeleteSLO`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        String sloId = "sloId_example"; // String | The ID of the service level objective.
        String force = "force_example"; // String | Delete the monitor even if it's referenced by other resources (e.g. SLO, composite monitor).
        try {
            SLODeleteResponse result = apiInstance.deleteSLO(sloId)
                .force(force)
                .execute();
            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();
        }
    }
}
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)
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)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    slo_id = "slo_id_example" # str | The ID of the service level objective.
    force = "force_example" # str | Delete the monitor even if it's referenced by other resources (e.g. SLO, composite monitor). (optional)

    # example passing only required values which don't have defaults set
    try:
        # Delete a SLO
        api_response = api_instance.delete_slo(slo_id)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->delete_slo: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Delete a SLO
        api_response = api_instance.delete_slo(slo_id, force=force)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->delete_slo: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
slo_id = 'slo_id_example' # String | The ID of the service level objective.
opts = {
  force: 'force_example' # String | Delete the monitor even if it's referenced by other resources (e.g. SLO, composite monitor).
}

begin
  #Delete a SLO
  result = api_instance.delete_slo(slo_id, opts)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->delete_slo: #{e}"
end

SLO の詳細を取得する

GET https://api.datadoghq.eu/api/v1/slo/{slo_id}https://api.datadoghq.com/api/v1/slo/{slo_id}

概要

サービスレベル目標オブジェクトを取得します。

引数

パスパラメーター

名前

種類

説明

slo_id [required]

string

The ID of the service level objective object.

応答

OK

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

Expand All

フィールド

種類

説明

data

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

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 [required]

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 [required]

string

The name of the service level objective object.

query

object

A metric SLI query. 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 (e.g. 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.

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.

{
  "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": "",
    "query": {
      "denominator": "",
      "numerator": ""
    },
    "tags": [
      "env:prod",
      "app:core"
    ],
    "thresholds": [
      {
        "target": 0,
        "target_display": "99.9",
        "timeframe": "string",
        "warning": "number",
        "warning_display": "string"
      }
    ],
    "type": "string"
  },
  "errors": []
}

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Not found

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo/${slo_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    sloId := "sloId_example" // string | The ID of the service level objective object.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.GetSLO(ctx, sloId).Execute()
    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)
    }
    // response from `GetSLO`: SLOResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLO`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        String sloId = "sloId_example"; // String | The ID of the service level objective object.
        try {
            SLOResponse result = apiInstance.getSLO(sloId)
                .execute();
            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();
        }
    }
}
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)
# This is not currently available for the Ruby API.
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    slo_id = "slo_id_example" # str | The ID of the service level objective object.

    # example passing only required values which don't have defaults set
    try:
        # Get a SLO's details
        api_response = api_instance.get_slo(slo_id)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->get_slo: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
slo_id = 'slo_id_example' # String | The ID of the service level objective object.

begin
  #Get a SLO's details
  result = api_instance.get_slo(slo_id)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->get_slo: #{e}"
end

SLO の履歴を取得する

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.datadoghq.com/api/v1/slo/{slo_id}/history

概要

SLO の種類に関わらず、指定された SLO 履歴を取得します。

詳細な履歴データはソースデータの種類に応じて構造化されます。 たとえば、メトリクスのデータはそのメトリクスのソースを使用するイベントの SLO に、モニターの遷移履歴はそのモニターの SLO 種類に含まれます。

注: 応答の形式は、SLO がイベントベースか時間ベースかによって異なります。 事例では両方の形式をご紹介しています。

引数

パスパラメーター

名前

種類

説明

slo_id [required]

string

The ID of the service level objective object.

クエリ文字列

名前

種類

説明

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.

応答

OK

A service level objective history response.

Expand All

フィールド

種類

説明

data

object

An array of service level objective objects.

from_ts

int64

The from timestamp in epoch seconds.

groups

object

An object that holds an SLI value and its associated data. It can represent an SLO's overall SLI value or the SLI value for a specific monitor (in multi-monitor SLOs) or group (in grouped SLOs). The uptime history is included for monitor SLOs.

history

[array]

For monitor based SLOs, this includes the aggregated history uptime time series.

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: 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 or the SLI value for a specific monitor (in multi-monitor SLOs) or group (in grouped SLOs). The uptime history is included for monitor SLOs.

history

[array]

For monitor based SLOs, this includes the aggregated history uptime time series.

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: Deprecated. Use sli_value instead.

series

object

A metric based SLO history response.

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 [required]

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

string

Query units (if available).

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 [required]

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

string

Query units (if available).

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 (e.g. 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.

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": "integer",
    "groups": {
      "history": [],
      "name": "string",
      "precision": {
        "<any-key>": "number"
      },
      "preview": false,
      "sli_value": 99.99,
      "span_precision": "number",
      "uptime": "number"
    },
    "overall": {
      "history": [],
      "name": "string",
      "precision": {
        "<any-key>": "number"
      },
      "preview": false,
      "sli_value": 99.99,
      "span_precision": "number",
      "uptime": "number"
    },
    "series": {
      "denominator": {
        "count": 0,
        "metadata": {
          "aggr": "string",
          "expression": "string",
          "metric": "string",
          "query_index": "integer",
          "scope": "string",
          "unit": "string"
        },
        "sum": 0,
        "values": [
          []
        ]
      },
      "interval": 0,
      "message": "string",
      "numerator": {
        "count": 0,
        "metadata": {
          "aggr": "string",
          "expression": "string",
          "metric": "string",
          "query_index": "integer",
          "scope": "string",
          "unit": "string"
        },
        "sum": 0,
        "values": [
          []
        ]
      },
      "query": "",
      "res_type": "",
      "resp_version": 0,
      "times": [
        []
      ]
    },
    "thresholds": {
      "<any-key>": {
        "target": 0,
        "target_display": "99.9",
        "timeframe": "string",
        "warning": "number",
        "warning_display": "string"
      }
    },
    "to_ts": "integer",
    "type": "string",
    "type_id": 0
  },
  "errors": [
    {
      "error": "string"
    }
  ]
}

Bad Request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # 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.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_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    sloId := "sloId_example" // string | The ID of the service level objective object.
    fromTs := int64(789) // int64 | The `from` timestamp for the query window in epoch seconds.
    toTs := int64(789) // int64 | The `to` timestamp for the query window in epoch seconds.

    configuration := datadog.NewConfiguration()
    configuration.SetUnstableOperationEnabled("GetSLOHistory", true)

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.GetSLOHistory(ctx, sloId).FromTs(fromTs).ToTs(toTs).Execute()
    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)
    }
    // response from `GetSLOHistory`: SLOHistoryResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLOHistory`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        String sloId = "sloId_example"; // String | The ID of the service level objective object.
        Long fromTs = 56L; // Long | The `from` timestamp for the query window in epoch seconds.
        Long toTs = 56L; // Long | The `to` timestamp for the query window in epoch seconds.
        try {
            SLOHistoryResponse result = apiInstance.getSLOHistory(sloId)
                .fromTs(fromTs)
                .toTs(toTs)
                .execute();
            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();
        }
    }
}
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)
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)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    slo_id = "slo_id_example" # str | The ID of the service level objective object.
    from_ts = 1 # int | The `from` timestamp for the query window in epoch seconds.
    to_ts = 1 # int | The `to` timestamp for the query window in epoch seconds.

    # example passing only required values which don't have defaults set
    try:
        # Get an SLO's history
        api_response = api_instance.get_slo_history(slo_id, from_ts, to_ts)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->get_slo_history: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
slo_id = 'slo_id_example' # String | The ID of the service level objective object.
from_ts = 56 # Integer | The `from` timestamp for the query window in epoch seconds.
to_ts = 56 # Integer | The `to` timestamp for the query window in epoch seconds.

begin
  #Get an SLO's history
  result = api_instance.get_slo_history(slo_id, from_ts, to_ts)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->get_slo_history: #{e}"
end

SLO を検索する

GET https://api.datadoghq.eu/api/v1/slohttps://api.datadoghq.com/api/v1/slo

概要

複数のサービスレベル目標オブジェクトを ID で取得します。

引数

クエリ文字列

名前

種類

説明

ids [required]

string

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

応答

OK

A response with one or more service level objective.

Expand All

フィールド

種類

説明

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 [required]

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 [required]

string

The name of the service level objective object.

query

object

A metric SLI query. 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 (e.g. 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.

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.

{
  "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": "",
      "query": {
        "denominator": "",
        "numerator": ""
      },
      "tags": [
        "env:prod",
        "app:core"
      ],
      "thresholds": [
        {
          "target": 0,
          "target_display": "99.9",
          "timeframe": "string",
          "warning": "number",
          "warning_display": "string"
        }
      ],
      "type": "string"
    }
  ],
  "errors": []
}

Bad Request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Required query arguments
export ids="id1, id2, id3"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo?ids=${ids}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    ids := "id1, id2, id3" // string | A comma separated list of the IDs of the service level objectives objects.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.ListSLOs(ctx).Ids(ids).Execute()
    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)
    }
    // response from `ListSLOs`: SLOListResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.ListSLOs`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        String ids = "id1, id2, id3"; // String | A comma separated list of the IDs of the service level objectives objects.
        try {
            SLOListResponse result = apiInstance.listSLOs()
                .ids(ids)
                .execute();
            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();
        }
    }
}
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)
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)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    ids = "id1, id2, id3" # str | A comma separated list of the IDs of the service level objectives objects.

    # example passing only required values which don't have defaults set
    try:
        # Search SLOs
        api_response = api_instance.list_sl_os(ids)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->list_sl_os: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
ids = 'id1, id2, id3' # String | A comma separated list of the IDs of the service level objectives objects.

begin
  #Search SLOs
  result = api_instance.list_sl_os(ids)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->list_sl_os: #{e}"
end

SLO を更新する

PUT https://api.datadoghq.eu/api/v1/slo/{slo_id}https://api.datadoghq.com/api/v1/slo/{slo_id}

概要

指定のサービスレベル目標オブジェクトを更新します。

引数

パスパラメーター

名前

種類

説明

slo_id [required]

string

The ID of the service level objective object.

リクエスト

Body Data (required)

編集されたサービスレベル目標のリクエストオブジェクト。

Expand All

フィールド

種類

説明

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 [required]

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 [required]

string

The name of the service level objective object.

query

object

A metric SLI query. 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 (e.g. 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.

type [required]

enum

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

{
  "description": "string",
  "groups": [
    "env:prod",
    "role:mysql"
  ],
  "monitor_ids": [],
  "monitor_tags": [],
  "name": "",
  "query": {
    "denominator": "",
    "numerator": ""
  },
  "tags": [
    "env:prod",
    "app:core"
  ],
  "thresholds": [
    {
      "target": 0,
      "target_display": "99.9",
      "timeframe": "string",
      "warning": "number",
      "warning_display": "string"
    }
  ],
  "type": "string"
}

応答

OK

A response with one or more service level objective.

Expand All

フィールド

種類

説明

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 [required]

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 [required]

string

The name of the service level objective object.

query

object

A metric SLI query. 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 (e.g. 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.

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.

{
  "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": "",
      "query": {
        "denominator": "",
        "numerator": ""
      },
      "tags": [
        "env:prod",
        "app:core"
      ],
      "thresholds": [
        {
          "target": 0,
          "target_display": "99.9",
          "timeframe": "string",
          "warning": "number",
          "warning_display": "string"
        }
      ],
      "type": "string"
    }
  ],
  "errors": []
}

Bad Request

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

Not Found

Error response object.

Expand All

フィールド

種類

説明

errors [required]

[string]

Array of errors returned by the API.

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

コード例


                                        # Path parameters
export slo_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/slo/${slo_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF { "name": "", "query": { "denominator": "", "numerator": "" }, "thresholds": [ { "target": 0, "timeframe": null } ], "type": null } EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    sloId := "sloId_example" // string | The ID of the service level objective object.
    body := *datadog.NewServiceLevelObjective("Name_example", []datadog.SLOThreshold{*datadog.NewSLOThreshold(float64(0.0), datadog.SLOTimeframe("7d"))}, datadog.SLOType("metric")) // ServiceLevelObjective | The edited service level objective request object.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.ServiceLevelObjectivesApi.UpdateSLO(ctx, sloId).Body(body).Execute()
    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)
    }
    // response from `UpdateSLO`: SLOListResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.UpdateSLO`: %v\n", resp)
}
// Import classes:
import java.util.*;
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.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.ServiceLevelObjectivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
        String sloId = "sloId_example"; // String | The ID of the service level objective object.
        ServiceLevelObjective body = new ServiceLevelObjective(); // ServiceLevelObjective | The edited service level objective request object.
        try {
            SLOListResponse result = apiInstance.updateSLO(sloId)
                .body(body)
                .execute();
            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();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import service_level_objectives_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = service_level_objectives_api.ServiceLevelObjectivesApi(api_client)
    slo_id = "slo_id_example" # str | The ID of the service level objective object.
    body = ServiceLevelObjective(
        created_at=1,
        creator=Creator(
            email="email_example",
            handle="handle_example",
            name="name_example",
        ),
        description="description_example",
        groups=["env:prod","role:mysql"],
        id="id_example",
        modified_at=1,
        monitor_ids=[
            1,
        ],
        monitor_tags=[
            "monitor_tags_example",
        ],
        name="name_example",
        query=ServiceLevelObjectiveQuery(
            denominator="denominator_example",
            numerator="numerator_example",
        ),
        tags=["env:prod","app:core"],
        thresholds=[],
        type=SLOType("metric"),
    ) # ServiceLevelObjective | The edited service level objective request object.

    # example passing only required values which don't have defaults set
    try:
        # Update a SLO
        api_response = api_instance.update_slo(slo_id, body)
        pprint(api_response)
    except datadog_api_client.v1.ApiException as e:
        print("Exception when calling ServiceLevelObjectivesApi->update_slo: %s\n" % e)
# load the gem
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesApi.new
slo_id = 'slo_id_example' # String | The ID of the service level objective object.
body = DatadogAPIClient::V1::ServiceLevelObjective.new # ServiceLevelObjective | The edited service level objective request object.

begin
  #Update a SLO
  result = api_instance.update_slo(slo_id, body)
  p result
rescue DatadogAPIClient::V1::ApiError => e
  puts "Exception when calling ServiceLevelObjectivesApi->update_slo: #{e}"
end