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 #910

Merged
merged 58 commits into from
May 9, 2023

Conversation

elainevuong
Copy link
Contributor

This PR implements a SLO Datasource (READ) and a SLO Resource (CRUD + Import) to the Grafana Terraform Provider.

Needs to be reviewed in conjunction with this PR on the Grafana Go API Client

For anyone who wants to test this on sloapp, feel free to check out the instructions within slo-testing-README.md within the slo_testing directory.

Detailed steps are provided for testing the TF Provider CRUD and Import Functionality.

…eSLO functionality for the ResourceSLOCreate and ResourceSLORead Methods
…onality for the resourceSloUpdate method, removes the Local Dev Testing Files
@elainevuong elainevuong requested a review from a team as a code owner May 3, 2023 18:51
@github-actions
Copy link

github-actions bot commented May 3, 2023

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. To do so, a Grafana Labs employee must promote the Drone build.

For maintainers, it's better to run only the Cloud tests you need, rather than all of them. You can do so by setting the following parameter when promoting:

TESTARGS='-run=<testname>'

@elainevuong
Copy link
Contributor Author

Latest look at our HCL Schema is here for anyone that is curious:

We will stick with a nested structure, and I've extracted out a string that specifies our query type. Anything other than the string "freeform" will throw a validation error on the TF Provider side indicating that the query type hasn't been implemented yet.

resource "grafana_slo" "test" {
  name        = "Terraform Testing"
  description = "Terraform Description"
  query {
    freeformquery = "sum(rate(apiserver_request_total{code!=\"500\"}[$__rate_interval])) / sum(rate(apiserver_request_total[$__rate_interval]))"
    type          = "freeform"
  }
  objectives {
    value  = 0.995
    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"
      }
    }
  }
}

@elainevuong
Copy link
Contributor Author

hey @joeblubaugh - do you mind deploying the latest version of our SLO Plugin to the terraformprovidergrafana2 stack.

Once that's done, the tests should pass, and you can start your review.

Copy link
Member

@julienduchesne julienduchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some initial comments. Some of them imply pretty big changes (simplifying the code a bit) so I'd like to give another review after you've looked over my comments

go.mod Outdated Show resolved Hide resolved
internal/resources/slo/data_source_slo.go Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
@elainevuong elainevuong requested a review from julienduchesne May 5, 2023 18:05
examples/resources/grafana_slo/resource_complex.tf Outdated Show resolved Hide resolved
internal/resources/slo/data_source_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Show resolved Hide resolved
Copy link
Member

@julienduchesne julienduchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about SLOs but the TF stuff looks great!

internal/resources/slo/data_source_slo.go Outdated Show resolved Hide resolved
Copy link
Member

@julienduchesne julienduchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about SLOs but the TF stuff looks great!

Copy link
Member

@julienduchesne julienduchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about SLOs but the TF stuff looks great!

Copy link
Contributor

@joeblubaugh joeblubaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do "freeformquery" -> "freeform" in the schema. Otherwise looks great, and once done feel free to merge.

docs/data-sources/slos.md Outdated Show resolved Hide resolved
internal/resources/slo/resource_slo.go Outdated Show resolved Hide resolved
@elainevuong elainevuong merged commit ef7fa57 into master May 9, 2023
@elainevuong elainevuong deleted the elainevuong/slo-query branch May 9, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants