Grafana 图例格式 :9100 removal

标签 grafana prometheus grafana-templating

我的指标末尾显示了“: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/

相关文章:

json - 使用jsonnet更改json字符串

graph - 我无法为 grafana 图设置警报

grafana - Grafana 中的条件模板值

regex - 正则表达式: how to deal with character/

grafana - InfluxDB 查询如何过滤掉不存在行的数据

jmeter - 如何使用后端监听器从 JMeter 获取数据到 influxDB?

prometheus - 如何在 Prometheus 警报中匹配多个标签?

prometheus - 为什么我的 Prometheus Operator ServiceMonitor 需要 `release` 标签才能正常运行?

mysql - Grafana 选择查询抛出错误 - "Found no column named time or time_sec"

InfluxDB - Drop 系列不起作用