When getting a prometheus metrics with labels displayed in a grafana table, the order of the grafana columns(labels in prometheus) are just sorted in alphabetical order. There is no way to display the column in a different order.
I just googled this issue, and there are lots of similar discussions. The feedback from the grafana team is that Grafana just displays the labels in the same order as what is returned from the data source(prometheus in this case). So their point is that the users should can control the order of the labels in the query results. Accordingly they think that this issue should be resolved by the data source instead of grafana.
But unfortunately, we can't change the order of the labels in prometheus. They are always in alphabetical order.
I tried to change the order of the labels using "by", but it did not work. For example, the label "label_a" is still displayed ahead of "label_b) in the following expression.
max(whatever_metrics) by (label_b, label_a)
How do you think?