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

github-iconyuriatgoogle/stack-doctor
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
github-iconfawix/boutique-demo-slos-example
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"

github-icontpayne/terraform-examples
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
github-icontpayne/terraform-examples
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
github-icontpayne/terraform-examples
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_period optional - string
    • A calendar period, semantically "since the start of the current <calendarPeriod>". Possible values: ["DAY", "WEEK", "FORTNIGHT", "MONTH"]

  • display_name optional - string
    • Name used for UI elements listing this SLO.

  • goal required - number
    • The fraction of service that must be good in order for this objective to be met. 0 < goal <= 0.999

  • id optionalcomputed - string
  • name requiredcomputed - string
    • The full resource name for this service. The syntax is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]

  • project optionalcomputed - string
  • rolling_period_days optional - number
    • A rolling time period, semantically "in the past X days". Must be between 1 to 30 days, inclusive.

  • service required - string
    • ID of the service to which this SLO belongs.

  • slo_id optionalcomputed - string
    • The id to use for this ServiceLevelObjective. If omitted, an id will be generated instead.

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.

security-icon

Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.