Reputation: 6244
From Grafana Query inspector I am able to get the data for a date range ; Example
rate(node_disk_read_bytes_total{job="node-exporter",instance="172.18.0.2:9100",device=~"nvme.*"}[20m])
I can also give an absolute data time range. When I use the Prometheus GUI to query directly, I am not sure of the syntax of putting the date time range. I know it is in Unix Epoch time
What I have tried in PromQL from reading the docs
rate(node_disk_read_bytes_total{job="node-exporter",instance="172.18.0.2:9100",device=~"nvme.*"}[10m] @ 1648473649)[1d:10m]
1648473649 = Monday, 28 March 2022 13:20:49
https://www.epochconverter.com/
This works, without error and gives data, but the data is wrong (you can see from output it is giving one value all the way 38775.46666666667.
Also, I would like to give to and from as date timestamps in the above query.
The query which gives proper data in PromQL
rate(node_disk_read_bytes_total{job="node-exporter",instance="172.18.0.2:9100",device=~"nvme.*"}[10m])[7d:10m]
Upvotes: 1
Views: 14095
Reputation: 18056
PromQL doesn't allow specifying time range for the query. Instead, the time range is specified via HTTP API args passed to the corresponding endpoints:
time
query arg at /api/v1/querystart
and end
query args at /api/v1/query_rangeSuch a design decision allows executing the same PromQL query at any timestamp or on any time range without the need to change the query itself.
Upvotes: 5