Variables: Adds named capture groups to variable regex (#28625)
* Dashboard: Add named capture groups to variable query regex Variable query regex are able to use 'text' and 'value' named capture groups to allow for separate display text to be extracted from the query result. e.g. Using a regex of /foo="(?<text>[^"]+)|bar="(?<value>[^"]+)/g on a query result of metric{foo="FOO", bar="BAR"} would result in the variable value being set to 'BAR' but display text being set to 'FOO' Resolves #21076 * Improve regex capture group documentation * Update docs/sources/variables/filter-variables-with-regex.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com> * Use text capture if value capture does not match This is to keep the behaviour consistent with the current behavior. See discussion https://github.com/grafana/grafana/pull/28625/files#r516490942 * Improve regex field placeholder and tooltip message To make the feature more discoverable to users the place holder example now includes the named capture groups. The tool tip message also includes a reference and link to the documentation. Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
Showing
Please
register
or
sign in
to comment