SLO API
Get started with and use the SLO API to create, manage, and maintain your SLOs.
To use the SLO API, complete the following steps.
Create a Grafana service account token (/docs/grafana/latest/administration/service-accounts/) with Editor permissions.
Using any HTTP client like
curl
or HTTPie, make calls to the plugin’s resource API.- Make your API calls to the SLO resource API: {stackURL}/api/plugins/grafana-slo-app/resources/v1/slo
- Use “Authorization: Bearer $APITOKEN” and “Accept application/json” as request headers.
- The plugin uses GET to list all SLOs or read a specific one.
- DELETE to delete an individual SLO.
- POST to create an SLO.
- PUT to update an SLO.
For a full definition of the API, download this OpenAPIv3 specification.
Here is an example request body to create an SLO:
{
"name":"HTTP Requests Kubelet Success Indicator",
"description":"99.5% of Kubelet HTTP Requests are not 5xx errors",
"destinationDatasource": {
"uid": "grafanacloud-prom"
},
"objectives":[
{
"value":0.995,
"window":"28d"
}
],
"query":{
"type":"ratio",
"ratio":{
"successMetric":{
"prometheusMetric":"kubelet_http_requests_total{status!~\"5..\"}"
},
"totalMetric":{
"prometheusMetric":"kubelet_http_requests_total"
},
"groupByLabels":[
"instance",
"job"
]
}
},
"alerting":{
"fastBurn":{
"annotations":[
{
"key":"name",
"value":"SLO Burn Rate Very High"
},
{
"key":"description",
"value":"Error budget is burning too fast."
}
]
},
"slowBurn":{
"annotations":[
{
"key":"name",
"value":"SLO Burn Rate High"
},
{
"key":"description",
"value":"Error budget is burning too fast."
}
]
}
}
}