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

[WIP] feat(bigTent slo): Custom Validate function for big tent SLO schema #2016

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
97b18b9
feat(bigTent slo): Custom Validate function for big tent SLO schema
Leo-DiCara Jan 31, 2025
ab44728
Merge branch 'main' into ld/big_tent_validate
Leo-DiCara Jan 31, 2025
4231bd0
feat(bigTent slo): Tests for custom validate functions
Leo-DiCara Feb 1, 2025
fa7583a
Merge branch 'ld/big_tent_validate' of github.com:grafana/terraform-p…
Leo-DiCara Feb 1, 2025
f514eb0
feat(bigTent slo): fmt
Leo-DiCara Feb 3, 2025
1efd39b
feat(bigTent slo): removing derpecated reliance
Leo-DiCara Feb 3, 2025
2c6b7c9
feat(bigTent slo): fmt
Leo-DiCara Feb 3, 2025
7da58a2
feat(bigTent slo): fmt
Leo-DiCara Feb 3, 2025
b16d7d6
Merge branch 'main' into ld/big_tent_validate
Leo-DiCara Feb 3, 2025
9697dc6
feat(bigTent slo): fix overzealous id refactor
Leo-DiCara Feb 3, 2025
73ebdf2
Merge branch 'ld/big_tent_validate' of github.com:grafana/terraform-p…
Leo-DiCara Feb 3, 2025
6b77ed8
feat(bigTent slo): ignore http redirect for link checker
Leo-DiCara Feb 4, 2025
964ddd4
Merge branch 'main' into ld/big_tent_validate
Leo-DiCara Feb 4, 2025
9dcb2f6
feat(bigTent slo): Drop warning on Prometheus queries
Leo-DiCara Feb 7, 2025
ffecf7e
Merge branch 'ld/big_tent_validate' of github.com:grafana/terraform-p…
Leo-DiCara Feb 7, 2025
6df417a
Merge branch 'main' into ld/big_tent_validate
Leo-DiCara Feb 7, 2025
e60b741
chore(bigTent slo): WIP update documentation
Leo-DiCara Feb 10, 2025
26d9371
Merge branch 'ld/big_tent_validate' of github.com:grafana/terraform-p…
Leo-DiCara Feb 11, 2025
4881fef
chore(bigTent slo): update documentation
Leo-DiCara Feb 11, 2025
a392c84
chore(bigTent slo): update documentation
Leo-DiCara Feb 11, 2025
ac83149
chore(bigTent slo): update documentation
Leo-DiCara Feb 11, 2025
ffd495b
chore(doc links): fixing terraform provider doc links
Leo-DiCara Feb 11, 2025
6fab993
chore(doc links): fixing terraform provider doc links
Leo-DiCara Feb 11, 2025
7341ebe
chore(doc links): fixing terraform provider doc links
Leo-DiCara Feb 11, 2025
e8877fa
chore(slo provider): update to new query type
Leo-DiCara Feb 18, 2025
ad17b07
Merge branch 'main' into ld/big_tent_validate
Leo-DiCara Feb 18, 2025
c1c19e9
chore(slo provider): fixing grafana_queries for tf format
Leo-DiCara Feb 18, 2025
3c90dc7
chore(slo provider): docs
Leo-DiCara Feb 18, 2025
b0ee9a4
chore(slo provider): update failure for prometheus queries in grafana…
Leo-DiCara Feb 18, 2025
6a566c4
chore(slo provider): fmt
Leo-DiCara Feb 18, 2025
100c49a
chore(slo provider): remove from ratio queries
Leo-DiCara Feb 20, 2025
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
9 changes: 9 additions & 0 deletions docs/data-sources/slos.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ Read-Only:
Read-Only:

