2

The following functions are from the "Transform tab" in Grafana, have a look at Transformation types and options for examples.

I have tested the "Rename by regex" function which works fine, see the small example in the screenshot where I replace the column_name with a chosen pattern by another name (here just by a 2, quick example only).

The aim is to get an automated sorting of a chain of steps which should be adapted dynamically in a central mapping table so that "column_name_1" gets mapped to "a010 column_name_1" for example - which then sorts the steps automatically. I should not have an extra column in the queries so that I do not need to do fiddly tasks like reordering the chain and go through all of the not even ordered SQL queries.

I could also use the "Sort by" function of the "Transform" tab, but then I would have to keep an eye on the added text columns in my queries, and I use a lot of queries in a "-- Mixed Data Source --". It might be easier to keep an overview when having the mapping table instead. Sorting by another column is likely not the right workaround for me.

  • I also need a step number to be seen in each box anyway and the information would rather be seen when hovering over it, that is why I do not mind having the sorting string in the same column.
  • In addition, I do not know how to add a second output column with just that sorting text in a metrics query that gives me only one alias which I can change, not two or more as a SQL query does.

This is how it would look in a "Polystat panel" with boxes in it:

enter image description here

Since I have a lot of cases that need to be sorted in a growing chain of steps, I would rather use a mapping table instead of adding a new regex rule for each column or sorting by an additional "sort by" column.

How to add my own mapping table to the dropdown menu of the "field lookup" function in the "Transform" tab?

For now, there is only

  • Countries
  • USA States
  • Airports

I would like to have MY_PROJECT_STEPS_MAPPING as well in there with a link to something like:

"column_name_1": "a010 column_name_1"
"column_name_2": "a060 column_name_2"
"column_name_3": "b010 column_name_3"
"column_name_4": "b020 column_name_4"

How can that be done?

enter image description here

questionto42
  • 2,691

1 Answers1

0

Short:
I can only guess. Perhaps this is not wanted as a tool since regex threshold matches would stop working.

Long:
If you replace parts of a name with the "Rename by regex" function in the transform tab, any regex on a threshold will ignore what you have replaced by regex before, if I remember it right. I do not know what will happen if a mapping table replaces even the whole name! Perhaps you will lose regex for thresholds!? Which might be the reason why custom mapping tables are not made available.

questionto42
  • 2,691