Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow re-ordering of columns in table panel configuration #5082

Closed
volter opened this issue May 18, 2016 · 63 comments
Closed

Allow re-ordering of columns in table panel configuration #5082

volter opened this issue May 18, 2016 · 63 comments

Comments

@volter
Copy link
Contributor

volter commented May 18, 2016

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.

@jayannah
Copy link

+1

@MrBoggi
Copy link

MrBoggi commented Jan 10, 2017

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

@marianob85
Copy link

+1

4 similar comments
@jameswongyou
Copy link

+1

@boeboe
Copy link

boeboe commented Aug 3, 2017

+1

@annevanleyden
Copy link

+1

@AInoob
Copy link

AInoob commented Oct 4, 2017

+1

@amgorb
Copy link

amgorb commented Jan 18, 2018

indeed +1

@JinlinSong
Copy link

+1

@paol
Copy link

paol commented May 18, 2018

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.

@torkelo
Copy link
Member

torkelo commented May 18, 2018

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

@paol
Copy link

paol commented May 18, 2018

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

@cxxly
Copy link

cxxly commented May 24, 2018

+1

@cxxly
Copy link

cxxly commented May 25, 2018

is there any progress?

@Stono
Copy link

Stono commented Jul 8, 2018

+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

@Rellek72
Copy link

Rellek72 commented Jul 12, 2018

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

@iamash
Copy link

iamash commented Jul 18, 2018

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)

@jeremyxu2010
Copy link

+1

@jeremyxu2010
Copy link

+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", "(.*)")

@curiTTV
Copy link

curiTTV commented Aug 7, 2018

+1

4 similar comments
@s7v7nislands
Copy link

+1

@Meta4X
Copy link

Meta4X commented Sep 25, 2018

+1

@yanivroz
Copy link

+1

@ksemaev
Copy link

ksemaev commented Oct 31, 2018

+1

@sjentzsch
Copy link

sry but here is another +1 ...

@cactusgame
Copy link

I think this feature is very useful. +1

@cyyeong
Copy link

cyyeong commented Nov 14, 2018

this is a needed feature!! +1

@TylerZale
Copy link

+1

@onedr0p
Copy link

onedr0p commented Feb 19, 2019

:shakes_fist:

@ghost
Copy link

ghost commented Mar 27, 2019

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

@debmalyapan53
Copy link

+1

@jutley
Copy link
Contributor

jutley commented Apr 16, 2019

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.

@c6h3un
Copy link

c6h3un commented Jun 12, 2019

+1

@ghost
Copy link

ghost commented Jun 12, 2019

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

@WilliamLHarms
Copy link

+1

@amytleonard
Copy link

I would like this as well

@apanagar
Copy link

apanagar commented Sep 9, 2019

This would be a great feature

@qyvlik
Copy link

qyvlik commented Sep 23, 2019

+1

@WilliamLHarms
Copy link

WilliamLHarms commented Sep 23, 2019

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"
    }

@paol
Copy link

paol commented Sep 23, 2019

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

@WilliamLHarms
Copy link

@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.

@bzon
Copy link

bzon commented Sep 27, 2019

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

@binduv124
Copy link

This would be a great feature to have.

@zimmertr
Copy link

Would love to be able to do this as well.

@joker234
Copy link

I'd like to see that feature realised.

@ZeroMagic
Copy link

The feature will improve the user experience greatly.

@r2dedios
Copy link

r2dedios commented Dec 17, 2019

@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

@AIXruth
Copy link

AIXruth commented Jan 25, 2020

+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)

@neeles83
Copy link

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

@kushalsen38
Copy link

@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.

@torkelo torkelo added this to the 7.0 milestone May 5, 2020
@torkelo
Copy link
Member

torkelo commented May 5, 2020

Coming in 7.0 via the new transform tab!

@torkelo torkelo closed this as completed May 5, 2020
@jothibasu-kamaraj
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests