Same dashboard with more relative time panel

Hi, I know that probably this has been asked several times but I’m spending several days trying and searching inside the forum without success.
What I need is display in the same dashboard several panel with data per hour, day and month. I’m able to set it, but only till “now” and starting from 1 “time unit” in the past. What I need is the graphs showing alwasy this x time scale:
daily: from 00.00.00 to 23:59:59
monthly: from 01 to last month’s day (28-29-30 or 31)
yearly: from January to December.
For data I use mysql and time column is timestamp type.
Thanks a lot to all

I’m sorry that I cannot answer your question, but I hope that:

a) there is an answer

b) once we have it, it gets added to the documentation as an example.

This sounds like a very useful facility to me.

Antony.

I put this question in other forum too, but I got no answer. I don’t believe it is not possible and no one else had and solve this issue

Hi Antony, have you got any solution on this theme?

You may need to do a workaround and jump into the code.

First, you will need to create custom graph panels from the original one, and add them in builtin_plugins.ts in order to activate them in grafana.

Then, in each of them you may go to graph.ts and change addTimeAxis() function in each custom graph for your needs.

Lastly, create a dashboard with each panel being of a different type, but I’m not sure if time units are gonna work well.

This is a tricky solution and it may not be worth trying, but I hope it can help you. Feel free to ask for more info.

Thanks, could you please make a quick example to import?

How can I do that? Pleas could you guide me?
Thanks a lot

You need to copy the graph panel folder to another folder in the same scope with another name.

Then, go to public > app > features > plugins > built_in_plugins.ts and add your panel the same way the other ones are added, just copy anything the graph panel is in on the next line and change “graph” for your custom name.

Then, take a look at the imports on your new panel’s imports and make sure they all point to the newly created graph and its classes, and not to the old one.

Now you will have a new panel in grafana which you can manipulate and works just like the graph panel.

Ok. I copied …\grafana\public\app\plugins\panel\graph as …\grafana\public\app\plugins\panel\Test_graph and in built_in_plugins.ts I added these line after the original “graph” ones:

import * as Test_graphPanel from ‘app/plugins/panel/Test_graph/module’;
‘app/plugins/panel/Test_graph/module’: Test_graphPanel,

I restarted grafana but I still see only the original one! :frowning:
I’m starting from a completely new and empty dashboard

Make sure you change the class exports name in the new graph’s module.ts and graph.ts (beware with the imports you will need to change for that). In your case, GraphCtrl will be changed to Test_graphCtrl and GraphElement → Test_graphElement

Thanks, I missed it.
In the meantime I was able to accomplish what I needed.
For the relative time I set “0s” in all the panels, and as time shift “0d/d”, “0M/M”, “0y/y” depending on what I wanted to display.
Now I have the last problem: In a panel I want to show all the result from the beginning till now, grouped by year (I use Mysql).
It’s strange the result I get, even without setting anything as relative time:


As you can see I have these as last value for each year:
2019-12-20 01:00:00 with 50908 and 2020-12-19 01:00:00 with 54066
image
image
But I have no data for the 2019, and several data till now in 2021. This is my table, from the beginning till now (a row per each hour):

        Timing      |  Avg   | Yearly
2020-12-04 17:00:00  |  3.98  |  47804.2
..............
2020-12-19 00:00:00  |  3.75  |  50908.3
2020-12-19 01:00:00  |  5.24  |  50918.4
..............
2020-12-31 23:00:00  |  3.3   |  54065.9
2021-01-01 00:00:00  |  3.25  |  2.3
..........
2021-06-02 13:00:00  |  4.32   |  32178.5
2021-06-02 15:00:00  |  4.6    |  32489.5

This is what I should have, plotted from the same DB with this instruction:
SELECT AVG(Avg), MAX(Yearly), YEAR(Timing) AS Year FROM historic GROUP BY YEAR(Timing) ORDER BY Timing

Avg   |  Yearly    |  Year
4.50  |   54065.9  |  2020
4.32  |   32489.5  |  2021

image

1 Like