Templating: Makes so __searchFilter can be used as part of regular expression (#20103)

* Fix: Fixes searchfilter wildcard char in regular expressions
Fixes: #20006

* Refactor: Uses TemplateSrv and ScopedVars instead

* Docs: Updates docs with new format

* Tests: Corrects test description
This commit is contained in:
Hugo Häggmark
2019-11-04 06:43:03 +01:00
committed by GitHub
parent fc5cc4cbf9
commit 7aeed4d987
12 changed files with 224 additions and 132 deletions
+10 -4
View File
@@ -114,19 +114,25 @@ variable with all possible values that exist in the wildcard position.
You can also create nested variables that use other variables in their definition. For example
`apps.$app.servers.*` uses the variable `$app` in its query definition.
#### Using `$__searchFilter` to filter results in Query Variable
#### Using `__searchFilter` to filter results in Query Variable
> Available from Grafana 6.5 and above
Using `$__searchFilter` in the query field will filter the query result based on what the user types in the dropdown select box.
When nothing has been entered by the user the default value for `$__searchFilter` is `*`.
Using `__searchFilter` in the query field will filter the query result based on what the user types in the dropdown select box.
When nothing has been entered by the user the default value for `__searchFilter` is `*` and `` when used as part of a regular expression.
The example below shows how to use `$__searchFilter` as part of the query field to enable searching for `server` while the user types in the dropdown select box.
The example below shows how to use `__searchFilter` as part of the query field to enable searching for `server` while the user types in the dropdown select box.
Query
```bash
apps.$app.servers.$__searchFilter
```
TagValues
```bash
tag_values(server, server=~${__searchFilter:regex})
```
### Variable Usage
You can use a variable in a metric node path or as a parameter to a function.