I am using Grafana 4.2.2 version.I use mySQL and monitor data in series with below query:
SELECT
UNIX_TIMESTAMP(time) as time_sec,
model_no as metric,
sum(device_count) as value
FROM device_models_stats
GROUP BY model_no,time
ORDER BY value DESC limit 10
But my problem is bar-graph is fluctuating and not based on descending order as expected.
Could yoy please help on this.
Or please let us know if it is bug in that version , is next version resolved it?
@daniellee Could you please help on it
ok Thanks i will upgrade my version and check .
Is there steps need to follow to upf=grade my version since i am need to migrate it on production directly
@daniellee Same problem im facing with “Datatable Panel” with the below query in Grafana 4.5.2 version:
select model_no,sum(device_count) device_count from device_models_stats group by model_no order by device_count DESC limit 5;
It is not in descending order as expected.
Im using format as ‘table’ as below. Please suggest me im using wrong query.
Just backup your database first (if you are using sqlite just make a copy of the grafana.db file). But is should be pain-free.
http://docs.grafana.org/installation/upgrading/#upgrading-grafana
Are you sorting within the Datatable panel plugin? You can click on column headers to sort the column. The sorting in the datatable panel will override your sql query sorting.
Yes Im using Datatable panel plugin. I want to sort top 10 models in decresaing order based on ‘device count’ constantly .
I want to show my data in decresing order .
Is there any suggestion in query since it is not giving the data based on ‘order by device_count’
select model_no,sum(device_count) device_count from device_models_stats group by model_no order by device_count DESC limit 5;
Hmm, think you did not understand me. The Datatable panel columns can sort the data as well and it will override the “order by” in your query - in this example it is sorted by “Value”:
You need to unsort the table by clicking on Value until it goes back to not sorted. Do you have any columns with sorting enabled in your Datatable panel?
Yes i can see sorted data by clicking on ‘model_no’ as well as ‘device_count’ headers but i want them to be sorted order without clicking on ‘headers’.
Is there any way to disable it or any query for sorting.
I want to show the data in sorted order without clicking on any headers.
I’m in the middle of developing Grafana so can’t check this right now.
To double check that the sorting from the query is correct, can you either:
- use the Query Explorer on the Metrics tab and see if the sorting looks correct from the response.
- Or take the same query and put it in a table panel and see if it is sorted correctly.
In mysql you cant reference columns by alias in group by or order by. So your query sorts by device_count but not sum(device_count). You can reference by index though. Those queries should work:
select model_no,sum(device_count) device_count from device_models_stats group by model_no order by 2 DESC limit 5;
select model_no,sum(device_count) device_count from device_models_stats group by model_no order by sum(device_count) DESC limit 5;
1 Like