Skip to content

incorrect interpolation of multi-value variable in regex #238

@pgassmann

Description

@pgassmann

the query: host:~'^$host$' with host variable multi select of backup3 and backup4

is interpolated to: host:~'^"(backup3|backup4)"$' (as seen in the query inspector)

There are additional quotes around the regex.

Expected query: host:~'^(backup3|backup4)$'

Background Use Case:

I would like to filter logs based on multiple selected values, of e.g. the host label

The dashboard variables returns multiple values formatted regex (foo|bar|three).
if using regexp filter host:~"$host" it partially works, but matches anything with that substring. also, regexp filter is not good for performance

Originally, the workaround with using regex start and end matchers worked, but later the quotes were introduced, now this doesn't work anymore.
I would prefer that the quoting is left to the user of the variable and not returning quotes in the variable value.
#65 (comment)

UPDATE: host:in($host) works correctly. Simplified this issue to be specific about the interpolation in regex.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions