简体   繁体   English

Grafana - 是否可以在基于 Loki 的仪表板查询中使用变量?

[英]Grafana - Is it possible to use variables in Loki-based dashboard query?

I am working on a Loki-based Dashboard on Grafana.我正在 Grafana 上开发基于 Loki 的仪表板。 I have one panel for searching text in the Loki trace logs, the current query is like:我有一个用于在 Loki 跟踪日志中搜索文本的面板,当前查询如下:

{job="abc-service"}
|~ "searchTrace"
|json
|line_format "{if .trace_message}} Message: \t{{.trace_message}} {{end}}"

Where searchTrace is a variable of type "Text box" for the user to input search text.其中searchTrace是“文本框”类型的变量,供用户输入搜索文本。

I want to include another variable skipTestLog to skip logs created by some test cron tasks.我想包含另一个变量skipTestLog以跳过某些测试 cron 任务创建的日志。 skipTestLog is a custom variable of two options: Yes,No . skipTestLog是两个选项的自定义变量: Yes,No

Suppose the logs created by test cron tasks contain the text CronTest in the field trace_message after the json parser, are there any ways to filter them out based on the selected value of skipTestLog ?假设测试 cron 任务创建的日志在json解析器之后的字段trace_message中包含文本CronTest ,有没有什么方法可以根据skipTestLog的选择值过滤掉它们?

Create a key/value custom variable like in the following example:创建一个键/值自定义变量,如下例所示:

在此处输入图像描述

Use the variable like in the following example:使用以下示例中的变量:

在此处输入图像描述

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

相关问题 在 grafana loki 查询 (LogQL) 上使用变量 - Use variables on grafana loki queries (LogQL) 可以以编程方式将查询添加到 Grafana 仪表板吗? - Possible to add a query programmatically to a Grafana dashboard? 是否可以在 Grafana 上按天聚合 Loki 日志? - Is it possible to aggregate Loki logs by day on Grafana? 是否可以根据名称过滤使用 GRAFANA 在仪表板中创建的面板 - Is it possible to filter the panels created in a dashboard using GRAFANA based on their name 有没有办法在基于正则表达式的 LOKI 查询中使用推断值? - Is there a way to use inferred values in a regex based LOKI query? 如何在另一个变量正则表达式中使用 Grafana 仪表板变量? - How to use Grafana dashboard variable in another variables regex? 如何在 LOKI 中使用二元运算符? 格拉法纳 - How to use binary operators in LOKI ? Grafana Grafana 仪表板显示 JSON Loki 记录中的键的指标 - Grafana dashboard to display a metric for a key in JSON Loki record 如何在 Grafana + InfluxDB 中使用键/值仪表板变量? - How can I use key/value dashboard variables in Grafana + InfluxDB? Grafana仪表板变量-处理基于查询的变量中的NULL值 - Grafana dashboard variable - handling NULL values in Query-based variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM