简体   繁体   中英

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.

I tried multiple ways:

  1. Get "instant" data where unixtime is lower than the current time ( 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.

The second (preferred way) would be something like that (in 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

timestamp(my_device_time) - my_device_time()

timestamp() will return crawl time in unixtime, so found the solution on my own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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