Question about @ operator

45 views
Skip to first unread message

Helio Loureiro

unread,
Dec 6, 2021, 6:03:43 AM12/6/21
to promethe...@googlegroups.com
Hi,

We were given a try on the new @ operator, but we got uncanny results.

First using time:

$ curl -s 'http://localhost:9090/api/v1/query?query=scrape_duration_seconds%7Bjob="prometheus"%7D&time=2021-11-26T09:39:21.000Z' | jq .
{
 "status": "success",
 "data": {
   "resultType": "vector",
   "result": [
     {
       "metric": {
         "__name__": "scrape_duration_seconds",
         "instance": "localhost:9090",
         "job": "prometheus"
       },
       "value": [
         1637919561,
         "0.00721538"
       ]
     }
   ]
 }
}

As can be seen, time returned at value is 1637919561, which matches the time sent:

In [9]: time.strftime("%Y-%m-%dT%H:%M:%S.000", time.gmtime(1637919561))
Out[9]: '2021-11-26T09:39:21.000'

But once using the @ operator, got a different result:

$ curl -s 'http://localhost:9090/api/v1/query?query=scrape_duration_seconds%7Bjob="prometheus"%7D@1637919561' | jq .
{
 "status": "success",
 "data": {
   "resultType": "vector",
   "result": [
     {
       "metric": {
         "__name__": "scrape_duration_seconds",
         "instance": "localhost:9090",
         "job": "prometheus"
       },
       "value": [
         1638787945.238,
         "0.00721538"
       ]
     }
   ]
 }
}

The data values is the same for both: 0.00721538.

But the time in value response not.

In [10]: time.strftime("%Y-%m-%dT%H:%M:%S.000", time.gmtime(1638787945.238))
Out[10]: '2021-12-06T10:52:25.000'

Which is the time right now.

So that's my question.  Are we doing something wrong on the query using @ operator?

Best Regards,
Helio Loureiro

Brian Candler

unread,
Dec 6, 2021, 7:19:02 AM12/6/21
to Prometheus Users
You are evaluating the PromQL query "scrape_duration_seconds{job="prometheus"}@1637919561" at time 1638787945.238

That seems perfectly consistent to me.

A simple instant vector query, like "up", evaluates the expression at some specific instant in time T (by default, the current time).  The value of each time series at time T is the most recent value it had at or before time T.  But the timestamp of the result is T.  That's because you asked for a vector of time series at time T, and the result is the value of these timeseries as they were at time T.

Similarly, if you ask for "up@T1" at time T2, then the instant vector result will be timestamped T2, because you asked for the value of this expression as it was at time T2.  The fact that the expression internally makes use of the timeseries at or before time T1 doesn't change this.

Helio Loureiro

unread,
Dec 7, 2021, 4:24:56 AM12/7/21
to Brian Candler, Prometheus Users
Hi Brian,

Thanks for the prompt reply :)

Best Regards,
Helio Loureiro

--
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 prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/4885fd04-72f1-4d11-888a-90ec77b4fa36n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages