Optimalization of transformation in Bar Guages

  • What Grafana version and what operating system are you using?
    11.6.1
  • What are you trying to achieve?
    I am wondering if it can be done differently with better optimization.
  • How are you trying to achieve it?
    1) Labels to fields

2) Group by calculating las + group by labels (now there are fields because of the first transformation)
I am calculating the grouped by metrics as a LAST value

3) Merge Series/tabels

4) group by one of the labels (for ignoring one of the labels)

5) Add field from calculation: Reducing the entries with calculation as a ‘Total’ and putting a new name for Total.

6) Add field from calculation: Reducing the entries with calculation as a ‘Total’ and putting a new name for Total.

7) Add field from calculation: Reducing the entries with calculation as a ‘Total’ and putting a new name for Total.

8) Add field from calculation: Reducing the entries with calculation as a ‘Total’ and putting a new name for Total.

9) Add field from calculation: Reducing the entries with calculation as a ‘Total’ and putting a new name for Total.

10) Organize fields by name - I am organizing here new names from transformations 5-9

I assume that this is quite well organized and there is more “organizing” than calculation itself.
But after watching the grafana campfire - I’m starting to think about that.

What are you guys thinking about that? Is there any better option?

  • What did you expect to happen?
    I am curious if it can be done better.

I personally try to stay as far away as possible from transformations and only use them when I cannot do it in my datasource.

What is your datasoure?

What is the original data look like in this datasource?

What do you want it to look like at the end

I am using the Victoria Metrics metrics (based on Prometheus)

I have 11 metrics with different labels like this.

msg_cnt{Category=“A”,Destination=“Dest_1”} 43
msg_cnt{Category=“B”,Destination=“Dest_2”} 123
msg_cnt{Category=“C”,Destination=“**Dest_**2”} 213

msg_failed{Category=“A”,Destination=“Dest_1”} 43
msg_failed{Category=“B”,Destination=“Dest_2”} 123
msg_failed{Category=“C”,Destination=“Dest_2”} 213

There can be many such metrics with different variations — for example, the same category with different destinations, or the same destination with different categories.

My goal is to create a Bar Gauges that displays different categories (A, B, C, etc.) for each destination (or all of them).
Here you can see me screenshot from the current setup (I deleted the names of categories)

To achieve this, I use labels as values, which allows filtering through variables (steps are shown above).

For example, if I select only Dest_1, I should see a bar gauge showing all corresponding categories.

However, I need to apply the transformation at the end, because I want to display only the current snapshot value.