mirror of
https://github.com/prometheus/prometheus
synced 2025-02-23 08:07:18 +00:00
Fix scalar-vector comparisons (#5454)
* Fix scalar-vector comparisons Fixes https://github.com/prometheus/prometheus/issues/5452 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
46660a0745
commit
bc1c7f1809
@ -24,6 +24,7 @@
|
||||
* [BUGFIX] Set TLSHandshakeTimeout in HTTP transport. common#179
|
||||
* [BUGFIX] Use fsync to be more resilient to machine crashes. tsdb#573 tsdb#578
|
||||
* [BUGFIX] Keep series that are still in WAL in checkpoints. tsdb#577
|
||||
* [BUGFIX] Fix output sample values for scalar-to-vector comparison operations. #5454
|
||||
|
||||
## 2.8.1 / 2019-03-28
|
||||
|
||||
@ -195,8 +196,8 @@ This release includes multiple bugfixes and features. Further, the WAL implement
|
||||
* [FEATURE] Persist alert 'for' state across restarts #4061
|
||||
* [FEATURE] Add API providing per target metric metadata #4183
|
||||
* [FEATURE] Add API providing recording and alerting rules #4318 #4501
|
||||
* [ENHANCEMENT] Brand new WAL implementation for TSDB. Forwards incompatible with previous WAL.
|
||||
* [ENHANCEMENT] Show rule evaluation errors in UI #4457
|
||||
* [ENHANCEMENT] Brand new WAL implementation for TSDB. Forwards incompatible with previous WAL.
|
||||
* [ENHANCEMENT] Show rule evaluation errors in UI #4457
|
||||
* [ENHANCEMENT] Throttle resends of alerts to Alertmanager #4538
|
||||
* [ENHANCEMENT] Send EndsAt along with the alert to Alertmanager #4550
|
||||
* [ENHANCEMENT] Limit the samples returned by remote read endpoint #4532
|
||||
|
@ -1581,6 +1581,11 @@ func (ev *evaluator) VectorscalarBinop(op ItemType, lhs Vector, rhs Scalar, swap
|
||||
lv, rv = rv, lv
|
||||
}
|
||||
value, keep := vectorElemBinop(op, lv, rv)
|
||||
// Catch cases where the scalar is the LHS in a scalar-vector comparison operation.
|
||||
// We want to always keep the vector element value as the output value, even if it's on the RHS.
|
||||
if op.isComparisonOperator() && swap {
|
||||
value = rv
|
||||
}
|
||||
if returnBool {
|
||||
if keep {
|
||||
value = 1.0
|
||||
|
6
promql/testdata/operators.test
vendored
6
promql/testdata/operators.test
vendored
@ -220,7 +220,7 @@ eval instant at 50m SUM(http_requests) BY (job) > 1000
|
||||
{job="app-server"} 2600
|
||||
|
||||
eval instant at 50m 1000 < SUM(http_requests) BY (job)
|
||||
{job="app-server"} 1000
|
||||
{job="app-server"} 2600
|
||||
|
||||
eval instant at 50m SUM(http_requests) BY (job) <= 1000
|
||||
{job="api-server"} 1000
|
||||
@ -388,7 +388,7 @@ eval instant at 5m node_cpu % 2
|
||||
{instance="def",job="node",mode="idle"} 0
|
||||
{instance="def",job="node",mode="user"} 0
|
||||
|
||||
|
||||
|
||||
clear
|
||||
|
||||
load 5m
|
||||
@ -414,4 +414,4 @@ load 5m
|
||||
testmetric1{src="a",dst="b"} 0
|
||||
testmetric2{src="a",dst="b"} 1
|
||||
|
||||
eval_fail instant at 0m -{__name__=~'testmetric1|testmetric2'}
|
||||
eval_fail instant at 0m -{__name__=~'testmetric1|testmetric2'}
|
||||
|
Loading…
Reference in New Issue
Block a user