Hello everyone, pretty new to Grafana with PostgresSQL and so far I love it! I will be presetting to our company the capabilities of Grafana next week and proposing to switching onto this platform - but I need help with one little thing:
I want to create an environment where I can show processes from industry plant. The dashboard should look something like this at the end (our current application):
So far I got to the point where I can select process numbers based on a query variable.
The problem I am facing right now is that the data shown in the graph doesnât automatically zoom in to data. This can be a problem because processes can be years old. And the user shouldnât scroll and âlookâ for the process through all the years.
Please tell me that there is a way how to do this?
I have been searching on the internet and couldnât find any answers (I am limited to 2 links so I will put the rest into comments):
I hope I will be proven wrong, but I had a similar question a few weeks back and the answer was that it cannot be done.
You can run the make a panel to user a relative time, which means that it will always fix to the last minutes, hours that you specify:
But it is always a range that ends in the current time. So if your process completes 5pm and you are running the report at 6pm, there will a 1 hour empty space in your graph. Similarly it is always a fixed period to the past. I wanted a graph which zooms in the data on my solar panels, which always start and stop depending when the sun rises and sets in the day. And I could not do it.
I hope you find a solution, it there will be a solution for that in the future. For me it seems what we need is not so much a setting on the graph, but some option to programmatically influence the time range on the dashboard. But in my understanding, this is not possible at the moment. Only if we could add a script to the dashboard page sourceâŚ
Just spend a few minutes scrolling through it, but it looks like a bespoke panel type where you can have buttons on your panel, and that will change the time range. So your button can determine the start and end of your data range and set the time range to that. Let me know if you can get this working.
Just a bump on this topic. Iâm also looking at solar data, but my information comes from Influx (2.6) and the time range is selected by the query (It presents yesterdayâs data before 10AM and todayâs after 10) and always displays from 6AM - 8PM of whichever day. The query is also set up for overlaying multiple days of data time-shifted to the âcurrentâ day.
Iâm looking for an unattended option that will just zoom to results from the query; is that not possible?
Editing my thoughts from above slightly-- Looking into RelativeTime and Time Shift I understand that I can do now/d to get to midnight, but I would like a start time of 6AM. If I enter now/d + 6h the + 6h is truncated off.
It doesnât seem like the selectors are sufficiently robust to do what I am doing in Flux (including if-then statements).
The query does everything I need it to do; the easy solution is to just have the panel display all query results rather than trying to manage zoom from a separate setting.
(I run two queries, one for âtodayâ and one for âyesterdayâ, and I timeShift the yesterday data into today so things overlay.)
When the refresh runs, the panel doesnât shift, as it is already padded out to 8PM today by the yesterday information. [It works as expected when I run it in Influx.]
The problem is that I canât figure out how to make Grafana âtrustâ that the time information all needs to be displayed (and nothing else).
Hi, i know that topic is near 2 years old but i searched grafana (& google) forum and could not find a idea how to âautozoom graph to dataâ so i finally done that by myself âŚi hope i didnt developed a wheel again but anyway i will paste how i did it and maybe someone find that useful
i have simple graph (# of client through time) âŚtakes data from MSSQL based on mien own start date and end date picker
important here is that You dont need use default dashboard data picker to zoom graph and all is automatically counted /zoomed
I defined 4 dashboard variable startD, endD, aaa, bbb. I know aaa & bbb are not good names for variable but are here only to be good visible in below explanation âŚalso You can hide them from dashboard as they are counted in real time based on startD & endD selection and dont need to be presented on life dashboard
-startD & endD variable are query from the same TABLE as graph it self âŚjust distinct/ grouped by Date âŚone Ascending order second in descending order (only cause i still not found how to in query select visible value âŚmean that i want see just 2nd from list âŚno i can t save as dashboard default value as list is dynamically created when dashboard is opened âŚbut this another story to grafna developers)
SELECT FORMAT(Date, âyyyy-MM-ddâ)
FROM <TABLE_NAME>
GROUP BY Date
ORDER BY Date
aaa (Relative time) query variable counting in days different between end and start date (for example 60 days) âŚand add âdâ to end so after all $aaa is â60dâ
SELECT CONCAT(DATEDIFF(day, CAST(${startD:singlequote} as smalldatetime), CAST(${endD:singlequote} as smalldatetime)) + 1,âdâ)
bbb (Shift time) variable counting in days different between TODAY/NOW date and end date (for example 3 days) âŚand add âdâ to end so after all $bbb is â3dâ
SELECT CONCAT(DATEDIFF(day, CAST(${endD:singlequote} as smalldatetime), GETDATE()),âdâ)
mine graph is created by query âŚ
SELECT
$__timeEpoch(Date),
â# of clientsâ as Client,
COUNT(ClientName) as Value
FROM <TABLE_NAME>
WHERE
Date >= CAST(${startD:singlequote} as date) AND Date <= CAST(${endD:singlequote} as date)
GROUP BY Date
ORDER BY Date
for above query i must use âquery optionsâ (1)" just to avoid that graph utilize main dashboard date picker âŚis lest say override
just set âRelative timeâ(2) to dashboard variable $aaa
just set âTime Shiftâ(3) to dashboard variable $bbb
can set also âHide time infoâ (4) so You will have no CLOCK icon & text âLast 47 days timeshift -2dâ on top of graph
and thatâs it âŚnow any time i select need by me range for graph it will automatically zoom it to show it from start date to end date and nothing more âŚ