data points returned prometheus http query

31 views
Skip to first unread message

Johny

unread,
Jun 23, 2020, 6:41:43 PM6/23/20
to Prometheus Users
the http api called by grafana is showing data that is hard to explain. step size sent from grafana is 15 seconds.

i only have two points in underlying time series data:
10:01:14   5.5
10:31:30.  10.4

when I query a time range (query_range) inclusive of these points, I get two 5 min batches rounded to nearest minute. Each batch has points separated by 15 seconds.
10:01:00  5.5
10:01:15  5.5
10:01:30  5.5
...
10:05:00  5.5

10:31:00  10.4
10:31:15  10.4
10:31:30  10.4
..
10:36:00   10.4


Can you please explain the 5 minute batch?
Is there a way to plot the actual data points in grafana?



Brian Candler

unread,
Jun 24, 2020, 6:20:53 AM6/24/20
to Prometheus Users
I can explain it. query_range runs an instant query across the range, at the interval you specify.  The value at time T is whatever the most recent value was before time T.  So you'll see a value at 15 second intervals, being the most recent value available at that time, stepped across the time range you asked for.

To get the raw data via the prometheus API, send a plain "query" with a range vector, rather than "query_range" with an instant vector.

However I don't know if you can do that with Grafana.  If you try a range vector query in Explore it's rejected:



But no problem via API:

root@prometheus:~# curl -Ssg 'localhost:9090/api/v1/query?query=node_load1[5m]' | jq .
{
  "status": "success",
  "data": {
    "resultType": "matrix",
    "result": [
      {
        "metric": {
          "__name__": "node_load1",
          "instance": "nuc1",
          "job": "node",
          "netbox_type": "device"
        },
        "values": [
          [
            1592993705.766,
            "1.28"
          ],
          [
            1592993765.766,
            "0.93"
          ],
          [
            1592993825.766,
            "0.49"
          ],
          [
            1592993885.766,
            "1.04"
          ],
          [
            1592993945.766,
            "1.42"
          ]
        ]
      },
... etc 

Johny

unread,
Jun 24, 2020, 10:33:43 AM6/24/20
to Prometheus Users
Thanks. But how do you explain the 5 minute batches? 

Stuart Clark

unread,
Jun 24, 2020, 10:46:23 AM6/24/20
to Johny, Prometheus Users
On 2020-06-24 15:33, Johny wrote:
> Thanks. But how do you explain the 5 minute batches?
>

I think that is due to staleness.

You mentioned that there are only 2 datapoints actually stored in the
TSDB, therefore if you query it will find the nearest point (up to a 5
minute maximum).

--
Stuart Clark

Johny

unread,
Jun 24, 2020, 11:14:03 AM6/24/20
to Prometheus Users
Thank you. That makes sense.

More a grafana question - is there a way plot actual data points in a graph (not table). Want users to see X calls to my end point, etc.

Stuart Clark

unread,
Jun 24, 2020, 11:47:29 AM6/24/20
to Johny, Prometheus Users
I'm not quite sure what you mean? A graph in Grafana will plot how the data changes over whatever time period you are viewing.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Johny

unread,
Jun 24, 2020, 1:19:28 PM6/24/20
to Prometheus Users
I was referrring to actual points scraped/pushed to prometheus. I understand the graph reflects how prom interprets the time series.
Reply all
Reply to author
Forward
0 new messages