It would help if you used Absent with labels to convert the value from 1 to zero, use clamp_max
( Metrics{label=“a”} OR clamp_max(absent(notExists{label=“a”}),0))
+
( Metrics2{label=“a”} OR clamp_max(absent(notExists{label=“a”}),0)
Vector(0) has no label.
clamp_max(Absent(notExists{label=“a”},0) is 0 with label.
It would help if you used Absent with labels to convert the value from 1 to zero, use clamp_max
( Metrics{label=“a”} OR clamp_max(absent(notExists{label=“a”}),0))
+
( Metrics2{label=“a”} OR clamp_max(absent(notExists{label=“a”}),0)
Vector(0) has no label.
clamp_max(Absent(notExists{label=“a”},0) is 0 with label.
If you do sum(flexlm_feature_used_users{app="vendor_lic-server01",name="Temp"} or vector(0)) you should get what you're looking for, but you'll lose possibility to do group by, since vector(0) doesn't have any labels.
Query with OR
Show "no data" as 0 with multiple time series
PromQL: additions and subtractions between some vectors and an empty vector result in empty vector
database - Prometheus, OR Vector(0) - Stack Overflow
Hello,
I have such a query:
up{name=~"node1|node2|node3"}Which returns `1` if the node is up, and nothing if it's down or does not exist. The problem is that I'd like to have `0` if the node is down or does not exist. I tried with:
up{name=~"node1|node2|node3"} OR on() vector(0)But it doesn't work.
The best solution which works is:
(sum by(name) (up{name="node1"}) OR on() vector(0))
OR
(sum by(name) (up{name="node2"}) OR on() vector(0))
OR
(sum by(name) (up{name="node3"}) OR on() vector(0))But I looking for a solution that allows to use Grafana variable. I want to use $NAMES, e.g.:
up{name=~"$NAMES"}Having the above long solution does not allow to do it.It is worth noting that I don't have access to the Prometheus instance. It's out of my control. I have only Grafana which uses Prometheus as a data source.
Do you have some idea how to do it in one query?
PS. To be honest, I didn't know what title should I choose.
--- EDIT (SOLUTION) ---
I've resolved my problem using the following query:
(sum by (name) (up{name='node1'}) OR clamp_max(absent(up{name='node1'}),0))
OR
(sum by (name) (up{name='node2'}) OR clamp_max(absent(up{name='node2'}),0))
OR
(sum by (name) (up{name='node3'}) OR clamp_max(absent(up{name='node3'}),0))
OR
(sum by (name) (up{name='node4'}) OR clamp_max(absent(up{name='node4'}),0))
OR
(sum by (name) (up{name='node5'}) OR clamp_max(absent(up{name='node5'}),0))Each node has 1 query containing 2 parts. The first part `sum by (name) (up{name='node1'})` returns the sum of number 1 (`up` result). The second part (`clamp_max(absent(up{name='node1'}),0)`) returns zeros even if the metric for a node has disappeared (eg. because of no data or the target does not exist).
Between all queries is `OR`. As a result, I have a graph showing 0 or 1 for each node, even if a node has no data or is not available (then there is 0).
Disadvantage - I have to update that query each time a node will be removed or added to my system.