I have ":9100" showing up at the end of my metrics. I am using a prometheus datasource with my company and can't change it. Has anyone figured out how to remove this? I was thinking maybe templates or regex but I haven't been successful yet.
Configuration:
Legend Format = {{hostname}}
Result = myhostname.mydomain.com:9100
As far as I know, currently it is not possible to format the legend in Grafana (there is an open PR for it), however as you are using Prometheus, you can use its label_replace()
function, eg.:
label_replace(my_vector, "short_hostname", "$1", "hostname", "(.*):.*")
This should give you:
Legend Format = {{short_hostname}}
Result = myhostname.mydomain.com
See the docs here - label_replace
In Grafana 8.0, there is Transform menu that can be used to remove text. I hope it is still relevant to this question.
On Dashboard, select the panel > Edit. There are 3 tabs below chart, one of them is Transform. Select Transform > Add Transformation > Rename by Regex, fill the form with these values:
Please refer to the link for detailed information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With