首页 > 解决方案 > 正则表达式与 Grafana 中绘图(可视化)别名中的变量

问题描述

我的查询别名为:

"Temperature $Names1" and "Power $Names1"

我希望我的传奇阅读:

"Temperature <name>" and "Power <name>"

我的图例按预期工作,但我正在尝试设置别名,以便可以在 y-axis2 上绘制 Power 数据并设置颜色。

在“别名或正则表达式”的可视化下,我输入了:

/^Power $Names1$/

似乎我的变量的 $ 正在终止正则表达式。我尝试了各种逃避它的方法,但没有成功。

也许我在做一些明显错误的事情?

标签: regexgrafanaregex-lookaroundsregex-groupregex-greedy

解决方案


此链接可帮助您为 Grafana 编写正确的表达式。

Grafana 中的示例

Regex
Formats multi-value variable into a regex string.

servers = ['test1.', 'test2']
String to interpolate: '${servers:regex}'
Interpolation result: '(test1\.|test2)'

基于此,您可能想要修改您尝试传递的变量。


推荐阅读