Allow Legend Formatting of Custom Metrics with Templates
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:
However, if you set the legend format to {{status}}
like this:
Then the legend will be updated accordingly like this:
We do allow the user to set the legend in custom metrics, but we do not do the template replacement:
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