grafana_slo (Resource)

Resource manages Grafana SLOs.

Example Usage

Basic

resource "grafana_slo" "test" {
  name        = "Terraform Testing"
  description = "Terraform Description"
  query {
    freeform {
      query = "sum(rate(apiserver_request_total{code!=\"500\"}[$__rate_interval])) / sum(rate(apiserver_request_total[$__rate_interval]))"
    }
    type = "freeform"
  }
  objectives {
    value  = 0.995
    window = "30d"
  }
  destination_datasource {
    uid = "grafanacloud-prom"
  }
  label {
    key   = "slo"
    value = "terraform"
  }
  alerting {
    fastburn {
      annotation {
        key   = "name"
        value = "SLO Burn Rate Very High"
      }
      annotation {
        key   = "description"
        value = "Error budget is burning too fast"
      }
    }

    slowburn {
      annotation {
        key   = "name"
        value = "SLO Burn Rate High"
      }
      annotation {
        key   = "description"
        value = "Error budget is burning too fast"
      }
    }
  }
}

Advanced

resource "grafana_slo" "test" {
  name        = "Complex Resource - Terraform Ratio Query Example"
  description = "Complex Resource - Terraform Ratio Query Description"
  query {
    ratio {
      success_metric  = "kubelet_http_requests_total{status!~\"5..\"}"
      total_metric    = "kubelet_http_requests_total"
      group_by_labels = ["job", "instance"]
    }
    type = "ratio"
  }
  objectives {
    value  = 0.995
    window = "30d"
  }
  destination_datasource {
    uid = "grafanacloud-prom"
  }
  label {
    key   = "slo"
    value = "terraform"
  }
  alerting {
    fastburn {
      annotation {
        key   = "name"
        value = "SLO Burn Rate Very High"
      }
      annotation {
        key   = "description"
        value = "Error budget is burning too fast"
      }
      label {
        key   = "type"
        value = "slo"
      }
    }

    slowburn {
      annotation {
        key   = "name"
        value = "SLO Burn Rate High"
      }
      annotation {
        key   = "description"
        value = "Error budget is burning too fast"
      }
      label {
        key   = "type"
        value = "slo"
      }
    }
  }
}

Schema

Required

Optional

Read-Only

Nested Schema for objectives

Required:

Nested Schema for query

Required:

Optional:

Nested Schema for query.freeform

Required:

Nested Schema for query.ratio

Required:

Optional:

Nested Schema for alerting

Optional:

Nested Schema for alerting.annotation

Required:

Nested Schema for alerting.fastburn

Optional:

Nested Schema for alerting.fastburn.annotation

Required:

Nested Schema for alerting.fastburn.label

Required:

Nested Schema for alerting.label

Required:

Nested Schema for alerting.slowburn

Optional:

Nested Schema for alerting.slowburn.annotation

Required:

Nested Schema for alerting.slowburn.label

Required:

Nested Schema for destination_datasource

Optional:

Nested Schema for label

Required:

Import

Import is supported using the following syntax:

terraform import grafana_slo.name "{{ uuid }}"