简体   繁体   English

Prometheus 指标值与 grafana 中的“抓取时间”相比

[英]Prometheus metric value compared to "crawl Time" in grafana

I have metric that exports "current time" from the device in UNIX time, now I would like to compare that time with "crawling time", but I seem to have some problems with that.我有在 UNIX 时间从设备导出“当前时间”的指标,现在我想将该时间与“爬行时间”进行比较,但我似乎对此有一些问题。

I tried multiple ways:我尝试了多种方法:

  1. Get "instant" data where unixtime is lower than the current time ( time() function )获取 unixtime 低于当前时间的“即时”数据 ( time() function )

example:例子:

my_device_time{somelable="asd"} < (time() - 120)

Should return me rows that have a time difference of 2 or more minutes but do not seem to work.应该返回时差为 2 分钟或更长时间但似乎不起作用的行。

The second (preferred way) would be something like that (in grafana):第二种(首选方式)是这样的(在 grafana 中):

    my_device_time{somelable="asd"} < (crawledTime() - 60)

So questions:所以问题:

is it possible to get Time field as unixtimestamp for compare or how should i compare metric value (unixtime) against current timestamp with promql是否有可能将时间字段作为 unixtimestamp 进行比较,或者我应该如何使用 promql 将度量值(unixtime)与当前时间戳进行比较

timestamp(my_device_time) - my_device_time()

timestamp() will return crawl time in unixtime, so found the solution on my own. timestamp() 将以 unixtime 返回抓取时间,因此我自己找到了解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM