如果我查询一个指标,那么我会得到一个结果1
:
node_systemd_unit_state{name="web.service",state="active",type="simple"}
如果我查询相同的指标但使用不同的标签,那么我会得到一个结果0
:
node_systemd_unit_state{name="web.service",state="inactive",type="simple"}
但是如果我尝试将它们加在一起,那么我会得到no data
node_systemd_unit_state{name="web.service",state="active",type="simple"} + node_systemd_unit_state{name="web.service",state="inactive",type="simple"}
但是通过阅读https://prometheus.io/docs/prometheus/latest/querying/examples/#using-functions-operators-etc我希望我的表达能够起作用:
如果我们有两个具有相同维度标签的不同指标,我们可以对它们应用二元运算符,并且两侧具有相同标签集的元素将被匹配并传播到输出。例如,此表达式为每个实例返回 MiB 中未使用的内存(在一个虚构的集群调度程序上,公开有关它运行的实例的这些指标):
(instance_memory_limit_bytes - instance_memory_usage_bytes) / 1024 / 1024
- 如何将我的两个指标加在一起?
- 我的查询有什么问题?