Allow Legend Formatting of Custom Metrics with Templates

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Problem to solve

When creating a Grafana dashboard, a user can use template substations like {{hostname}} or {{status}} in the legend format which will be replaced in the chart. We do not have this feature for custom metric charts within GitLab.

This was identified in #13564 (closed) as a limitation to our custom metrics.

Further details

In Grafana, if you were using a prometheus query like:

sum by(status)(irate(alertmanager_alerts_received_total[5m]))

You would get a chart with a legend like this:

Screen_Shot_2019-09-24_at_1.58.32_PM

However, if you set the legend format to {{status}} like this:

Screen_Shot_2019-09-24_at_1.57.59_PM

Then the legend will be updated accordingly like this:

Screen_Shot_2019-09-24_at_1.58.20_PM

We do allow the user to set the legend in custom metrics, but we do not do the template replacement:

Screen_Shot_2019-09-24_at_2.22.30_PM

Proposal

Allow the user to use templating in legend formats.

Links / references

The limited Grafana documentation is located here: https://grafana.com/docs/features/datasources/prometheus/#templating

Edited Jul 01, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading