Grafana introduced $__range for Prometheus. See https://stackoverflow.com/a/54776593/1244605
On Friday, January 12, 2018 at 7:34:11 PM UTC+2, Ben Kochie wrote: > > I don't remember the exact timing, but the $__interval values, and > behavior, in Grafana were improved in the last couple releases. > > On Fri, Jan 12, 2018 at 5:03 PM, <[email protected] <javascript:>> wrote: > >> Hi, did you find a solution for that? We met same problem and don't know >> what to do. >> >> >> On Wednesday, July 19, 2017 at 2:17:40 PM UTC-5, [email protected] wrote: >>> >>> Prometheus: v1.5.0 >>> Grafana: v4.2.0 >>> >>> We're collecting a counter metric for the number of calls that each >>> endpoint has. This is scraped every 60s. >>> >>> One common request I'm receiving from some of our teams is if we display >>> the total number of calls over a specified period of time in Grafana >>> through a Singlestat panel. >>> >>> Currently, I have the Grafana query setup like the following. We take >>> the increase of the counter and then sum it up for all instances of that >>> endpoint. We're using the $__interval variable provided by Grafana to >>> handle the varying intervals. However, the numbers we receive from these >>> queries don't appear to be correct, and I'm fairly sure it has to be due to >>> the way interval and resolution/stepping is involved. >>> >>> - >>> >>> sum(increase(app_callscount{endpoint="/services/exampleService"}[$__interval])) >>> >>> Below I'll show the queries being performed by Grafana and then the >>> results. The results are the summed total of the returned values matrix. >>> This is done by Grafana using "total" under Options -> Value -> Stat field. >>> >>> *30 Min Period* >>> >>> - Query: >>> >>> http://prometheus:9090/api/v1/query_range?query=sum(increase(app_callscount{endpoint= >>> >>> "/services/exampleService"}[20s]))&start=1500324434&end=1500326234&step=40 >>> - Result: 27,273 >>> >>> *Last 7 Days* >>> >>> - Query: >>> >>> http://prometheus:9090/api/v1/query_range?query=sum(increase(app_callscount{endpoint= >>> >>> "/services/exampleService"}[2h]))&start=1499886247&end=1500491047&step=1440 >>> - Result: 255,654 >>> >>> *Last 60 days* >>> >>> - Query: >>> >>> http://prometheus:9090/api/v1/query_range?query=sum(increase(app_callscount{endpoint= >>> >>> "/services/exampleService"}[12h]))&start=1495307012&end=1500491012&step=86400 >>> - Result: 973,423 >>> >>> *This Year* >>> >>> - Query: >>> >>> http://prometheus:9090/api/v1/query_range?query=sum(increase(app_callscount{endpoint= >>> >>> "/services/exampleService"}[1d]))&start=1483246800&end=1514782800&step=172800 >>> - Result: *508,820* >>> >>> Should we let Grafana auto-adjust the interval based on the selected >>> time range rather than statically providing it a value? >>> >>> As you can see above, the range "This Year" provides a result nearly >>> half of what is provided by "Last 60 Days" which doesn't make sense when >>> people are viewing the dashboard. >>> >>> Has anyone had experience with this and can provide recommendations or >>> best practices? >>> >>> Regards, >>> Matt >>> >>> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/prometheus-users/e9feef32-e7df-4214-953a-122969bdb40e%40googlegroups.com >> >> <https://groups.google.com/d/msgid/prometheus-users/e9feef32-e7df-4214-953a-122969bdb40e%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/df624e65-e3c4-49d0-92f3-c175b4dea810o%40googlegroups.com.

