Provides a Datadog service level objective resource. This can be used to create and manage Datadog service level objectives.
# Metric-Based SLO
# Create a new Datadog service level objective
resource "datadog_service_level_objective" "foo" {
name = "Example Metric SLO"
type = "metric"
description = "My custom metric SLO"
query {
numerator = "sum:my.custom.count.metric{type:good_events}.as_count()"
denominator = "sum:my.custom.count.metric{*}.as_count()"
}
thresholds {
timeframe = "7d"
target = 99.9
warning = 99.99
}
thresholds {
timeframe = "30d"
target = 99.9
warning = 99.99
}
timeframe = "30d"
target_threshold = 99.9
warning_threshold = 99.99
tags = ["foo:bar", "baz"]
}
# Monitor-Based SLO
# Create a new Datadog service level objective
resource "datadog_service_level_objective" "bar" {
name = "Example Monitor SLO"
type = "monitor"
description = "My custom monitor SLO"
monitor_ids = [1, 2, 3]
thresholds {
timeframe = "7d"
target = 99.9
warning = 99.99
}
thresholds {
timeframe = "30d"
target = 99.9
warning = 99.99
}
timeframe = "30d"
target_threshold = 99.9
warning_threshold = 99.99
tags = ["foo:bar", "baz"]
}
resource "datadog_service_level_objective" "time_slice_slo" {
name = "Example Time Slice SLO"
type = "time_slice"
description = "My custom time slice SLO"
sli_specification {
time_slice {
query {
formula {
formula_expression = "query1"
}
query {
metric_query {
name = "query1"
query = "avg:my.custom.count.metric{*}.as_count()"
}
}
}
comparator = ">"
threshold = 0.9
}
}
thresholds {
timeframe = "7d"
target = 99.9
warning = 99.99
}
timeframe = "7d"
target_threshold = 99.9
warning_threshold = 99.99
tags = ["service:myservice", "team:myteam"]
}
name
(String) Name of Datadog service level objectivethresholds
(Block List, Min: 1) A list of thresholds and targets that define the service level objectives from the provided SLIs. (see below for nested schema)type
(String) The type of the service level objective. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API documentation page. Valid values are metric
, monitor
, time_slice
.description
(String) A description of this service level objective.force_delete
(Boolean) A boolean indicating whether this monitor can be deleted even if it's referenced by other resources (for example, dashboards).groups
(Set of String) A static set of groups to filter monitor-based SLOsmonitor_ids
(Set of Number) A static set of monitor IDs to use as part of the SLOquery
(Block List, Max: 1) The metric query of good / total events (see below for nested schema)sli_specification
(Block List, Max: 1) A map of SLI specifications to use as part of the SLO. (see below for nested schema)tags
(Set of String) A list of tags to associate with your service level objective. This can help you categorize and filter service level objectives in the service level objectives page of the UI. Note: it's not currently possible to filter by these tags when querying via the APItarget_threshold
(Number) The objective's target in (0,100)
. This must match the corresponding thresholds of the primary time frame.timeframe
(String) The primary time frame for the objective. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API documentation page. Valid values are 7d
, 30d
, 90d
, custom
.validate
(Boolean) Whether or not to validate the SLO.warning_threshold
(Number) The objective's warning value in (0,100)
. This must be greater than the target value and match the corresponding thresholds of the primary time frame.id
(String) The ID of this resource.thresholds
Required:
target
(Number) The objective's target in (0,100)
.timeframe
(String) The time frame for the objective. The mapping from these types to the types found in the Datadog Web UI can be found in the Datadog API documentation page. Valid values are 7d
, 30d
, 90d
, custom
.Optional:
warning
(Number) The objective's warning value in (0,100)
. This must be greater than the target value.Read-Only:
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
).warning_display
(String) A string representation of the warning target (see the description of the target_display field for details).query
Required:
denominator
(String) The sum of the total
events.numerator
(String) The sum of all the good
events.sli_specification
Required:
time_slice
(Block List, Min: 1, Max: 1) The time slice condition, composed of 3 parts: 1. The timeseries query, 2. The comparator, and 3. The threshold. Optionally, a fourth part, the query interval, can be provided. (see below for nested schema)sli_specification.time_slice
Required:
comparator
(String) The comparator used to compare the SLI value to the threshold. Valid values are >
, >=
, <
, <=
.query
(Block List, Min: 1, Max: 1) A timeseries query, containing named data-source-specific queries and a formula involving the named queries. (see below for nested schema)threshold
(Number) The threshold value to which each SLI value will be compared.Optional:
query_interval_seconds
(Number) The interval used when querying data, which defines the size of a time slice. Valid values are 60
, 300
. Defaults to 300
.sli_specification.time_slice.query
Required:
formula
(Block List, Min: 1, Max: 1) A list that contains exactly one formula, as only a single formula may be used to define a timeseries query for a time-slice SLO. (see below for nested schema)query
(Block List, Min: 1) A list of data-source-specific queries that are in the formula. (see below for nested schema)sli_specification.time_slice.query.formula
Required:
formula_expression
(String) The formula string, which is an expression involving named queries.sli_specification.time_slice.query.query
Optional:
metric_query
(Block List, Max: 1) A timeseries formula and functions metrics query. (see below for nested schema)sli_specification.time_slice.query.query.metric_query
Required:
name
(String) The name of the query for use in formulas.query
(String) The metrics query definition.Optional:
data_source
(String) The data source for metrics queries. Defaults to "metrics"
.Import is supported using the following syntax:
# Service Level Objectives can be imported using their string ID, e.g.
terraform import datadog_service_level_objective.baz 12345678901234567890123456789012