- `freeform` (List of Object) (see [below for nested schema](#nestedobjatt--slos--query--freeform))
- `grafana_queries` (List of Object) (see [below for nested schema](#nestedobjatt--slos--query--grafana_queries))
- `ratio` (List of Object) (see [below for nested schema](#nestedobjatt--slos--query--ratio))
- `type` (String)

Expand All @@ -225,6 +226,14 @@ Read-Only:
- `query` (String)


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

Read-Only:

- `grafana_queries` (String)


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

Expand Down
119 changes: 117 additions & 2 deletions docs/resources/slo.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,112 @@ resource "grafana_slo" "test" {
}
```

## Enterprise Datasources

Currently supported datasources: AppDynamics, Splunk, Graphite

Enterprise Datasource queries use the freeform query field. It expects a JSON string list of valid grafana query JSON objects.
For additional help, view our [documentation](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/).

```terraform
resource "grafana_slo" "test" {
name = "Terraform Testing"
description = "Terraform Description"
query {
grafana_queries {
grafana_queries = jsonencode([
{
aggregation : "Sum",
alias : "",
application : "57831",
applicationName : "petclinic",
datasource : {
type : "dlopes7-appdynamics-datasource",
uid : "appdynamics_localdev"
},
delimiter : "|",
isRawQuery : false,
metric : "Service Endpoints|PetClinicEastTier1|/petclinic/api_SERVLET|Errors per Minute",
queryType : "metrics",
refId : "errors",
rollUp : true,
schemaVersion : "3.9.5",
transformLegend : "Segments",
transformLegendText : ""
},
{
aggregation : "Sum",
alias : "",
application : "57831",
applicationName : "petclinic",
datasource : {
type : "dlopes7-appdynamics-datasource",
uid : "appdynamics_localdev"
},
intervalMs : 1000,
maxDataPoints : 43200,
delimiter : "|",
isRawQuery : false,
metric : "Service Endpoints|PetClinicEastTier1|/petclinic/api_SERVLET|Calls per Minute",
queryType : "metrics",
refId : "total",
rollUp : true,
schemaVersion : "3.9.5",
transformLegend : "Segments",
transformLegendText : ""
},
{
datasource : {
type : "__expr__",
uid : "__expr__"
},
expression : "($total - $errors) / $total",
intervalMs : 1000,
maxDataPoints : 43200,
refId : "C",
type : "math"
}
])
}
type = "grafana_queries"
}
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"
}
}
}
}
```

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

Expand Down Expand Up @@ -173,19 +279,28 @@ Required:

Required:

- `type` (String) Query type must be one of: "freeform", "query", "ratio", or "threshold"
- `type` (String) Query type must be one of: "freeform", "query", "ratio", "grafanaQueries" or "threshold"

Optional:

- `freeform` (Block List, Max: 1) (see [below for nested schema](#nestedblock--query--freeform))
- `grafana_queries` (Block List) Array for holding a set of grafana queries (see [below for nested schema](#nestedblock--query--grafana_queries))
- `ratio` (Block List, Max: 1) (see [below for nested schema](#nestedblock--query--ratio))

<a id="nestedblock--query--freeform"></a>
### Nested Schema for `query.freeform`

Required:

- `query` (String) Freeform Query Field
- `query` (String) Freeform Query Field - valid promQl


<a id="nestedblock--query--grafana_queries"></a>
### Nested Schema for `query.grafana_queries`

Required:

- `grafana_queries` (String) Query Object - JSON formatted string


<a id="nestedblock--query--ratio"></a>
Expand Down
96 changes: 96 additions & 0 deletions examples/resources/grafana_slo/resource_nonprometheus.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
resource "grafana_slo" "test" {
name = "Terraform Testing"
description = "Terraform Description"
query {
grafana_queries {
grafana_queries = jsonencode([
{
aggregation : "Sum",
alias : "",
application : "57831",
applicationName : "petclinic",
datasource : {
type : "dlopes7-appdynamics-datasource",
uid : "appdynamics_localdev"
},
delimiter : "|",
isRawQuery : false,
metric : "Service Endpoints|PetClinicEastTier1|/petclinic/api_SERVLET|Errors per Minute",
queryType : "metrics",
refId : "errors",
rollUp : true,
schemaVersion : "3.9.5",
transformLegend : "Segments",
transformLegendText : ""
},
{
aggregation : "Sum",
alias : "",
application : "57831",
applicationName : "petclinic",
datasource : {
type : "dlopes7-appdynamics-datasource",
uid : "appdynamics_localdev"
},
intervalMs : 1000,
maxDataPoints : 43200,
delimiter : "|",
isRawQuery : false,
metric : "Service Endpoints|PetClinicEastTier1|/petclinic/api_SERVLET|Calls per Minute",
queryType : "metrics",
refId : "total",
rollUp : true,
schemaVersion : "3.9.5",
transformLegend : "Segments",
transformLegendText : ""
},
{
datasource : {
type : "__expr__",
uid : "__expr__"
},
expression : "($total - $errors) / $total",
intervalMs : 1000,
maxDataPoints : 43200,
refId : "C",
type : "math"
}
])
}
type = "grafana_queries"
}
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"
}
}
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/grafana/grafana-com-public-clients/go/gcom v0.0.0-20240807172819-ac10800522a3
github.com/grafana/grafana-openapi-client-go v0.0.0-20241113095943-9cb2bbfeb8a3
github.com/grafana/machine-learning-go-client v0.8.2
github.com/grafana/river v0.3.0
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20240807172758-1b7d00838fc7
github.com/grafana/river v0.3.0
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20250218172929-ab9cae090da6
github.com/grafana/synthetic-monitoring-agent v0.34.1
github.com/grafana/synthetic-monitoring-api-go-client v0.11.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ github.com/grafana/river v0.3.0 h1:6TsaR/vkkcppUM9I0muGbPIUedCtpPu6OWreE5+CE6g=
github.com/grafana/river v0.3.0/go.mod h1:icSidCSHYXJUYy6TjGAi/D+X7FsP7Gc7cxvBUIwYMmY=
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20240807172758-1b7d00838fc7 h1:t7zAFX0rMu868n85zRHLgmAjLJgWbkxUekGquZmovjA=
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20240807172758-1b7d00838fc7/go.mod h1:MVsmQi3lkhNnRExmke6Ug6HFG4Dycd+oRgzC3Rz+vOs=
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20250218172929-ab9cae090da6 h1:7jbuz2MCqHlIc+vC3geOEzMZolm30v3K1bFTaTJ4mGI=
github.com/grafana/slo-openapi-client/go/slo v0.0.0-20250218172929-ab9cae090da6/go.mod h1:a9idYds6valDrBwBdcFTIp+QzlERgf2CFDZgEfmp9pA=
github.com/grafana/synthetic-monitoring-agent v0.34.1 h1:igtwIr61lFopRzSRL1uBAmmbaQ5OebsgKXw9dpjOefY=
github.com/grafana/synthetic-monitoring-agent v0.34.1/go.mod h1:PM7+XQSxiXAklTbTmpK8OvbcvUvGF8BOdRWhd7V/39o=
github.com/grafana/synthetic-monitoring-api-go-client v0.11.0 h1:C/LMuhY9USNXRVhzQ3S09C0rSyAwCUssCp3WOShLN5I=
Expand Down
Loading
Loading