Cloud Monitoring: Support SLO burn rate (#53710)
This commit is contained in:
@@ -429,7 +429,13 @@ func buildFilterString(metricType string, filterParts []string) string {
|
||||
}
|
||||
|
||||
func buildSLOFilterExpression(q sloQuery) string {
|
||||
return fmt.Sprintf(`%s("projects/%s/services/%s/serviceLevelObjectives/%s")`, q.SelectorName, q.ProjectName, q.ServiceId, q.SloId)
|
||||
sloName := fmt.Sprintf("projects/%s/services/%s/serviceLevelObjectives/%s", q.ProjectName, q.ServiceId, q.SloId)
|
||||
|
||||
if q.SelectorName == "select_slo_burn_rate" {
|
||||
return fmt.Sprintf(`%s("%s", "%s")`, q.SelectorName, sloName, q.LookbackPeriod)
|
||||
} else {
|
||||
return fmt.Sprintf(`%s("%s")`, q.SelectorName, sloName)
|
||||
}
|
||||
}
|
||||
|
||||
func setMetricAggParams(params *url.Values, query *metricQuery, durationSeconds int, intervalMs int64) {
|
||||
|
||||
@@ -589,6 +589,26 @@ func TestCloudMonitoring(t *testing.T) {
|
||||
|
||||
dl := qqueries[0].buildDeepLink()
|
||||
assert.Empty(t, dl)
|
||||
|
||||
req.Queries[0].JSON = json.RawMessage(`{
|
||||
"queryType": "slo",
|
||||
"sloQuery": {
|
||||
"projectName": "test-proj",
|
||||
"alignmentPeriod": "stackdriver-auto",
|
||||
"perSeriesAligner": "ALIGN_NEXT_OLDER",
|
||||
"aliasBy": "",
|
||||
"selectorName": "select_slo_burn_rate",
|
||||
"serviceId": "test-service",
|
||||
"sloId": "test-slo",
|
||||
"lookbackPeriod": "1h"
|
||||
},
|
||||
"metricQuery": {}
|
||||
}`)
|
||||
|
||||
qes, err = service.buildQueryExecutors(req)
|
||||
require.NoError(t, err)
|
||||
qqqueries := getCloudMonitoringQueriesFromInterface(t, qes)
|
||||
assert.Equal(t, `aggregation.alignmentPeriod=%2B60s&aggregation.perSeriesAligner=ALIGN_NEXT_OLDER&filter=select_slo_burn_rate%28%22projects%2Ftest-proj%2Fservices%2Ftest-service%2FserviceLevelObjectives%2Ftest-slo%22%2C+%221h%22%29&interval.endTime=2018-03-15T13%3A34%3A00Z&interval.startTime=2018-03-15T13%3A00%3A00Z`, qqqueries[0].Target)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ type (
|
||||
SelectorName string
|
||||
ServiceId string
|
||||
SloId string
|
||||
LookbackPeriod string
|
||||
}
|
||||
|
||||
grafanaQuery struct {
|
||||
|
||||
Reference in New Issue
Block a user