Obtener el historial de un SLO
https://api.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.us3.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.us5.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.datadoghq.eu/api/v1/slo/{slo_id}/historyhttps://api.ap1.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.ap2.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.uk1.datadoghq.com/api/v1/slo/{slo_id}/historyhttps://api.ddog-gov.com/api/v1/slo/{slo_id}/historyhttps://api.us2.ddog-gov.com/api/v1/slo/{slo_id}/historyDescripción general
Obtén el historial de un SLO específico, independientemente de su tipo de SLO.
Los datos detallados del historial se estructuran según el tipo de datos de origen. Por ejemplo, los datos de métricas se incluyen para los SLOs de evento que utilizan la fuente de métricas y los tipos de SLOs de monitor incluyen el historial de transición del monitor.
Nota: Existen diferentes formatos de respuesta para los SLOs basados en eventos y en el tiempo. Se muestran ejemplos de ambos.
OAuth apps require the slos_read authorization scope to access this endpoint.
Argumentos
Parámetros de ruta
slo_id [required]The ID of the service level objective object.
Cadenas de consulta
from_ts [required]The from timestamp for the query window in epoch seconds.
to_ts [required]The to timestamp for the query window in epoch seconds.
targetThe SLO target. If target is passed in, the response will include the remaining error budget and a timeframe value of custom.
apply_correctionDefaults to true. If any SLO corrections are applied and this parameter is set to false,
then the corrections will not be applied and the SLI values will not be affected.
Respuesta
OK
A service level objective history response.
dataAn array of service level objective objects.
from_tsThe from timestamp in epoch seconds.
group_byFor metric based SLOs where the query includes a group-by clause, this represents the list of grouping parameters.
This is not included in responses for monitor based SLOs.
groupsFor grouped SLOs, this represents SLI data for specific groups.
This is not included in the responses for metric based SLOs.
error_budget_remainingA mapping of threshold timeframe to the remaining error budget.
<any-key>Remaining error budget.
errorsAn array of error objects returned while querying the history data for the service level objective.
error_message [required]A message with more details about the error.
error_type [required]Type of the error.
groupFor groups in a grouped SLO, this is the group name.
historyThe state transition history for the monitor. It is represented as
an array of pairs. Each pair is an array containing the timestamp of the transition
as an integer in Unix epoch format in the first element, and the state as an integer in the
second element. An integer value of 0 for state means uptime, 1 means downtime, and 2 means no data.
Periods of no data are counted either as uptime or downtime depending on monitor settings.
See SLO documentation
for detailed information.
monitor_modifiedFor monitor based SLOs, this is the last modified timestamp in epoch seconds of the monitor.
monitor_typeFor monitor based SLOs, this describes the type of monitor.
nameFor groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.
precisionDEPRECATED The amount of decimal places the SLI value is accurate to for the given from && to timestamp. Use span_precision instead.
previewFor monitor based SLOs, when true this indicates that a replay is in progress to give an accurate uptime
calculation.
sli_valueThe current SLI value of the SLO over the history window.
span_precisionThe amount of decimal places the SLI value is accurate to for the given from && to timestamp.
uptimeDEPRECATED Use sli_value instead.
monitorsFor multi-monitor SLOs, this represents SLI data for specific monitors.
This is not included in the responses for metric based SLOs.
error_budget_remainingA mapping of threshold timeframe to the remaining error budget.
<any-key>Remaining error budget.
errorsAn array of error objects returned while querying the history data for the service level objective.
error_message [required]A message with more details about the error.
error_type [required]Type of the error.
groupFor groups in a grouped SLO, this is the group name.
historyThe state transition history for the monitor. It is represented as
an array of pairs. Each pair is an array containing the timestamp of the transition
as an integer in Unix epoch format in the first element, and the state as an integer in the
second element. An integer value of 0 for state means uptime, 1 means downtime, and 2 means no data.
Periods of no data are counted either as uptime or downtime depending on monitor settings.
See SLO documentation
for detailed information.
monitor_modifiedFor monitor based SLOs, this is the last modified timestamp in epoch seconds of the monitor.
monitor_typeFor monitor based SLOs, this describes the type of monitor.
nameFor groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.
precisionDEPRECATED The amount of decimal places the SLI value is accurate to for the given from && to timestamp. Use span_precision instead.
previewFor monitor based SLOs, when true this indicates that a replay is in progress to give an accurate uptime
calculation.
sli_valueThe current SLI value of the SLO over the history window.
span_precisionThe amount of decimal places the SLI value is accurate to for the given from && to timestamp.
uptimeDEPRECATED Use sli_value instead.
overallAn object that holds an SLI value and its associated data. It can represent an SLO's overall SLI value. This can also represent the SLI value for a specific monitor in multi-monitor SLOs, or a group in grouped SLOs.
error_budget_remainingA mapping of threshold timeframe to the remaining error budget.
<any-key>Remaining error budget.
errorsAn array of error objects returned while querying the history data for the service level objective.
error_message [required]A message with more details about the error.
error_type [required]Type of the error.
groupFor groups in a grouped SLO, this is the group name.
historyThe state transition history for monitor or time-slice SLOs. It is represented as
an array of pairs. Each pair is an array containing the timestamp of the transition
as an integer in Unix epoch format in the first element, and the state as an integer in the
second element. An integer value of 0 for state means uptime, 1 means downtime, and 2 means no data.
Periods of no data count as uptime in time-slice SLOs, while for monitor SLOs, no data is counted
either as uptime or downtime depending on monitor settings. See
SLO documentation
for detailed information.
monitor_modifiedFor monitor based SLOs, this is the last modified timestamp in epoch seconds of the monitor.
monitor_typeFor monitor based SLOs, this describes the type of monitor.
nameFor groups in a grouped SLO, this is the group name. For monitors in a multi-monitor SLO, this is the monitor name.
precisionA mapping of threshold timeframe to number of accurate decimals, regardless of the from && to timestamp.
<any-key>The number of accurate decimals.
previewFor monitor based SLOs, when true this indicates that a replay is in progress to give an accurate uptime
calculation.
sli_valueThe current SLI value of the SLO over the history window.
span_precisionThe amount of decimal places the SLI value is accurate to for the given from && to timestamp.
uptimeDEPRECATED Use sli_value instead.
seriesA metric based SLO history response.
This is not included in responses for monitor based SLOs.
denominator [required]A representation of metric based SLO timeseries for the provided queries.
This is the same response type from batch_query endpoint.
count [required]Count of submitted metrics.
metadataQuery metadata.
aggrDEPRECATED Query aggregator function.
expressionDEPRECATED Query expression.
metricDEPRECATED Query metric used.
query_indexDEPRECATED Query index from original combined query.
scopeDEPRECATED Query scope.
unitAn array of metric units that contains up to two unit objects. For example, bytes represents one unit object and bytes per second represents two unit objects. If a metric query only has one unit object, the second array element is null.
familyThe family of metric unit, for example bytes is the family for kibibyte, byte, and bit units.
idThe ID of the metric unit.
nameThe unit of the metric, for instance byte.
pluralThe plural Unit of metric, for instance bytes.
scale_factorThe scale factor of metric unit, for instance 1.0.
short_nameA shorter and abbreviated version of the metric unit, for instance B.
sum [required]Total sum of the query.
values [required]The query values for each metric.
interval [required]The aggregated query interval for the series data. It's implicit based on the query time window.
messageOptional message if there are specific query issues/warnings.
numerator [required]A representation of metric based SLO timeseries for the provided queries.
This is the same response type from batch_query endpoint.
count [required]Count of submitted metrics.
metadataQuery metadata.
aggrDEPRECATED Query aggregator function.
expressionDEPRECATED Query expression.
metricDEPRECATED Query metric used.
query_indexDEPRECATED Query index from original combined query.
scopeDEPRECATED Query scope.
unitAn array of metric units that contains up to two unit objects. For example, bytes represents one unit object and bytes per second represents two unit objects. If a metric query only has one unit object, the second array element is null.
familyThe family of metric unit, for example bytes is the family for kibibyte, byte, and bit units.
idThe ID of the metric unit.
nameThe unit of the metric, for instance byte.
pluralThe plural Unit of metric, for instance bytes.
scale_factorThe scale factor of metric unit, for instance 1.0.
short_nameA shorter and abbreviated version of the metric unit, for instance B.
sum [required]Total sum of the query.
values [required]The query values for each metric.
query [required]The combined numerator and denominator query CSV.
res_type [required]The series result type. This mimics batch_query response type.
resp_version [required]The series response version type. This mimics batch_query response type.
times [required]An array of query timestamps in EPOCH milliseconds.
thresholdsmapping of string timeframe to the SLO threshold.
<any-key>SLO thresholds (target and optionally warning) for a single time window.
target [required]The target value for the service level indicator within the corresponding timeframe.
target_displayA string representation of the target that indicates its precision.
It uses trailing zeros to show significant decimal places (for example 98.00).
Always included in service level objective responses. Ignored in create/update requests.
timeframe [required]The SLO time window options. Note that "custom" is not a valid option for creating or updating SLOs. It is only used when querying SLO history over custom timeframes.
7d, 30d, 90d, customwarningThe warning value for the service level objective.
warning_displayA string representation of the warning target (see the description of
the target_display field for details).
Included in service level objective responses if a warning target exists. Ignored in create/update requests.
to_tsThe to timestamp in epoch seconds.
typeThe type of the service level objective.
metric, monitor, time_slicetype_idA 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.
0, 1, 2errorsA list of errors while querying the history data for the service level objective.
errorHuman readable error.
{
"data": {
"from_ts": 1615323990,
"group_by": [],
"groups": [
{
"error_budget_remaining": {
"<any-key>": "number"
},
"errors": [
{
"error_message": "",
"error_type": ""
}
],
"group": "name",
"history": [
[
1579212382,
0
]
],
"monitor_modified": 1615867200,
"monitor_type": "string",
"name": "string",
"precision": 2,
"preview": true,
"sli_value": 99.99,
"span_precision": 2,
"uptime": 99.99
}
],
"monitors": [
{
"error_budget_remaining": {
"<any-key>": "number"
},
"errors": [
{
"error_message": "",
"error_type": ""
}
],
"group": "name",
"history": [
[
1579212382,
0
]
],
"monitor_modified": 1615867200,
"monitor_type": "string",
"name": "string",
"precision": 2,
"preview": true,
"sli_value": 99.99,
"span_precision": 2,
"uptime": 99.99
}
],
"overall": {
"error_budget_remaining": {
"<any-key>": "number"
},
"errors": [
{
"error_message": "",
"error_type": ""
}
],
"group": "name",
"history": [
[
1579212382,
0
]
],
"monitor_modified": 1615867200,
"monitor_type": "string",
"name": "string",
"precision": {
"<any-key>": "number"
},
"preview": true,
"sli_value": 99.99,
"span_precision": 2,
"uptime": 99.99
},
"series": {
"denominator": {
"count": 0,
"metadata": {
"aggr": "string",
"expression": "string",
"metric": "string",
"query_index": "integer",
"scope": "string",
"unit": [
{
"family": "bytes",
"id": 2,
"name": "byte",
"plural": "bytes",
"scale_factor": 1,
"short_name": "B"
}
]
},
"sum": 0,
"values": [
[]
]
},
"interval": 0,
"message": "",
"numerator": {
"count": 0,
"metadata": {
"aggr": "string",
"expression": "string",
"metric": "string",
"query_index": "integer",
"scope": "string",
"unit": [
{
"family": "bytes",
"id": 2,
"name": "byte",
"plural": "bytes",
"scale_factor": 1,
"short_name": "B"
}
]
},
"sum": 0,
"values": [
[]
]
},
"query": "",
"res_type": "",
"resp_version": 0,
"times": [
[]
]
},
"thresholds": {
"<any-key>": {
"target": 99.9,
"target_display": "99.9",
"timeframe": "30d",
"warning": 90,
"warning_display": "90.0"
}
},
"to_ts": 1615928790,
"type": "metric",
"type_id": 0
},
"errors": [
{
"error": "string"
}
]
}Bad Request
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Forbidden
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Not Found
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Ejemplo de código
# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export slo_id="CHANGE_ME"
# Required query arguments
export from_ts="CHANGE_ME"
export to_ts="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v1/slo/${slo_id}/history?from_ts=${from_ts}&to_ts=${to_ts}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"// Get an SLO's history returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
// there is a valid "slo" in the system
SloData0ID := os.Getenv("SLO_DATA_0_ID")
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewServiceLevelObjectivesApi(apiClient)
resp, r, err := api.GetSLOHistory(ctx, SloData0ID, time.Now().AddDate(0, 0, -1).Unix(), time.Now().Unix(), *datadogV1.NewGetSLOHistoryOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.GetSLOHistory`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLOHistory`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Get an SLO's history returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.ServiceLevelObjectivesApi;
import com.datadog.api.client.v1.model.SLOHistoryResponse;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ServiceLevelObjectivesApi apiInstance = new ServiceLevelObjectivesApi(defaultClient);
// there is a valid "slo" in the system
String SLO_DATA_0_ID = System.getenv("SLO_DATA_0_ID");
try {
SLOHistoryResponse result =
apiInstance.getSLOHistory(
SLO_DATA_0_ID,
OffsetDateTime.now().plusDays(-1).toInstant().getEpochSecond(),
OffsetDateTime.now().toInstant().getEpochSecond());
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ServiceLevelObjectivesApi#getSLOHistory");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Get an SLO's history returns "OK" response
"""
from datetime import datetime
from dateutil.relativedelta import relativedelta
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.service_level_objectives_api import ServiceLevelObjectivesApi
# there is a valid "slo" in the system
SLO_DATA_0_ID = environ["SLO_DATA_0_ID"]
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ServiceLevelObjectivesApi(api_client)
response = api_instance.get_slo_history(
slo_id=SLO_DATA_0_ID,
from_ts=int((datetime.now() + relativedelta(days=-1)).timestamp()),
to_ts=int(datetime.now().timestamp()),
)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Get an SLO's history returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new
# there is a valid "slo" in the system
SLO_DATA_0_ID = ENV["SLO_DATA_0_ID"]
p api_instance.get_slo_history(SLO_DATA_0_ID, (Time.now + -1 * 86400).to_i, Time.now.to_i)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Get an SLO's history returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_service_level_objectives::GetSLOHistoryOptionalParams;
use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
#[tokio::main]
async fn main() {
// there is a valid "slo" in the system
let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = ServiceLevelObjectivesAPI::with_config(configuration);
let resp = api
.get_slo_history(
slo_data_0_id.clone(),
1636542671,
1636629071,
GetSLOHistoryOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Get an SLO's history returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);
// there is a valid "slo" in the system
const SLO_DATA_0_ID = process.env.SLO_DATA_0_ID as string;
const params: v1.ServiceLevelObjectivesApiGetSLOHistoryRequest = {
sloId: SLO_DATA_0_ID,
fromTs: Math.round(
new Date(new Date().getTime() + -1 * 86400 * 1000).getTime() / 1000
),
toTs: Math.round(new Date().getTime() / 1000),
};
apiInstance
.getSLOHistory(params)
.then((data: v1.SLOHistoryResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"from datadog import initialize, api
import time
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
slo_id = '<YOUR_SLO_ID>'
initialize(**options)
to_ts = int(time.time())
from_ts = to_ts - 60*60*24*30
api.ServiceLevelObjective.history(slo_id, from_ts=from_ts, to_ts=to_ts)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
slo_id = '<YOUR_SLO_ID>'
dog = Dogapi::Client.new(api_key, app_key)
to_ts = 1_571_320_613
from_ts = to_ts - 60 * 60 * 24 * 30
dog.get_service_level_objective_history(slo_id, from_ts, to_ts)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"