shorten variable

  • What Grafana version and what operating system are you using?

  • Grafana in Docker Grafana v7.1.3 (5723d951af) oder Grafana v8.0.4 (81fef5b4b4)

  • What are you trying to achieve?

  • Shorten Template Variable ($hostname)

  • How are you trying to achieve it?

  • No Ideas

  • What happened?

  • Nothing

  • What did you expect to happen?

  • Tutorial / Help to shorten Variable

we pull from a icinga2 database all host names, we use these in different dashboards with templates to display uniform graphs for all machines. With a handful of graphs, however, it bothers us that icinga provides the fqdn name, but I do not want to see this in the dashboard. is there a way to shorten variables?

Variable hostname
Query: SHOW TAG VALUES WITH KEY = “hostname”.
Regex: /win.c00505|win.c00508|win.c00512|win.c00531|win.c00542|win.mgmt/

(names by way of example)

Preview:
app-c00505-p01-win.c00505.axs-host.de
app-c00505-p02-win.c00505.axs-host.de
app-c00505-p03-win.c00505.axs-host.de
app-c00505-p04-win.c00505.axs-host.de
app-c00505-p05-win.c00505.axs-host.de
app-c00505-p08-win.c00505.axs-host.de
app-c00508-p01-win.c00508.axs-host.de
app-c00508-p02-win.c00508.axs-host.de
app-c00508-p03-win.c00508.axs-host.de
app-c00508-p04-win.c00508.axs-host.de
app-c00508-p05-win.c00508.axs-host.de
app-c00508-p06-win.c00508.axs-host.de

for some graphs and text fields I would like to display ONLY app-c00508-p06-win instead of app-c00508-p06-win.c00508.axs-host.de.

thanks in advance