Special Characters in Grafana Variable Causing "no data" Output in Query

438 views Asked by At

I've encountered an odd interaction in my Grafana dashboard where I'm storing a specific string in a variable called errorMsg. The string is: ERROR: DoorBoard: SetErrorClass[Uart]: Open /dev/ttyUSB2 Exception: Access to the port '/dev/ttyUSB2' is denied.

When I insert this string directly into my query, it works as expected and returns data. Note that for demonstration purposes, I put $errorMsg in the title of the dashboard to show that it is getting interpreted correctly. However, the characters ' seem to be problematic when inserting into the regex: enter image description here

When I copy the exact same variable (as shown in the Dashboard Title) in place of the $errorMsg, I get the expected output: enter image description here

As explained above, the difference seems to be in the characters '. When I try the same with messages without these characters, I don't have any issues.

Another Example: enter image description here enter image description here

I've attempted to escape the special characters in the errorMsg variable, but still encounter the "no data" output. I expected the query to work the same way whether the error message string is inserted directly or referenced through the variable.

1

There are 1 answers

0
Falke On BEST ANSWER

{job="systemd-journal"} |~ ${errorMsg:raw} works as markalex suggested