Navneet Nandan Jha
Navneet Nandan Jha

Reputation: 1506

Adding two values in Prometheus

We need to add results of two queries in Prometheus. Snippet is below:

(probe_ssl_earliest_cert_expiry{job="SSL-expiry"} - time() < 86400 * 738 )*1000 + (node_time_seconds*1000)

but the result says no data as shown below:

enter image description here

Upvotes: 0

Views: 3731

Answers (1)

Michael Doubez
Michael Doubez

Reputation: 6903

You will get an empty result if the metrics do not match. The reason is that for binary operator vector1 <op> vector2

vector1 and vector2 results in a vector consisting of the elements of vector1 for which there are elements in vector2 with exactly matching label sets. Other elements are dropped.

You must at least add a on() or ignoring() vector matching keyword specifying the labels (names) on which the (name and) value match. You may have to add grouping instruction if you have one to many matching.

Fill the ??? in the following expression such that label match:

(probe_ssl_earliest_cert_expiry{job="SSL-expiry"} - time() < 86400 * 738 )*1000 + ON(???) (node_time_seconds*1000)

Upvotes: 1

Related Questions