Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLO: Implements SLO Datasource and SLO Resource #890

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
23ba3d3
slo: Support SLO Datasource Read Functionality
elainevuong Mar 29, 2023
b9e8d63
slo: Support SLO Resource Create Functionality
elainevuong Mar 31, 2023
64b90ce
slo: Adds a resourceSloRead method to the SLO Resource Create Functio…
elainevuong Apr 3, 2023
3f5a8fb
Modify README
elainevuong Apr 3, 2023
e2ceedc
slo: Support SLO Resource Delete Functionality
elainevuong Apr 3, 2023
1af04a0
slo: Support SLO Resource Update Functionality
elainevuong Apr 4, 2023
0453983
slo: Support SLO Resource Import Functionality
elainevuong Apr 4, 2023
f4d7f01
slo: Update Testing READMEs, implement SLO Datasource HG Functionality
elainevuong Apr 12, 2023
6b399bc
slo: Implement SLO Resource CREATE and READ HG Functionality and Test…
elainevuong Apr 12, 2023
abc322e
slo: Implement SLO Resource UPDATE HG Functionality and Testing READMEs
elainevuong Apr 12, 2023
639bd4b
slo: Implement SLO Resource DESTROY HG Functionality and Testing READMEs
elainevuong Apr 12, 2023
e3cae37
slo: Implement SLO Resource IMPORT HG Functionality and Update Testin…
elainevuong Apr 12, 2023
51ee8af
Modify Grafana Client for the ListSLOs functionality for the Datasour…
elainevuong Apr 18, 2023
ec907b3
Modify Grafana Client and Terraform Provider for the GetSLO and Creat…
elainevuong Apr 18, 2023
16e94a9
Modify Grafana Client and Terraform Provider for the DeleteSLO functi…
elainevuong Apr 18, 2023
924fee8
Modify Grafana Client and Terraform Provider for the UpdateSLO functi…
elainevuong Apr 18, 2023
98c6ec3
Testing - Checking Initial Resource Attributes and Attribute Sets
elainevuong Apr 18, 2023
1c4e53a
Updates READMEs for testing
elainevuong Apr 19, 2023
067d2b9
Updated to replace the specific branch on the Grafana API Golang Client
elainevuong Apr 19, 2023
aa6c7c9
Adding Testing Functions to check for Slo existence and Slo destroy
elainevuong Apr 20, 2023
10cd20c
Updated the Grafana API Wrapper Update Method on UpdateSlo
elainevuong Apr 20, 2023
8159de5
Modify UUID Naming in GAPI
elainevuong Apr 20, 2023
a059c87
Merge branch 'master' into elainevuong/slo
elainevuong Apr 20, 2023
3fa6c78
Update Linting Comments
elainevuong Apr 20, 2023
1ce6f8e
Merge branch 'elainevuong/slo' of https://github.com/grafana/terrafor…
elainevuong Apr 20, 2023
c556886
Tests Passing for SLO Resources
elainevuong Apr 24, 2023
7c4838e
Update Variable Naming and Branch Reference in go.mod
elainevuong Apr 24, 2023
0f45dec
Added Update Test for SLO Resources
elainevuong Apr 24, 2023
0266403
Adding Checks for Empty SLOs for Datasource ListSlos Read
elainevuong Apr 24, 2023
a7f7970
Adds checks for nil alertData, fastBurn/slowBurn and tests
elainevuong Apr 24, 2023
87852c4
Added Tests for Invalid Queries and Invalid Objectives
elainevuong Apr 24, 2023
d95d024
Updating Tests
elainevuong Apr 24, 2023
461da7f
Adding Error Messages and Datasource SLO Tests
elainevuong Apr 25, 2023
c42efe9
Modifies GAPI Branch Reference
elainevuong Apr 25, 2023
59b24ed
Updating Docs and Descriptions on Resources
elainevuong Apr 26, 2023
c1af1d3
Merge branch 'master' into elainevuong/slo
elainevuong Apr 26, 2023
b1603f8
Updating Docs and Description on SLO Datasource
elainevuong Apr 26, 2023
5f6d81b
Update Formatting
elainevuong Apr 26, 2023
91c0b75
Revert Drone Changes
elainevuong Apr 26, 2023
f79086f
Formatting
elainevuong Apr 26, 2023
995f953
Updates GAPI Branch
elainevuong Apr 27, 2023
fd06f45
Merge branch 'master' into elainevuong/slo
elainevuong Apr 27, 2023
d681701
Add Instructions for Testing SLO Resources
elainevuong Apr 27, 2023
1fbfb63
Merge branch 'elainevuong/slo' of https://github.com/grafana/terrafor…
elainevuong Apr 27, 2023
1e37f1e
Update the Schema for the Query to match the API Types
elainevuong May 1, 2023
88c72ee
Query Labels Packed
elainevuong May 1, 2023
27f3502
Update Error Handling for Query Types Not Yet Implemented
elainevuong May 1, 2023
f625f39
Updating Datasource and Resource Fields on HCL Schema
elainevuong May 1, 2023
dd7fcfe
Updating Testing Files
elainevuong May 1, 2023
555bbea
Regenerate Documentation
elainevuong May 1, 2023
47503a2
Terraform FMT and Modifying Tests
elainevuong May 1, 2023
e2a136c
Updated Docs and Tests
elainevuong May 1, 2023
5fe1b0e
Correct Test Query
elainevuong May 1, 2023
2af66cc
Updating Unpack Functionality for modified Query Type
elainevuong May 1, 2023
6623c58
Updating Resources
elainevuong May 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions docs/data-sources/slo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "grafana_slo Data Source - terraform-provider-grafana"
subcategory: "SLO"
description: |-
Datasource for retrieving all SLOs.
Official documentation https://grafana.com/docs/grafana-cloud/slo/API documentation https://grafana.com/docs/grafana-cloud/slo/api/
---

