如何区分两种不同的prometheus指标?

问题描述 投票:0回答:1

考虑度量示例:

increase(application_executor_recordsWritten[20m])
increase(kafka_server_brokertopicmetrics_messagesin_total{topic="my_topic"}[20m])

如果我在prometheus图上单独执行这些指标 - 一切正常。但是当尝试类似的东西:

increase(application_executor_recordsWritten[20m]) -  increase(kafka_server_brokertopicmetrics_messagesin_total{topic="my_topic"}[20m])

我得到了No datapoints error

  1. 可能是因为application_executor_recordsWritten收到了最后1小时,而kafka_server_brokertopicmetrics_messagesin_total收到了6个多小时。
  2. 可能是因为这些指标有不同的“收集设置”,请考虑prometheus控制台输出: application_executor_recordsWritten {APP_NAME = “应用程序名”,exported_instance = “application_111111111111111111”,exported_job = “application_111111111111111111”,例如= “XX.XXX.X.XX”,工作= “JOB_NAME”,数= “1”,角色= “执行人” } kafka_server_brokertopicmetrics_messagesin_total {例如= “XX.XXX.X.XX”,工作= “JOB_NAME”,主题= “my_topic”}

Prometheus使用类似ignore(???)关键字的东西,但我无法弄清楚它是如何工作的以及如何将它应用于这些指标。

任何想法如何执行指标差异?这个的正确语法是什么?

apache-spark apache-kafka prometheus metrics prometheus-operator
1个回答
0
投票

在PromQL中,两个度量范围(也称为向量)之间的算术二元运算符受vector matching约束:该操作仅应用于具有相同精确标签集(名称和值)的条目。

如果存在差异且没有配对的值,则会得到臭名昭着的No data point错误。

如果你想让它们匹配,你必须

  • 要么忽略一些不匹配的标签(metric1 - ignoring(a_lone_label) metric2
  • 或指示哪个标签执行匹配(metric1 - on(common_label_name_and_value) metric2

在您给出的示例中,不清楚应该匹配什么。我会说instancejob;它可能是:

increase(application_executor_recordsWritten[...]) - on (job,instance) increase(kafka_server_brokertopicmetrics_messagesin_total{topic="my_topic"}[...])

如果运算符的一侧包含应与另一侧的多个元素配对的元素(调用一对多匹配),则必须指示运算符的哪一侧(右侧或左侧)具有更多条目:使用group_<side:rigth|left>

© www.soinside.com 2019 - 2024. All rights reserved.