mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 22:37:27 -08:00
Fix rate() per-second adjustment.
This got broken during the depointerization of the Vector type.
This commit is contained in:
parent
62f33f1fc2
commit
1cff4f3d91
|
@ -137,8 +137,8 @@ func rateImpl(timestamp time.Time, view *viewAdapter, args []Node) interface{} {
|
||||||
// MatrixLiteral exists). Find a better way of getting the duration of a
|
// MatrixLiteral exists). Find a better way of getting the duration of a
|
||||||
// matrix, such as looking at the samples themselves.
|
// matrix, such as looking at the samples themselves.
|
||||||
interval := args[0].(*MatrixLiteral).interval
|
interval := args[0].(*MatrixLiteral).interval
|
||||||
for _, sample := range vector {
|
for i, _ := range vector {
|
||||||
sample.Value /= model.SampleValue(interval / time.Second)
|
vector[i].Value /= model.SampleValue(interval / time.Second)
|
||||||
}
|
}
|
||||||
return vector
|
return vector
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,12 @@ var expressionTests = []struct {
|
||||||
output: []string{"http_requests{group='canary',instance='1',job='app-server'} => 288 @[%v]"},
|
output: []string{"http_requests{group='canary',instance='1',job='app-server'} => 288 @[%v]"},
|
||||||
fullRanges: 1,
|
fullRanges: 1,
|
||||||
intervalRanges: 0,
|
intervalRanges: 0,
|
||||||
|
}, {
|
||||||
|
// Rates should transform per-interval deltas to per-second rates.
|
||||||
|
expr: "rate(http_requests{group='canary',instance='1',job='app-server'}[10m])",
|
||||||
|
output: []string{"http_requests{group='canary',instance='1',job='app-server'} => 0.26666668 @[%v]"},
|
||||||
|
fullRanges: 1,
|
||||||
|
intervalRanges: 0,
|
||||||
}, {
|
}, {
|
||||||
// Empty expressions shouldn't parse.
|
// Empty expressions shouldn't parse.
|
||||||
expr: "",
|
expr: "",
|
||||||
|
|
Loading…
Reference in a new issue