如何从Grafana变量中创建常规表达。涌入2.0dB
我有这个查询,可以从git中获取分支信息。我希望能够通过变量“史诗”过滤数据。在Grafana中,我从数据库中获取了史诗数据,可以从下拉列表中的每个Epic(MultiSelect)中选择它。
from(bucket: "my_bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "my_measure")
|> filter(fn: (r) => r["_field"] == "Score")
|> filter(fn: (r) => r["epic"] == "${epic_db}")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
但是,当我在列表中选择多个史诗时,我得到了:
|> filter(fn: (r) => r["epic"] == "{epic-1,epic-2}")
它不像Squl中的SQL(epic1,epic2等)那样工作。 对我有用的是,
filter(fn: (r) => r["epic"] =~ /epic1|epic2|epic3/
要通过使用此下拉列表检查列表和Grafana中的变量来构建这样的正则是这样,但我不知道如何构建这样的正则命令。我正在尝试所有类似的事情:
"/${epic_db}/"
但是没有工作。有什么想法,如何使用Flux的InfuxDB2.0使其成为可能?
I have this query that pulls branch information from GIT. I would like to be able to filter the data by the variable "epic". In Grafana, I have the epic data pulled from the database and it can be selected from a dropdown list witch checkbox for each epic (multiselect).
from(bucket: "my_bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "my_measure")
|> filter(fn: (r) => r["_field"] == "Score")
|> filter(fn: (r) => r["epic"] == "${epic_db}")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
But when i select more than one epic on list, i got this:
|> filter(fn: (r) => r["epic"] == "{epic-1,epic-2}")
Which is not working like the SQL IN statement (WHERE epic IN (epic1, epic2, etc).
The thing that is working for me, is to build the regex like this
filter(fn: (r) => r["epic"] =~ /epic1|epic2|epic3/
But i have no idea, how to build such a regex, by using this drop-down-check-list with variables in Grafana. I was trying all that stuff like:
"/${epic_db}/"
But is not working. Any ideas, how to make it possible using InfluxDB2.0 with Flux?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请查看可变格式选项文档 >。
基本上Grafana允许您选择查询中的变量格式。在您的情况下,您可以执行这样的操作:
这样,您可以在通量查询语言的Regex功能中使用构建。
Have a look at the variable formatting options documentation here.
Basically grafana allows you to choose how the variable is formatted in your query. In your case you can do something like this:
This way you can use the build in regex functionality of the flux query language.