I'm trying to define an E2E access availability of a service from a user perspective as the result of applying the bit-wise AND operation between two (Boolean) instant vectors representing individual service availability (e.g. S1 and S2).
I'm fetching the probe_success results of pinging these two services from a "user node" with a blackbox_exporter preinstalled:
+-------+ +---------------------+ +-------+
|S1 | | | | S2|
| | | User node with | | |
| +<----+ blackbox_exporter +---->+ |
| | icmp| |icmp6| |
+-------+ +---------------------+ +-------+
+-------------------------------------+-----+---+---+---+---+
| probe_success{user="foo", job="S1"} | ... | 0 | 0 | 1 | 1 |
+-------------------------------------+-----+---+---+---+---+
| probe_success{user="foo", job="S2"} | ... | 0 | 1 | 0 | 1 |
+-------------------------------------+-----+---+---+---+---+
| E2E{user="foo"} | ... | 0 | 0 | 0 | 1 |
+-------------------------------------+-----+---+---+---+---+
Since the targets are probed using different modules (icmp and icmp6) I'm using two jobs and therefore getting two instant vectors:
probe_success{job="S1", user="foo"}
# AND
probe_success{job="S2", user="foo"}
As I read on Prometheus' (querying) logical operators docs(
https://prometheus.io/docs/prometheus/latest/querying/operators/#logical-set-binary-operators), that logical and is not exactly what I'm looking for. ¿Is there an easy way to perform these kind of "bit-wise" operations in PromQL?
A user on SO suggested trying a recording rule to generate a new instant vector that does the trick:
(scalar(probe_success{job="S1", user="foo"}) + scalar(probe_success{job="S2", user="foo"})) == bool(2)
But, since scalar() drops the matching labels of the original metrics (i.e. 'user') I cannot use the rule applied to different users; being forced to use one per user. As this does not scale at all, I ask you guys; do you know a better way to use this kind of logic with PromQL? Is my reasoning flawed?