Grafana: Allow re-ordering of columns in table panel configuration

Created on 18 May 2016  ·  63Comments  ·  Source: grafana/grafana

There currently is no way (other than editing the JSON) to re-order existing fields in a table panel. This is pretty painful, if you have a lot of columns, in particular, if there is no auto-completion.

arepanetable typfeature-request

Most helpful comment

Coming in 7.0 via the new transform tab!

All 63 comments

+1

I agree. It would be nice to be able to reorganize the columns.
Now I'm stuck with but would like

+1

+1

+1

+1

+1

indeed +1

+1

With Prometheus data sources there is no way that I can tell to reorder columns, not even editing the JSON.
The column order appears to be effectively random. This can make tables really awkward to read.

Strange , means Prometheus returns them in random order (I think)

@torkelo Well, prometheus labels are being turned into columns and labels have no inherent ordering, so that's to be expected.

+1

is there any progress?

+1billion to this, a prometheus data source results in columns being displayed in a non-deterministic order which is bloody well rubbish! :)

It'd be great if grafana could control this

+1 This is especially painful when trying to use Prometheus, as previous commentators mentioned.

Is there any progress??? This is a MUST have feature, right now you have no control over the table which is ridiculous.
And for Prometheus, I think the order is alphabetically depending on the label name (Giving another column name in Granada won't do anything)

+1

+1
For Prometheus, the order is alphabetically depending on the label name.
So i get a solution, but it's ugly...
Use label_replace in promQL, rename label to _xx_old_label, something like that:

label_replace(some_metric, "_01_old_label", "$1", "old_label", "(.*)")

+1

+1

+1

+1

+1

sry but here is another +1 ...

I think this feature is very useful. +1

this is a needed feature!! +1

+1

+1
Can sort by default the columns, but works if you click on the actual column...

+1

+1

Even simple MoveUp/MoveDown buttons would be better than nothing
+1

+1

+1

+1

+1

+1

Please stop with the +1, I (like many others) are tired of receiving notifications for those comments.

+1

:shakes_fist:

yes for influxdb when dealing with tags, the order of columns is imposed by the alpha-numeric order.
please do it 🙏🏻

+1

For people using Prometheus, I have the world's ugliest hack to get around this.

Suppose I have a query $QUERY that returns vectors with labels $A_LABEL, $SOME_LABEL, and $THIS_LABEL. In my table, I will see the columns in this same order, since I listed them alphabetically. However, I want the order to be $SOME_LABEL, $A_LABEL, $THIS_LABEL.

We can use Prometheus's label_replace to rename my labels so that they are done alphabetically. Then, we can use a sum_by to remove the original labels. This looks like this:

sum by (_0_some_label, _1_a_label, _2_this_label) (
  label_replace(
  label_replace(
  label_replace(

    # The actual query
    $QUERY

  , "_0_some_label", "$1", "some_label", "(.*)")
  , "_1_a_label",    "$1", "a_label",    "(.*)")
  , "_2_this_label", "$1", "this_label", "(.*)")
)

Pretty dumb, right? But it works. Unfortunately, these are ugly names to read, so let's reformat them. Add a column style that matches the regular expression /_\d+_(.*)/. Then set the column header to $1. This way, we strip off our ugly hack and get our original labels as our column headers.

The fact that this is necessary is ridiculous. Column ordering should really be a built in feature. So, you know, +1.

+1

To solve this issue, i ussed a custom backend using the json data source plugin https://grafana.com/plugins/simpod-json-datasource.

+1

I would like this as well

This would be a great feature

+1

FYI - the work around to this bug is to edit the panel json directly. Look for the columns block then move the column definition around in the json. (panel dropdown --> more --> Panel Json)

"columns": [
    {
      "text": "level",
      "value": "level"
    },
    {
      "text": "message.text",
      "value": "message.text"
    },
    {
      "text": "@timestamp",
      "value": "@timestamp"
    }

@WilliamLHarms That only works for some data sources. Prometheus for example builds the columns dynamically, there is no JSON to edit.

@paol - yea, it was an elastic datasource. I guess there isn't a work around for the bug. Just scrap your panel and start over.

We are all waiting for the hero who will apply this feature.

This would be a great feature to have.

Would love to be able to do this as well.

I'd like to see that feature realised.

The feature will improve the user experience greatly.

@WilliamLHarms That only works for some data sources. Prometheus for example builds the columns dynamically, there is no JSON to edit.

Prometheus sort the labels attributes by alphabetic order. Not randomly.

If you have the labels: "hostname", "ip", "cluster", the order will be:

{cluster="", hostname="", ip=""}

But if one label name begins by capital letter the order change.

{IP="", cluster="", hostname=""}

If you want to sort the labels, you can use the label_replace function.

Prometheus Label Replace

+1 and btw if the amount of columns is to high, the header row is stuck and not able to scroll with the rest (#4157)

+1 Why not order on the Column styles order and make them, easy to move so you can drag them on the screen.

@torkelo I still see this is not yet fixed. Using the grafana version 6.7.2.
There should be some ordering option to re arrange the columns.

Coming in 7.0 via the new transform tab!

sum by (_0_some_label, _1_a_label, _2_this_label) (
label_replace(
label_replace(
label_replace(

# The actual query
$QUERY

, "_0_some_label", "$1", "some_label", "(.)")
, "_1_a_label", "$1", "a_label", "(.
)")
, "_2_this_label", "$1", "this_label", "(.*)")
)

it worked for me with 20 columns thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

calind picture calind  ·  3Comments

jackmeagher picture jackmeagher  ·  3Comments

KlavsKlavsen picture KlavsKlavsen  ·  3Comments

ricardclau picture ricardclau  ·  3Comments

yuvaraj951 picture yuvaraj951  ·  3Comments