mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-29 07:29:42 -08:00
29e8dc2c49
When doing comparison operations on vectors, filtering sometimes gets in the way and you have to go to a fair bit of effort to workaround it in order to always return a result. The 'bool' modifier instead of filtering returns 0/1 depending on the result of the compairson. This is also a prerequisite to removing plain scalar/scalar comparisons, as it maintains the current behaviour under a new syntax.
54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
load 5m
|
|
http_requests{job="api-server", instance="0", group="production"} 0+10x10
|
|
http_requests{job="api-server", instance="1", group="production"} 0+20x10
|
|
http_requests{job="api-server", instance="0", group="canary"} 0+30x10
|
|
http_requests{job="api-server", instance="1", group="canary"} 0+40x10
|
|
http_requests{job="app-server", instance="0", group="production"} 0+50x10
|
|
http_requests{job="app-server", instance="1", group="production"} 0+60x10
|
|
http_requests{job="app-server", instance="0", group="canary"} 0+70x10
|
|
http_requests{job="app-server", instance="1", group="canary"} 0+80x10
|
|
|
|
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
|
|
|
|
|
|
eval instant at 50m SUM(http_requests) BY (job) <= 1000
|
|
{job="api-server"} 1000
|
|
|
|
|
|
eval instant at 50m SUM(http_requests) BY (job) != 1000
|
|
{job="app-server"} 2600
|
|
|
|
|
|
eval instant at 50m SUM(http_requests) BY (job) == 1000
|
|
{job="api-server"} 1000
|
|
|
|
eval instant at 50m SUM(http_requests) BY (job) == bool 1000
|
|
{job="api-server"} 1
|
|
{job="app-server"} 0
|
|
|
|
eval instant at 50m SUM(http_requests) BY (job) == bool SUM(http_requests) BY (job)
|
|
{job="api-server"} 1
|
|
{job="app-server"} 1
|
|
|
|
eval instant at 50m SUM(http_requests) BY (job) != bool SUM(http_requests) BY (job)
|
|
{job="api-server"} 0
|
|
{job="app-server"} 0
|
|
|
|
|
|
eval instant at 50m 0 == 1
|
|
0
|
|
|
|
eval instant at 50m 1 == 1
|
|
1
|
|
|
|
eval instant at 50m 0 == bool 1
|
|
0
|
|
|
|
eval instant at 50m 1 == bool 1
|
|
1
|