I have seen a video on https://www.youtube.com/watch?v=I3o3tnj5j6s&feature=emb_logo, in which at 11:53 you can see the graph:
I have a dataset with columns:
2020-04-02 12:00:00|M1 |tap01 | 3|
2020-04-02 12:00:00|M1 |tap02 | 2|
2020-04-02 12:00:00|M1 |tap03 | 10|
2020-04-02 12:00:00|M1 |tap04 | 5|
2020-04-02 12:00:00|M1 |tap05 | 8|
2020-04-02 12:00:00|M1 |tap06 | 6|
2020-04-02 12:00:00|M1 |tap07 | 10|
2020-04-02 12:00:00|M1 |tap08 | 4|
2020-04-02 12:00:00|M1 |tap09 | 3|
2020-04-02 12:00:00|M1 |tap10 | 6|
2020-04-02 12:00:00|M2 |tap01 | 4|
2020-04-02 12:00:00|M2 |tap02 | 3|
2020-04-02 12:00:00|M2 |tap03 | 11|
2020-04-02 12:00:00|M2 |tap04 | 6|
2020-04-02 12:00:00|M2 |tap05 | 9|
2020-04-02 12:00:00|M2 |tap06 | 7|
2020-04-02 12:00:00|M2 |tap07 | 11|
2020-04-02 12:00:00|M2 |tap08 | 5|
2020-04-02 12:00:00|M2 |tap09 | 4|
2020-04-02 12:00:00|M2 |tap10 | 7|
2020-04-02 12:30:00|M1 |tap01 | 1|
2020-04-02 12:30:00|M1 |tap02 | 3|
2020-04-02 12:30:00|M1 |tap03 | 6|
2020-04-02 12:30:00|M1 |tap04 | 4|
2020-04-02 12:30:00|M1 |tap05 | 9|
2020-04-02 12:30:00|M1 |tap06 | 2|
2020-04-02 12:30:00|M1 |tap07 | 10|
2020-04-02 12:30:00|M1 |tap08 | 5|
2020-04-02 12:30:00|M1 |tap09 | 6|
2020-04-02 12:30:00|M1 |tap10 | 3|
2020-04-02 12:30:00|M2 |tap01 | 7|
2020-04-02 12:30:00|M2 |tap02 | 3|
2020-04-02 12:30:00|M2 |tap03 | 4|
2020-04-02 12:30:00|M2 |tap04 | 3|
2020-04-02 12:30:00|M2 |tap05 | 4|
2020-04-02 12:30:00|M2 |tap06 | 5|
2020-04-02 12:30:00|M2 |tap07 | 8|
2020-04-02 12:30:00|M2 |tap08 | 4|
2020-04-02 12:30:00|M2 |tap09 | 1|
2020-04-02 12:30:00|M2 |tap10 | 10|
Basically, we are monitoring modems through time, and log (every 30 min) their taps (tap = switch) positions (single modem usually have more taps and one tap can have position in range of integers).
Idea is to show line graph for certain 30 min for all modems in barchart or linechart format.
I have created such charts as toy example in python and plotly for barchart:
Can I somehow do this in Grafana?
According to the video from the beginning of this post, it is possible, but I don’t know how?
Can someone please help?
Unless I misunderstand the issue all you need to do is to create a query for each line.
I don’t know in advance how many lines I will have.
It depends on variable selection and filtering.
I cannot hardcode the queries.
In that case perhaps it would be a good idea to rephrase the thread title and the question.
Perhaps it is clear from the video but very few are going to be bothered to watch a video.
My suggestion answers all the requirements of the thread title and the written text as far as I can see.
Well, from the whole video, only the picture I have put here is important.
As English is not my first language, I really don’t know how to rephrase the question.
If you have an idea, please tell, I will change it.
You answer is correct but it is not feasible to me because number of queries is dynamic. I don’t know in advance how many queries it will be.
The missing bit is the use of the word dynamic. The graph shown from the video can be accomplished just by specifying the queries, unless you need the queries generated dynamically.
Yes, graph on the picture has 12 groups, so 12 queries would be OK.
In my case I have (at the moment) cca 300 groups, and that number vary (in the future it will be larger).
You can use variables to parameterise queries to select which data you want to see, but I presume you have already investigated that.
This thread is already old, but in case someone else is struggling with similar problem, here’s my 5 cents.
If I understood the question correctly, I have managed to achieve something similar this way:
In the query settings:
- Remove the filtering condition (where modem=M1)
- Add “Group by”: tag(modem)
- Define the “Alias by” as: [[tag_modem]]
- Remove other queries as you do not need to have separate queries for each modem anymore
And the translation:
- get data for all modems instead
- grouping by a tag will create separate graphs for each value of the tag
- in the legend of each group the name of the group is clumsy by default. This setting will make it look better (please try with and without this setting and you will notice the difference).
alias by available for all datasources ?
I have a similar simpler question here : Dynamic legend values based on data column
You could accomplish this by adding the distinction for the series as a metrics column to your select query. Do not need a group by for this case.
In case of the original question, it will be the “modem” column. So, the query will be something like below -
tap_val as value,
modem as metric
Guys, this has not been said much anywhere on Grafana forums/communities/Managed Services. But let me solve this problem once and for all.
You can have multiple lines on a single graph (through a single query) and group them by a metric by selecting a specific transformation called ‘Prepare Time Series’ and select ‘multi-frame time series’ in the drop down. Grafana will do the rest.