Google Cloud (Stackdriver) Monitoring Slo
This page shows how to write Terraform for Cloud (Stackdriver) Monitoring Slo and write them securely.
google_monitoring_slo (Terraform)
The Slo in Cloud (Stackdriver) Monitoring can be configured in Terraform with the resource name google_monitoring_slo. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_monitoring_slo" "window_based_slo" {
service = google_monitoring_custom_service.terraform-service.service_id
slo_id = "terraform-slo"
display_name = "99% of 10-min windows in rolling day have mean latency under 8s"
goal = 0.99
resource "google_monitoring_slo" "home_page_available" {
project = var.project_id
service = data.google_monitoring_cluster_istio_service.frontend_external.service_id
slo_id = "availability-slo"
display_name = "Home Page Available"
resource "google_monitoring_slo" "slo_lbbackend" {
service = google_monitoring_custom_service.service_slo.service_id
display_name = "Standard SLO LB Backend latency"
goal = 0.8
rolling_period_days = 20
resource "google_monitoring_slo" "slo_lbbackend" {
service = google_monitoring_custom_service.service_slo.service_id
display_name = "Standard SLO LB Backend latency"
goal = 0.8
rolling_period_days = 20
resource "google_monitoring_slo" "slo_lbbackend" {
service = google_monitoring_custom_service.service_slo.service_id
display_name = "Standard SLO LB Backend latency"
goal = 0.8
rolling_period_days = 20
Parameters
-
calendar_periodoptional - string
A calendar period, semantically "since the start of the current <calendarPeriod>". Possible values: ["DAY", "WEEK", "FORTNIGHT", "MONTH"]
-
display_nameoptional - string
Name used for UI elements listing this SLO.
-
goalrequired - number
The fraction of service that must be good in order for this objective to be met. 0 < goal <= 0.999
The full resource name for this service. The syntax is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
-
projectoptional computed - string -
rolling_period_daysoptional - number
A rolling time period, semantically "in the past X days". Must be between 1 to 30 days, inclusive.
-
servicerequired - string
ID of the service to which this SLO belongs.
-
slo_idoptional computed - string
The id to use for this ServiceLevelObjective. If omitted, an id will be generated instead.
-
basic_slilist block-
locationoptional - set of string
An optional set of locations to which this SLI is relevant. Telemetry from other locations will not be used to calculate performance for this SLI. If omitted, this SLI applies to all locations in which the Service has activity. For service types that don't support breaking down by location, setting this field will result in an error.
-
methodoptional - set of string
An optional set of RPCs to which this SLI is relevant. Telemetry from other methods will not be used to calculate performance for this SLI. If omitted, this SLI applies to all the Service's methods. For service types that don't support breaking down by method, setting this field will result in an error.
-
versionoptional - set of string
The set of API versions to which this SLI is relevant. Telemetry from other API versions will not be used to calculate performance for this SLI. If omitted, this SLI applies to all API versions. For service types that don't support breaking down by version, setting this field will result in an error.
-
availabilitylist block-
enabledoptional - bool
Whether an availability SLI is enabled or not. Must be set to true. Defaults to 'true'.
-
-
latencylist block-
thresholdrequired - string
A duration string, e.g. 10s. Good service is defined to be the count of requests made to this service that return in no more than threshold.
-
-
-
request_based_slilist block-
distribution_cutlist block-
distribution_filterrequired - string
A TimeSeries monitoring filter aggregating values to quantify the good service provided. Must have ValueType = DISTRIBUTION and MetricKind = DELTA or MetricKind = CUMULATIVE.
-
-
good_total_ratiolist block-
bad_service_filteroptional - string
A TimeSeries monitoring filter quantifying bad service provided, either demanded service that was not provided or demanded service that was of inadequate quality. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. Exactly two of 'good_service_filter','bad_service_filter','total_service_filter' must be set (good + bad = total is assumed).
-
good_service_filteroptional - string
A TimeSeries monitoring filter quantifying good service provided. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. Exactly two of 'good_service_filter','bad_service_filter','total_service_filter' must be set (good + bad = total is assumed).
-
total_service_filteroptional - string
A TimeSeries monitoring filter quantifying total demanded service. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. Exactly two of 'good_service_filter','bad_service_filter','total_service_filter' must be set (good + bad = total is assumed).
-
-
-
timeoutssingle block -
windows_based_slilist block-
good_bad_metric_filteroptional - string
A TimeSeries monitoring filter with ValueType = BOOL. The window is good if any true values appear in the window. One of 'good_bad_metric_filter', 'good_total_ratio_threshold', 'metric_mean_in_range', 'metric_sum_in_range' must be set for 'windows_based_sli'.
-
window_periodoptional - string
Duration over which window quality is evaluated, given as a duration string "[X]s" representing X seconds. Must be an integer fraction of a day and at least 60s.
-
good_total_ratio_thresholdlist block-
thresholdoptional - number
If window performance >= threshold, the window is counted as good.
-
basic_sli_performancelist block-
locationoptional - set of string
An optional set of locations to which this SLI is relevant. Telemetry from other locations will not be used to calculate performance for this SLI. If omitted, this SLI applies to all locations in which the Service has activity. For service types that don't support breaking down by location, setting this field will result in an error.
-
methodoptional - set of string
An optional set of RPCs to which this SLI is relevant. Telemetry from other methods will not be used to calculate performance for this SLI. If omitted, this SLI applies to all the Service's methods. For service types that don't support breaking down by method, setting this field will result in an error.
-
versionoptional - set of string
The set of API versions to which this SLI is relevant. Telemetry from other API versions will not be used to calculate performance for this SLI. If omitted, this SLI applies to all API versions. For service types that don't support breaking down by version, setting this field will result in an error.
-
availabilitylist block-
enabledoptional - bool
Whether an availability SLI is enabled or not. Must be set to 'true. Defaults to 'true'.
-
-
latencylist block-
thresholdrequired - string
A duration string, e.g. 10s. Good service is defined to be the count of requests made to this service that return in no more than threshold.
-
-
-
performancelist block-
distribution_cutlist block-
distribution_filterrequired - string
A TimeSeries monitoring filter aggregating values to quantify the good service provided. Must have ValueType = DISTRIBUTION and MetricKind = DELTA or MetricKind = CUMULATIVE.
-
-
good_total_ratiolist block-
bad_service_filteroptional - string
A TimeSeries monitoring filter quantifying bad service provided, either demanded service that was not provided or demanded service that was of inadequate quality. Exactly two of good, bad, or total service filter must be defined (where good + bad = total is assumed) Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.
-
good_service_filteroptional - string
A TimeSeries monitoring filter quantifying good service provided. Exactly two of good, bad, or total service filter must be defined (where good + bad = total is assumed) Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.
-
total_service_filteroptional - string
A TimeSeries monitoring filter quantifying total demanded service. Exactly two of good, bad, or total service filter must be defined (where good + bad = total is assumed) Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.
-
-
-
-
metric_mean_in_rangelist block-
time_seriesrequired - string
A monitoring filter specifying the TimeSeries to use for evaluating window The provided TimeSeries must have ValueType = INT64 or ValueType = DOUBLE and MetricKind = GAUGE. Mean value 'X' should satisfy 'range.min <= X < range.max' under good service.
-
-
metric_sum_in_rangelist block-
time_seriesrequired - string
A monitoring filter specifying the TimeSeries to use for evaluating window quality. The provided TimeSeries must have ValueType = INT64 or ValueType = DOUBLE and MetricKind = GAUGE. Summed value 'X' should satisfy 'range.min <= X < range.max' for a good window.
-
-
Explanation in Terraform Registry
A Service-Level Objective (SLO) describes the level of desired good service. It consists of a service-level indicator (SLI), a performance goal, and a period over which the objective is to be evaluated against that goal. The SLO can use SLIs defined in a number of different manners. Typical SLOs might include "99% of requests in each rolling week have latency below 200 milliseconds" or "99.5% of requests in each calendar month return successfully." To get more information about Slo, see:
Frequently asked questions
What is Google Cloud (Stackdriver) Monitoring Slo?
Google Cloud (Stackdriver) Monitoring Slo is a resource for Cloud (Stackdriver) Monitoring of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google Cloud (Stackdriver) Monitoring Slo?
For Terraform, the yuriatgoogle/stack-doctor, fawix/boutique-demo-slos-example and tpayne/terraform-examples source code examples are useful. See the Terraform Example section for further details.