英文:
join prometheus queries while keeping data from the left side
问题
我想构建一个PromQL查询,它连接了两个向量:一个包含一些指标,另一个包含信息。问题是信息向量不包含所有与“joining label”相关的信息,但我不想错过指标向量的数据。
例如:kafka_consumergroup_lag
是一个具有 consumergroup
标签的指标向量,而 catalog_entities_info
是一个带有 consumergroup
和 team
标签以及每个条目的 1
标尺值的信息向量。我想将 team
标签添加到 kafka_consumergroup_lag
中。但是 catalog_entities_info
并不包含所有的 consumergroup
,在这种情况下,我希望在结果向量中添加空的 team
(或者可能是一些占位符,甚至根本不添加任何东西)。
到目前为止,我尝试过:
(sum(kafka_consumergroup_lag[1d]) by (consumergroup) >= 100)
* on(consumergroup) group_left(team)
catalog_entities_info
但是这个查询会过滤掉在 catalog_entities_info
中不存在的滞后的 consumergroup
。
英文:
I want to build promql query that joins two vectors: one with some metrics and other is informational. The caveat is that info vector doesn't have all the information for "joining label", but I don't want to miss the data from metrics vector.
For example: kafka_consumergroup_lag
is the metrics vector with consumergroup
label, and catalog_entities_info
is the gauge info vector with consumergroup
and team
label and 1
gauge value for every entry. I want to add team
label to kafka_consumergroup_lag
. But catalog_entities_info
doesn't have all consumergroup
and in this case I want to add empty team
(or maybe some placeholder, or even not adding anything at all) into resulting vector.
So far I tried:
(sum(kafka_consumergroup_lag[1d]) by (consumergroup) >= 100)
* on(consumergroup) group_left(team)
catalog_entities_info
but this query will filter out lagging consumergroup
s which are absent in catalog_entities_info
.
答案1
得分: 0
现在我唯一的解决方案是使用查询重复:
(
(sum(kafka_consumergroup_lag[1d]) by (consumergroup) >= 100)
* on(consumergroup) group_left(team)
catalog_entities_info
)
or ignoring(team) (sum(kafka_consumergroup_lag[1d]) by (consumergroup) >= 100)
第一部分将在可能的情况下添加 team
标签,第二部分的 or
将添加丢失的数据(在忽略添加的 team
标签的同时合并向量非常重要,否则我们将会有重复的数据)。
英文:
For now the only solution I have is with query duplication:
(
(sum(kafka_consumergroup_lag[1d]) by (consumergroup) >= 100)
* on(consumergroup) group_left(team)
catalog_entities_info
)
or ignoring(team) (sum(kafka_consumergroup_lag[1d]) by (consumergroup) >= 100)
First half will add team
label where possible, and second or
half will add missed data (important to merge vectors while ignoring added team
label, otherwise we will have duplicates).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论