-
Notifications
You must be signed in to change notification settings - Fork 251
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
feat(bigTent slo): Custom Validate function for big tent SLO schema #2016
Conversation
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
…rovider-grafana into ld/big_tent_validate
I'd like to see if we can remove the warnings for valid Prometheus queries when we validate the Perhaps we can investigate if this |
…rovider-grafana into ld/big_tent_validate
…rovider-grafana into ld/big_tent_validate
description = "Terraform Description" | ||
query { | ||
grafana_queries { | ||
grafana_queries = jsonencode([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: can we use a Big Tent SLO example that matches the format and RefID of how the frontend generates it? i.e. using the Success
and Total
RefIDs, so it's easier for users to follow along? the example currently used looks to be a non-standard SLO that we had used for initial testing
maybe something like this
[
{
"datasource": {
"type": "graphite",
"uid": "datasource-uid"
},
"refId": "Success",
"target": "groupByNode(perSecond(web.*.http.2xx_success.*.*), 3, 'avg'')"
},
{
"datasource": {
"type": "graphite",
"uid": "datasource-uid"
},
"refId": "Total",
"target": "groupByNode(perSecond(web.*.http.5xx_errors.*.*), 3, 'avg')"
},
{
"datasource": {
"type": "__expr__",
"uid": "__expr__"
},
"expression": "$Success / $Total",
"refId": "Expression",
"type": "math"
}
]
diags = append(diags, diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: "Missing Required Field", | ||
Detail: fmt.Sprintf("expected Big Tent Query (refId:%v) to have a uid", refID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: do we want to use "Big Tent" language in our error messages? how about "supported datasource must specify a datasource: uid" and or "datasource: type"
nit: did you want to specify datasource: uid
rather than just uid
? same comment for datasource: type
above. since the uid
and type
fields are part of the datasource
struct. this is what it looks like in the Terraform terminal (I removed the type
field and then I removed the uid
field - wanted to see how the error message appeared to a user)
Sample Unhappy grafanaquery response from the API notice how we have three apostrophes in the Graphite query this returns a:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - we'll have some minor doc additions to add here with instructions to prototype queries in a dashboard panel and copy/paste here, but we can add that later as well
### Basic | ||
### Ratio | ||
|
||
```terraform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: we've been meaning to swap / fix this for awhile. Not part of big-tent, but a good improvement
docs/resources/slo.md
Outdated
"uid" : "datasource-uid" | ||
}, | ||
refId : "Success", | ||
target : "groupByNode(perSecond(web.*.http.2xx_success.*.*), 3, 'avg'')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: the extra ' char was from testing, is invalid in current form
target : "groupByNode(perSecond(web.*.http.2xx_success.*.*), 3, 'avg'')" | |
target : "groupByNode(perSecond(web.*.http.2xx_success.*.*), 3, 'avg')" |
refId : "Total", | ||
target : "groupByNode(perSecond(web.*.http.5xx_errors.*.*), 3, 'avg')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion - 5xx errors isn't really a great "total" query, we should give a better example ... but I think we may have used this one on website too, so need to fix both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is the exact same query.
docs/resources/slo.md
Outdated
} | ||
} | ||
} | ||
``` | ||
|
||
For a list of currently supported datasources review the [documentation](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/set-up/additionaldatasources/#supported-data-sources). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit / suggestion: most of our docs seem to try to have more informative link titles than "docs" (though I say "docs" internally all the time)
For a list of currently supported datasources review the [documentation](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/set-up/additionaldatasources/#supported-data-sources). | |
For a complete list, see [supported data sources](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/set-up/additionaldatasources/#supported-data-sources). |
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
Description: "Array for holding a set of grafana queries", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description: "Array for holding a set of grafana queries", |
the other query types seem to skip this outer description
templates/resources/slo.md.tmpl
Outdated
|
||
### Grafana Queries - Any supported datasource | ||
|
||
Grafana Queries use the grafana_queries field. It expects a JSON string list of valid grafana query JSON objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grafana Queries use the grafana_queries field. It expects a JSON string list of valid grafana query JSON objects. | |
Grafana Queries use the grafana_queries field. It expects a JSON string list of valid grafana query JSON objects, the same as you'll find assigned to a Grafana Dashboard panel `targets` field. |
Please Don't merge this until all work in https://github.com/grafana/slo/issues/2697 is complete. We want to ensure that the SLO Plugin API is merged and running in prod before we merge terraform-provider changes.
This adds a custom validate function for queries that checks to ensure basic form of big SLO JSON is being followed before we allow the user to roundtrip it to the API. This checks for:
Closes https://github.com/grafana/slo/issues/2702, https://github.com/grafana/slo/issues/2876, https://github.com/grafana/slo/issues/2875