# grafana_slo (Data Source)
elainevuong marked this conversation as resolved.
Show resolved Hide resolved

Datasource for retrieving all SLOs.

* [Official documentation](https://grafana.com/docs/grafana-cloud/slo/)
* [API documentation](https://grafana.com/docs/grafana-cloud/slo/api/)

## Example Usage

```terraform
data "grafana_slo" "slos" {}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `id` (String) The ID of this resource.
- `slos` (List of Object) Returns a list of all SLOs" (see [below for nested schema](#nestedatt--slos))

<a id="nestedatt--slos"></a>
### Nested Schema for `slos`

Read-Only:

- `alerting` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting))
- `dashboard_uid` (String)
- `description` (String)
- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--slos--labels))
- `name` (String)
- `objectives` (List of Object) (see [below for nested schema](#nestedobjatt--slos--objectives))
- `query` (String)
- `uuid` (String)

<a id="nestedobjatt--slos--alerting"></a>
### Nested Schema for `slos.alerting`

Read-Only:

- `annotations` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--annotations))
- `fastburn` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--fastburn))
- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--labels))
- `name` (String)
- `slowburn` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--slowburn))

<a id="nestedobjatt--slos--alerting--annotations"></a>
### Nested Schema for `slos.alerting.annotations`

Read-Only:

- `key` (String)
- `value` (String)


<a id="nestedobjatt--slos--alerting--fastburn"></a>
### Nested Schema for `slos.alerting.fastburn`

Read-Only:

- `annotations` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--fastburn--annotations))
- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--fastburn--labels))

<a id="nestedobjatt--slos--alerting--fastburn--annotations"></a>
### Nested Schema for `slos.alerting.fastburn.labels`

Read-Only:

- `key` (String)
- `value` (String)


<a id="nestedobjatt--slos--alerting--fastburn--labels"></a>
### Nested Schema for `slos.alerting.fastburn.labels`

Read-Only:

- `key` (String)
- `value` (String)



<a id="nestedobjatt--slos--alerting--labels"></a>
### Nested Schema for `slos.alerting.labels`

Read-Only:

- `key` (String)
- `value` (String)


<a id="nestedobjatt--slos--alerting--slowburn"></a>
### Nested Schema for `slos.alerting.slowburn`

Read-Only:

- `annotations` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--slowburn--annotations))
- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--slos--alerting--slowburn--labels))

<a id="nestedobjatt--slos--alerting--slowburn--annotations"></a>
### Nested Schema for `slos.alerting.slowburn.labels`

Read-Only:

- `key` (String)
- `value` (String)


<a id="nestedobjatt--slos--alerting--slowburn--labels"></a>
### Nested Schema for `slos.alerting.slowburn.labels`

Read-Only:

- `key` (String)
- `value` (String)




<a id="nestedobjatt--slos--labels"></a>
### Nested Schema for `slos.labels`

Read-Only:

- `key` (String)
- `value` (String)


<a id="nestedobjatt--slos--objectives"></a>
### Nested Schema for `slos.objectives`

Read-Only:

- `objective_value` (Number)
- `objective_window` (String)


183 changes: 183 additions & 0 deletions docs/resources/slo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "grafana_slo Resource - terraform-provider-grafana"
subcategory: "SLO"
description: |-
Resource manages Grafana SLOs.
Official documentation https://grafana.com/docs/grafana-cloud/slo/API documentation https://grafana.com/docs/grafana-cloud/slo/api/
---

# grafana_slo (Resource)

Resource manages Grafana SLOs.

* [Official documentation](https://grafana.com/docs/grafana-cloud/slo/)
* [API documentation](https://grafana.com/docs/grafana-cloud/slo/api/)

## Example Usage

```terraform
resource "grafana_slo" "test" {
name = "Terraform Testing"
description = "Terraform Description"
query = "sum(rate(apiserver_request_total{code!=\"500\"}[$__rate_interval])) / sum(rate(apiserver_request_total[$__rate_interval]))"
objectives {
objective_value = 0.995
objective_window = "30d"
elainevuong marked this conversation as resolved.
Show resolved Hide resolved
}
labels {
key = "custom"
value = "value"
}
alerting {
fastburn {
annotations {
key = "name"
value = "Critical - SLO Burn Rate Alert"
}
labels {
key = "type"
value = "slo"
}
}

slowburn {
annotations {
key = "name"
value = "Warning - SLO Burn Rate Alert"
}
labels {
key = "type"
value = "slo"
}
}
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `description` (String) Description is a free-text field that can provide more context to an SLO.
- `name` (String) Name should be a short description of your indicator. Consider names like "API Availability"
- `objectives` (Block List, Min: 1, Max: 1) Over each rolling time window, the remaining error budget will be calculated, and separate alerts can be generated for each time window based on the SLO burn rate or remaining error budget. (see [below for nested schema](#nestedblock--objectives))
- `query` (String) Query describes the indicator that will be measured against the objective. Freeform Query types are currently supported.

### Optional

- `alerting` (Block List) Configures the alerting rules that will be generated for each
time window associated with the SLO. Grafana SLOs can generate
alerts when the short-term error budget burn is very high, the
long-term error budget burn rate is high, or when the remaining
error budget is below a certain threshold. (see [below for nested schema](#nestedblock--alerting))
- `labels` (Block List) Additional labels that will be attached to all metrics generated from the query. These labels are useful for grouping SLOs in dashboard views that you create by hand. (see [below for nested schema](#nestedblock--labels))

### Read-Only

- `dashboard_uid` (String) A reference to a dashboard that the plugin has installed in Grafana based on this SLO. This field is read-only, it is generated by the Grafana SLO Plugin.
- `id` (String) The ID of this resource.

<a id="nestedblock--objectives"></a>
### Nested Schema for `objectives`

Required:

- `objective_value` (Number) Value between 0 and 1. If the value of the query is above the objective, the SLO is met.
- `objective_window` (String) A Prometheus-parsable time duration string like 24h, 60m. This is the time window the objective is measured over.


<a id="nestedblock--alerting"></a>
### Nested Schema for `alerting`

Optional:

- `annotations` (Block List) Annotations will be attached to all alerts generated by any of these rules. (see [below for nested schema](#nestedblock--alerting--annotations))
- `fastburn` (Block List) Alerting Rules generated for Fast Burn alerts (see [below for nested schema](#nestedblock--alerting--fastburn))
- `labels` (Block List) Labels will be attached to all alerts generated by any of these rules. (see [below for nested schema](#nestedblock--alerting--labels))
- `name` (String)
- `slowburn` (Block List) Alerting Rules generated for Slow Burn alerts (see [below for nested schema](#nestedblock--alerting--slowburn))

<a id="nestedblock--alerting--annotations"></a>
### Nested Schema for `alerting.annotations`

Required:

- `key` (String)
- `value` (String)


<a id="nestedblock--alerting--fastburn"></a>
### Nested Schema for `alerting.fastburn`

Optional:

- `annotations` (Block List) Annotations to attach only to Fast Burn alerts. (see [below for nested schema](#nestedblock--alerting--fastburn--annotations))
- `labels` (Block List) Labels to attach only to Fast Burn alerts. (see [below for nested schema](#nestedblock--alerting--fastburn--labels))

<a id="nestedblock--alerting--fastburn--annotations"></a>
### Nested Schema for `alerting.fastburn.annotations`

Required:

- `key` (String)
- `value` (String)


<a id="nestedblock--alerting--fastburn--labels"></a>
### Nested Schema for `alerting.fastburn.labels`

Required:

- `key` (String)
- `value` (String)



<a id="nestedblock--alerting--labels"></a>
### Nested Schema for `alerting.labels`

Required:

- `key` (String)
- `value` (String)


<a id="nestedblock--alerting--slowburn"></a>
### Nested Schema for `alerting.slowburn`

Optional:

- `annotations` (Block List) Annotations to attach only to Slow Burn alerts. (see [below for nested schema](#nestedblock--alerting--slowburn--annotations))
- `labels` (Block List) Labels to attach only to Slow Burn alerts. (see [below for nested schema](#nestedblock--alerting--slowburn--labels))

<a id="nestedblock--alerting--slowburn--annotations"></a>
### Nested Schema for `alerting.slowburn.annotations`

Required:

- `key` (String)
- `value` (String)


<a id="nestedblock--alerting--slowburn--labels"></a>
### Nested Schema for `alerting.slowburn.labels`

Required:

- `key` (String)
- `value` (String)




<a id="nestedblock--labels"></a>
### Nested Schema for `labels`

Required:

- `key` (String)
- `value` (String)


1 change: 1 addition & 0 deletions examples/data-sources/grafana_slo/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data "grafana_slo" "slos" {}
36 changes: 36 additions & 0 deletions examples/resources/grafana_slo/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
resource "grafana_slo" "test" {
name = "Terraform Testing"
description = "Terraform Description"
query = "sum(rate(apiserver_request_total{code!=\"500\"}[$__rate_interval])) / sum(rate(apiserver_request_total[$__rate_interval]))"
objectives {
objective_value = 0.995
objective_window = "30d"
}
labels {
key = "custom"
value = "value"
}
alerting {
fastburn {
annotations {
key = "name"
value = "Critical - SLO Burn Rate Alert"
}
labels {
key = "type"
value = "slo"
}
}

slowburn {
annotations {
key = "name"
value = "Warning - SLO Burn Rate Alert"
}
labels {
key = "type"
value = "slo"
}
}
}
}
Loading