For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/ko/api/latest/service-level-objectives/create-an-slo-object.md. A documentation index is available at /llms.txt.
Language
Datadog site

SLO 개체 생성하기

POSThttps://api.datadoghq.com/api/v1/slohttps://api.us3.datadoghq.com/api/v1/slohttps://api.us5.datadoghq.com/api/v1/slohttps://api.datadoghq.eu/api/v1/slohttps://api.ap1.datadoghq.com/api/v1/slohttps://api.ap2.datadoghq.com/api/v1/slohttps://api.uk1.datadoghq.com/api/v1/slohttps://api.ddog-gov.com/api/v1/slohttps://api.us2.ddog-gov.com/api/v1/slo

개요

서비스 수준 목표 객체를 생성합니다.

This endpoint requires the slos_write permission.

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

요청

Body Data (required)

서비스 수준 목표 요청 객체입니다.

항목
유형
설명
description
string

서비스 수준 목표 객체에는 서비스 수준 지표, 하나 이상의 타임프레임에 대한 임계값과 메타데이터(name, description, tags 등)가 포함됩니다.

groups
[string]

A list of (up to 100) monitor groups that narrow the scope of a monitor service level objective.

Included in service level objective responses if it is not empty. Optional in create/update requests for monitor service level objectives, but may only be used when then length of the monitor_ids field is one.

monitor_ids
[integer]

A list of monitor IDs that defines the scope of a monitor service level objective. Required if type is monitor.

name [required]
string

The name of the service level objective object.

query
object

A count-based (metric) SLO query. This field is superseded by sli_specification but is retained for backwards compatibility. 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.

sli_specification
<oneOf>

A generic SLI specification. This is used for time-slice and count-based (metric) SLOs only.

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.

target_threshold
double

The target threshold such that when the service level indicator is above this threshold over the given timeframe, the objective is being met.

thresholds [required]
[object]

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

timeframe
enum

The SLO time window options. Note that "custom" is not a valid option for creating or updating SLOs. It is only used when querying SLO history over custom timeframes.

Allowed enum values: 7d, 30d, 90d, custom
type [required]
enum

The type of the service level objective.

Allowed enum values: metric, monitor, time_slice
warning_threshold
double

The optional warning threshold such that when the service level indicator is below this value for the given threshold, but above the target threshold, the objective appears in a "warning" state. This value must be greater than the target threshold.

응답

OK

A response with one or more service level objective.

항목
유형
설명
data
[object]

An array of service level objective objects.

errors
[string]

An array of error messages. Each endpoint documents how/whether this field is used.

metadata
object

The metadata object containing additional information about the list of SLOs.

코드 예시

Create a new metric SLO object using bad events formula returns "OK" response
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "bad_events_formula": {
        "formula": "query2"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
Create a new metric SLO object using sli_specification returns "OK" response
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "metric",
  "description": "Metric SLO using sli_specification",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "count": {
      "good_events_formula": {
        "formula": "query1 - query2"
      },
      "total_events_formula": {
        "formula": "query1"
      },
      "queries": [
        {
          "data_source": "metrics",
          "name": "query1",
          "query": "sum:httpservice.hits{*}.as_count()"
        },
        {
          "data_source": "metrics",
          "name": "query2",
          "query": "sum:httpservice.errors{*}.as_count()"
        }
      ]
    }
  },
  "tags": [
    "env:prod",
    "type:count"
  ],
  "thresholds": [
    {
      "target": 99.0,
      "target_display": "99.0",
      "timeframe": "7d",
      "warning": 99.5,
      "warning_display": "99.5"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 99.0,
  "warning_threshold": 99.5
}
EOF
Create a time-slice SLO object returns "OK" response
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v1/slo" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "type": "time_slice",
  "description": "string",
  "name": "Example-Service-Level-Objective",
  "sli_specification": {
    "time_slice": {
      "query": {
        "formulas": [
          {
            "formula": "query1"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "query1",
            "query": "trace.servlet.request{env:prod}"
          }
        ]
      },
      "comparator": ">",
      "threshold": 5
    }
  },
  "tags": [
    "env:prod"
  ],
  "thresholds": [
    {
      "target": 97.0,
      "target_display": "97.0",
      "timeframe": "7d",
      "warning": 98,
      "warning_display": "98.0"
    }
  ],
  "timeframe": "7d",
  "target_threshold": 97.0,
  "warning_threshold": 98
}
EOF