簡體   English   中英

如何區分兩種不同的prometheus指標?

[英]How get difference between 2 different prometheus metrics?

考慮度量示例:

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(???)關鍵字,但我無法弄清楚它是如何工作的以及如何將它應用於這些指標。

任何想法如何執行指標差異? 這個的正確語法是什么?

在PromQL中,兩個度量范圍(也稱為向量)之間的算術二元運算符受矢量匹配的約束:該操作僅應用於具有相同精確標簽集(名稱和值)的條目。

如果存在差異並且沒有配對值,則會得到臭名昭着的無數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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM