1

I am creating a variable in Grafana from a mongoDB query. Currently my query returns an array of items in the format of:

name="Bob Hansen", id="8051240138eb2ea033aa21f3"
name="John Doe", id="4051240138eb2ea033aa21f3"
...

Now I am trying to use regex to extract the two key/value pairs like described here: https://grafana.com/docs/grafana/v9.0/variables/filter-variables-with-regex/#filter-and-modify-using-named-text-and-value-capture-groups

I have the following regex:

/name="(?<text>[^"]+)|id="(?<value>[^"]+)/g

But grafana keeps returning no values, unless I remove the regex :(

1 Answer 1

0

You shouldn't use alteration.

Alteration in your regex means, that once first branch is matched, second part is not checked.

Correct expression for this case will be

name="(?<text>[^"]+)", id="(?<value>[^"]+)

Demo here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.