# Label substring as legend

**URL:** <https://community.grafana.com/t/label-substring-as-legend/128433>\
**Category:** Dashboards\
**Created:** [August 12, 2024, 2:27pm UTC](https://community.grafana.com/t/label-substring-as-legend/128433 "2024-08-12T14:27:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![coleslaw](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coleslaw](https://community.grafana.com/u/coleslaw)\
**Post date:** [August 12, 2024, 2:27pm UTC](https://community.grafana.com/t/label-substring-as-legend/128433/1 "2024-08-12T14:27:42Z")

</div>

I have a Prometheus timeseries, it has a label “host”. So I can use `{{host}}` as legend and get its values like:  
com.acme.www  
com.acme.mail  
com.acme.ftp

Is there a way to specify the legend so that it only displays the last substring:  
www  
mail  
ftp

I’m using version 10.4.5.

---

<div class="post-metadata">

**Author:** ![ebabeshko](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@ebabeshko](https://community.grafana.com/u/ebabeshko)\
**Post date:** [August 12, 2024, 2:38pm UTC](https://community.grafana.com/t/label-substring-as-legend/128433/2 "2024-08-12T14:38:50Z")

</div>

Use [Rename by regex](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#rename-by-regex) transformation:

 ![Transformation](https://us1.discourse-cdn.com/grafana/original/3X/7/a/7af57e185c0b1ec5e80acd6277b0259b4934b064.png)

---

<div class="post-metadata">

**Author:** ![coleslaw](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@coleslaw](https://community.grafana.com/u/coleslaw)\
**Post date:** [August 12, 2024, 6:53pm UTC](https://community.grafana.com/t/label-substring-as-legend/128433/3 "2024-08-12T18:53:48Z")

</div>

Wow, that’s exactly what I needed. Thanks [ebabeshko](https://community.grafana.com/u/ebabeshko) !

---

<div class="post-metadata">

**Author:** ![shashwatdelhi](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/shashwatdelhi/32/53387_2.png) [@shashwatdelhi](https://community.grafana.com/u/shashwatdelhi)\
**Post date:** [March 21, 2025, 11:33am UTC](https://community.grafana.com/t/label-substring-as-legend/128433/4 "2025-03-21T11:33:30Z")

</div>

Thanks for the response man. I have been trying to get it to work with overrides. Is it possible to have this globally on a dashboard level?
