簡體   English   中英

Prometheus 計數指標 - 在開始時重置計數器

[英]Prometheus count metric - reset counter at the start time

如何在 Prometheus 中獲得實際計數指標?

目前,計數指標給出了運行信息——比如到目前為止有多少請求已經到達某個端點。

但是我想要某天從上午 9:00 到下午 5:00 之類的數字,我的端點被擊中了多少次? 它可以將上午 9:00 的計數器值視為 0 並進行計算嗎?

嘗試使用帶有startend時間戳的 Range Queries API:

文檔: https : //prometheus.io/docs/prometheus/latest/querying/api/

query=<string>: Prometheus expression query string.
start=<rfc3339 | unix_timestamp>: Start timestamp.
end=<rfc3339 | unix_timestamp>: End timestamp.
step=<duration | float>: Query resolution step width in duration format or float number of seconds.
timeout=<duration>: Evaluation timeout. Optional. Defaults to and is capped by the value of the -query.timeout flag.

您應該能夠使用新的@修飾符https://prometheus.io/docs/prometheus/2.26/querying/basics/#modifier

我假設這樣的事情有效:

http_requests_total - (http_requests_total @ start())

他們有一篇關於它的博客文章: https : //prometheus.io/blog/2021/02/18/introducing-the-@-modifier/

暫無
暫無

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

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