Grafana `group_by [re_replace ...` breaks text in the legend

18 views Asked by At

I'm using the following graph definition

fetch my_source
| metric 'my_source.com/api_request_count_total/counter'
| filter metric.route = 'all_endpoints'
| every($__interval)
| group_by [metric.version]

This works, but metric.version includes patch numbers that I don't want, causing a legend like this: Example Legend

So I'm trying to leverage re_replace:

| group_by [re_replace(metric.version, '.*_(..\...?).*', r'\1')]

But the new legend looks like this:

enter image description here

The aggregation itself seems to be working correctly as I'm noticing less entries in the legend overall. But the label itself in the legend is broken

1

There are 1 answers

0
Mikhail On

Found this syntax that does the trick:

| group_by [metric.version: re_replace(metric.version, "<your regex>", r"\1")]