How to override metric name?

Is it possible to set alternative names for metrics in graph panel?
By default metric name is returned from datasource response.
For example I want name “My alternative metric #1” instead of “metric_1”, “My alternative metric #2” instead of “metric_2”.

1 Like

Yes, it is done differently for different data sources. What data source are you using?

  • Graphite: alias or aliasByNode function
  • Prometheus: “Legend format” field on the metric tab
  • InfluxDB: “Alias By” field on the metric tab
1 Like

I created own datasource for BMC ProactiveNet based on simple json datasouce.
JSON responce from ProactiveNet contains only metric name.
I can’t change JSON format for responce - for example add another variables.

Are “aliasByNode”, “Legend format”, “Alias By” datasource specific functions?
In other words, these values returns with responce or they stored in Grafana for every request and applied for every time series response?

As I understand correctly requests from Grafana are send asynchroniously.
I tried to create special variable “target.alias”, but last value of it applied for all metric names in responce.

hi , I encounter the same problem . I use grafana + prometheus monitor metrics from etcd .

in template I define a variable like this:

$cluster label_values(etcd_server_has_leader,job)

and I select in prometheus the result shows:


also the variables shows “ch-etcd-global” and “th-etcd-global”,
I want to make “ch-etcd-global” showed as “china” and “th-etcd-global” showed as "thailand "
, at the same time I do not want the other variable which dependent on it invalid.
what should I do ?
thanks in advance !

Yes, those functions are database-specific. So if you want this feature in your data source, then you will have to implement it. Here is how I did it for the Azure Monitor data source:

Can you not just add an extra label with values like china or thailand when saving your metrics?

thanks for detailed reply .
but still a little confused .
you mean when grafana saving metrics from prometheus , and make them show different ones ? how make that happen?
if I save them as china or thailand , what about the other variables which dependent on this one ?
let’s say there is anohter variable in templating shows as:
label_values(container_memory_usage_bytes{container_name=~“etcd|mysql|vtctld|vttablet”,namespace="$NS"}, pod_name)
will the other variables can not be loaded match info because the modified value ?

I mean when you save your metrics to Prometheus that you could add some extra labels or do some relabelling:

thanks . it is helpful

How can we accomplish this with elasticsearch?

Hi, I also need help on this to override metric name.

My data source is Microsoft SQL Server.

I would appreciate for the response and advise on this.

1 Like