如何在 PromQL 中合并零值(vector(0) 与度量值) [英] How to merge zero values (vector(0) with metric values in PromQL

查看:219
本文介绍了如何在 PromQL 中合并零值(vector(0) 与度量值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

我在不同的 StackOverflow 线程中尝试了多种解决方案,但是没有任何效果.

请帮忙.

解决方案

如果你使用带有标签的 Absent 将值从 1 转换为零,使用 clamp_max 会有所帮助>

( Metrics{label="a"} ORclamp_max(absent(notExists{label="a"}),0))+( Metrics2{label="a"} 或clamp_max(absent(notExists{label="a"}),0)

Vector(0) 没有标签.

clamp_max(Absent(notExists{label="a"},0) 是带有标签的 0.

I'm using flexlm_exporter to export my license usage to Prometheus and from Prometheus to custom service (Not Graphana).

As you know Prometheus hides missing values.

However, I need those missing values in my metric values, therefore I added to my prom query or vector(0)

For example:

flexlm_feature_used_users{app="vendor_lic-server01",name="Temp"} or vector(0)

This query adds a empty metric with zero values.

My question is if there's a way to merge the zero vector with each metric values?

Edit:

I need grouping, at least for a user and name labels, so vector(0) is probably not the best option here?

I tried multiple solutions in different StackOverflow threads, however, nothing works.

Please assist.

解决方案

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.

这篇关于如何在 PromQL 中合并零值(vector(0) 与度量值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