Note that time() isn't actually the current time, but the instant at which 
the query relates to.  Do a graph of "time()" in the Prometheus web 
interface to see this.

If you want the current value of the clock on a node via node_exporter, 
then the metric you're looking for is "node_time_seconds".

If you want to check whether the node's clock is wrong, then you can use an 
alerting rule like this:

  - alert: ClockSync
    expr: abs(node_time_seconds - timestamp(node_time_seconds)) > 5
    for: 15m
    labels:
      severity: warning
    annotations:
      summary: 'Clock is out of sync ({{$value|humanize}} seconds)'

On Wednesday, 27 July 2022 at 09:08:54 UTC+1 [email protected] wrote:

> https://prometheus.io/docs/prometheus/latest/querying/functions/#time
>
>
>
> On Wed, Jul 27, 2022 at 5:57 AM BHARATH KUMAR <[email protected]> 
> wrote:
>
>> Hello,
>>
>> How to get the current time in epochs in the Prometheus query? 
>>
>> Like can we get this info using Node Exporter metrics or any timestamp 
>> function we can use to get that?
>>
>> Any leads?
>>
>> Thanks & regards,
>> Bharath Kumar.
>>
>> On Tuesday, 26 July 2022 at 22:00:00 UTC+5:30 BHARATH KUMAR wrote:
>>
>>> Hi,
>>>
>>> I had a table with column name *last loggedin time* in grafana 
>>> dashboard.
>>>
>>> This will give info regarding on particular server at what time the user 
>>> had accessed that server last time
>>>
>>> The Prometheus query is as below:
>>>
>>> (max_over_time(last_time_user_logged_in_time{instance=~"$ip"}[5m]) * 1000) 
>>>
>>> Now I need to compare during the last 24 hours, how many servers are not 
>>> accessed.
>>> at the end of the query, I want to compare some epochs so that I will 
>>> give output, but the epoch we need to pass is dynamic.
>>>
>>> How to do that?
>>>
>>> Any suggestions please?
>>>
>>> Thanks & regards,
>>> Bharath Kumar.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Prometheus Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/prometheus-users/e9233a20-a966-4c82-a2e1-1b7a5a665ab4n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/prometheus-users/e9233a20-a966-4c82-a2e1-1b7a5a665ab4n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/fe68a88b-b768-4862-877d-86f7071a48c2n%40googlegroups.com.

Reply via email to