diff --git a/rules/ast/functions.go b/rules/ast/functions.go index 6276f4429..a77ab9819 100644 --- a/rules/ast/functions.go +++ b/rules/ast/functions.go @@ -137,7 +137,7 @@ func rateImpl(timestamp time.Time, view *viewAdapter, args []Node) interface{} { // MatrixLiteral exists). Find a better way of getting the duration of a // matrix, such as looking at the samples themselves. interval := args[0].(*MatrixLiteral).interval - for i, _ := range vector { + for i := range vector { vector[i].Value /= model.SampleValue(interval / time.Second) } return vector diff --git a/rules/rules_test.go b/rules/rules_test.go index 78431cbc7..f4083e161 100644 --- a/rules/rules_test.go +++ b/rules/rules_test.go @@ -219,8 +219,8 @@ var expressionTests = []struct { intervalRanges: 1, }, { // Lower-cased aggregation operators should work too. - expr: "sum(http_requests) by (job) + min(http_requests) by (job) + max(http_requests) by (job) + avg(http_requests) by (job)", - output: []string{ + expr: "sum(http_requests) by (job) + min(http_requests) by (job) + max(http_requests) by (job) + avg(http_requests) by (job)", + output: []string{ "http_requests{job='app-server'} => 4550 @[%v]", "http_requests{job='api-server'} => 1750 @[%v]", },