我的指标末尾显示了“:9100”。我在我的公司使用普罗米修斯数据源并且无法更改它。有没有人想出如何删除它?我在想模板或正则表达式,但我还没有成功。
配置:
图例格式 = {{主机名}}
结果 = myhostname.mydomain.com:9100
最佳答案
据我所知,目前无法在 Grafana 中格式化图例(有一个公开的 PR),但是当您使用 Prometheus 时,您可以使用它的 label_replace()
功能,例如:
label_replace(my_vector, "short_hostname", "$1", "hostname", "(.*):.*")
这应该给你:
Legend Format = {{short_hostname}}
Result = myhostname.mydomain.com
See the docs here - label_replace
关于Grafana 图例格式 :9100 removal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47293510/