mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
exponentation operator to drop metric name in result of op operation (#5329)
Signed-off-by: Daisy T <daisyts@gmx.com>
This commit is contained in:
parent
59369491cf
commit
683fbc59ec
|
@ -1893,7 +1893,7 @@ func btos(b bool) float64 {
|
||||||
// result of the op operation.
|
// result of the op operation.
|
||||||
func shouldDropMetricName(op ItemType) bool {
|
func shouldDropMetricName(op ItemType) bool {
|
||||||
switch op {
|
switch op {
|
||||||
case itemADD, itemSUB, itemDIV, itemMUL, itemMOD:
|
case itemADD, itemSUB, itemDIV, itemMUL, itemPOW, itemMOD:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|
39
promql/testdata/operators.test
vendored
39
promql/testdata/operators.test
vendored
|
@ -350,6 +350,45 @@ eval instant at 5m node_cpu > on(job, instance) group_left(target) (threshold or
|
||||||
node_cpu{instance="def",job="node",mode="idle"} 8
|
node_cpu{instance="def",job="node",mode="idle"} 8
|
||||||
node_cpu{instance="def",job="node",mode="user"} 2
|
node_cpu{instance="def",job="node",mode="user"} 2
|
||||||
|
|
||||||
|
|
||||||
|
# Check that binops drop the metric name.
|
||||||
|
eval instant at 5m node_cpu + 2
|
||||||
|
{instance="abc",job="node",mode="idle"} 5
|
||||||
|
{instance="abc",job="node",mode="user"} 3
|
||||||
|
{instance="def",job="node",mode="idle"} 10
|
||||||
|
{instance="def",job="node",mode="user"} 4
|
||||||
|
|
||||||
|
eval instant at 5m node_cpu - 2
|
||||||
|
{instance="abc",job="node",mode="idle"} 1
|
||||||
|
{instance="abc",job="node",mode="user"} -1
|
||||||
|
{instance="def",job="node",mode="idle"} 6
|
||||||
|
{instance="def",job="node",mode="user"} 0
|
||||||
|
|
||||||
|
eval instant at 5m node_cpu / 2
|
||||||
|
{instance="abc",job="node",mode="idle"} 1.5
|
||||||
|
{instance="abc",job="node",mode="user"} 0.5
|
||||||
|
{instance="def",job="node",mode="idle"} 4
|
||||||
|
{instance="def",job="node",mode="user"} 1
|
||||||
|
|
||||||
|
eval instant at 5m node_cpu * 2
|
||||||
|
{instance="abc",job="node",mode="idle"} 6
|
||||||
|
{instance="abc",job="node",mode="user"} 2
|
||||||
|
{instance="def",job="node",mode="idle"} 16
|
||||||
|
{instance="def",job="node",mode="user"} 4
|
||||||
|
|
||||||
|
eval instant at 5m node_cpu ^ 2
|
||||||
|
{instance="abc",job="node",mode="idle"} 9
|
||||||
|
{instance="abc",job="node",mode="user"} 1
|
||||||
|
{instance="def",job="node",mode="idle"} 64
|
||||||
|
{instance="def",job="node",mode="user"} 4
|
||||||
|
|
||||||
|
eval instant at 5m node_cpu % 2
|
||||||
|
{instance="abc",job="node",mode="idle"} 1
|
||||||
|
{instance="abc",job="node",mode="user"} 1
|
||||||
|
{instance="def",job="node",mode="idle"} 0
|
||||||
|
{instance="def",job="node",mode="user"} 0
|
||||||
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
load 5m
|
load 5m
|
||||||
|
|
Loading…
Reference in a new issue