[英]Grafana: Overrriding series with metric named `/var(avail_MB)`: “Panel rendering error '/var(avail_MB)' is not a valid regular expression.”
An Icinga2 plugin (written by myself) returns performance data with metrics named /var(avail_MB)
, /var(total_MB)
and similar.一个 Icinga2 插件(由我自己编写)返回性能数据,其指标名为/var(avail_MB)
、 /var(total_MB)
等。 Data is forwarded to an InfluxDB with Grafana as Frontend.数据被转发到以 Grafana 作为前端的 InfluxDB。
I'm using "GROUP BY" "tag(metric)" and "ALIAS BY" " $tag_metric
" in a dashboard's panel query.我在仪表板的面板查询中使用“GROUP BY”“tag(metric)”和“ALIAS BY”“ $tag_metric
”。 The metric names are displayed correctly below the graph then.然后,指标名称会正确显示在图表下方。
However when I try to override series by specifying "alias or regex" /var(avail_MB)
it does not seem to work, and when going back from panel configuration to dashboard, I get an error message saying " Panel rendering error '/var(avail_MB)' is not a valid regular expression. ".但是,当我尝试通过指定“别名或正则表达式” /var(avail_MB)
来覆盖系列时,它似乎不起作用,并且当从面板配置返回到仪表板时,我收到一条错误消息,提示“面板呈现错误”/var( avail_MB)' 不是有效的正则表达式。 "。 I tried to put a backslash in front of (
and )
, but that didn't help.我试图在(
和)
前面加上一个反斜杠,但这没有帮助。 To make matters worse, the whole graph disappeared, and when trying to open the "Query Inspector", the frontend seems to take forever (Query never appears).更糟糕的是,整个图表消失了,当试图打开“查询检查器”时,前端似乎需要永远(查询永远不会出现)。
What is the problem, and how could I fix it?有什么问题,我该如何解决? I'm new to Icinga2, Grafana and InfluxDB (I'm just a "user" not administrator of those).我是 Icinga2、Grafana 和 InfluxDB 的新手(我只是这些的“用户”而不是管理员)。
The color change is not applied to the graph.颜色更改不会应用于图表。
Here is an example of plugin output:这是插件 output 的示例:
OK: /var: 3114/5632MB (55.30%), slope is NaN|/var(total_MB)=5631.56MB;;;0 /var(avail_pct)=55.30%;25;5;0;100 /var(avail_MB)=3114.12MB;10;5;0;5632 /var(est_avail_MB)=nanMB;10;5;0;5632
(The "nanMB" was a bug in the plugin that has been fixed already, but that data wasn't from the machine in question.) (“nanMB”是插件中的一个错误,已经修复,但该数据不是来自有问题的机器。)
The problems seems to be the beginning of the string ("/var").问题似乎是字符串的开头(“/var”)。 Grafana seems to treat every string starting with /
as regular expression, and it expects any regular expression to start with /
, too (it seems). Grafana 似乎将每个以/
开头的字符串视为正则表达式,并且它希望任何正则表达式也以/
开头(似乎)。
So the fix was to add a trailing /
, and escape the literal /
as \/
.所以解决方法是添加一个尾随/
,并将文字/
转义为\/
。
Unfortunately this only removes the error message, but doesn't make the override work (match).不幸的是,这只会删除错误消息,但不会使覆盖工作(匹配)。 It is also required to backslash-escape the parentheses and the slash(es):还需要对括号和斜杠进行反斜杠转义:
Instead of /var(total_MB)
you need to write /\/var\(total_MB\)
.而不是/var(total_MB)
您需要编写/\/var\(total_MB\)
。
The original problem has two origins:最初的问题有两个根源:
The monitoring plugin specification at https://www.monitoring-plugins.org/doc/guidelines.html#AEN201 states: " 2. label can contain any characters except the equals sign or single quote (') ") states that any character except =
and '
is allowed as metric name. https://www.monitoring-plugins.org/doc/guidelines.html#AEN201的监控插件规范指出:“ 2. label 可以包含除等号或单引号 (') ") 之外的任何字符除了=
和'
允许作为指标名称。
Grafana v6.7.3 proposes the incorrect (ie: unescaped) values for "alias or regex". Grafana v6.7.3 为“别名或正则表达式”提出了不正确的(即:未转义的)值。
That is how I had created the problem.这就是我制造问题的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.