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: 
So I'm trying to leverage re_replace:
| group_by [re_replace(metric.version, '.*_(..\...?).*', r'\1')]
But the new legend looks like this:
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

Found this syntax that does the trick: