PromQL step parameter

1,839 views
Skip to first unread message

kiran

unread,
Jan 15, 2021, 8:01:05 AM1/15/21
to Prometheus Users
Hello all

1. In PromQL range query what step value is used if I don’t give step parameter? 
2. Is there a way to determine for the given start and end dates, what is the step value I can give so it’s with the limit where query can handle? 
E.g I used a query for last 30 days and I gave 1 min as step and it threw a limitation error. So wondering if there is a way I could know what step value is appropriate for the given period.

Julius Volz

unread,
Jan 16, 2021, 10:59:58 AM1/16/21
to kiran, Prometheus Users
Hi Kiran,

On Fri, Jan 15, 2021 at 2:01 PM kiran <kira...@gmail.com> wrote:
Hello all

1. In PromQL range query what step value is used if I don’t give step parameter? 

The server returns an error if you use the API directly and don't set the step parameter. However, when using the Prometheus web UI and don't set a step manually, it sets a default step (https://github.com/prometheus/prometheus/blob/e483cff61ff1b68e8925db1059393c4d36af9df5/web/ui/react-app/src/pages/graph/Panel.tsx#L114) that depends on the graph range. It's basically the graph range divided by 250, so a 250-minute graph range would get a 1-minute step and a 500-minute time range would get a 2-minute step.
 
2. Is there a way to determine for the given start and end dates, what is the step value I can give so it’s with the limit where query can handle? 

No, at least not without first looking at the data more and determining how many samples there would be under a given graph range. You need to somehow keep the total number of returned points <=11k.

E.g I used a query for last 30 days and I gave 1 min as step and it threw a limitation error. So wondering if there is a way I could know what step value is appropriate for the given period.

Note that the 11k-point limit only applies to range queries. If your goal is to extract raw data at the resolution that it was scraped over 30d, you could run an instant query like "my_metric[30d]".

Regards,
Julius

--
Julius Volz
PromLabs - promlabs.com
Reply all
Reply to author
Forward
0 new messages