Ken Tsoi
Ken Tsoi

Reputation: 1303

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

I am working on a Loki-based Dashboard on Grafana. I have one panel for searching text in the Loki trace logs, the current query is like:

{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.

I want to include another variable skipTestLog to skip logs created by some test cron tasks. skipTestLog is a custom variable of two options: 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?

Upvotes: 6

Views: 7670

Answers (1)

Create a key/value custom variable like in the following example:

enter image description here

Use the variable like in the following example:

enter image description here

Upvotes: 7

Related Questions