Adding two values in Prometheus

戏子无情 提交于 2020-12-27 07:11:58

问题


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:


回答1:


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)


来源:https://stackoverflow.com/questions/59763954/adding-two-values-in-prometheus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!