简体   繁体   English

Grafana 变量引用 prometheus 统计名称的一部分

[英]Grafana variable to reference part of prometheus stat name

Is it possible to reference a prometheus metric by partially using a Grafana variable?是否可以通过部分使用 Grafana 变量来引用普罗米修斯指标?

I have metrics coming in from multiple sources like this我有来自多个来源的指标,像这样

foo_bar{job, status} zoo_bar{job, status} xoo_bar{job, status} foo_bar{job, status} zoo_bar{job, status} xoo_bar{job, status}

I have added an interval variable with a list of possible prefixes foo, zoo, xoo.我添加了一个区间变量,其中包含可能的前缀 foo、zoo、xoo 的列表。 How do I reference the stats if I want to combine charts on one dashboard?如果我想在一个仪表板上合并图表,如何参考统计数据? I tried something like this, but it gives me syntax error at the $ sign.我尝试了类似的方法,但它在 $ 符号处给了我语法错误。

    increase(${var_name}_bar{job="myjob", status!~="401|404|500"})

Adding answer for anybody potentially having the same issue.为任何可能遇到相同问题的人添加答案。 Seems like moving the metric stats in side the curly brackets and referencing name works.似乎将度量统计信息移动到大括号中并引用名称有效。 If there is aa better solution I would be happy to know.如果有更好的解决方案,我很乐意知道。

    increase({__name__=~"${variable}_bar", job="myjob", status!~="401|404|500"})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM