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:
@@ -282,17 +282,19 @@ the hosts variable only show hosts from the current selected region with a query
|
||||
SELECT hostname FROM host WHERE region IN($region)
|
||||
```
|
||||
|
||||
#### 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 `%`.
|
||||
|
||||
The example below shows how to use `$__searchFilter` as part of the query field to enable searching for `hostname` while the user types in the dropdown select box.
|
||||
> Important that you surround the `__searchFilter` expression with quotes as Grafana does not do this for you.
|
||||
|
||||
The example below shows how to use `__searchFilter` as part of the query field to enable searching for `hostname` while the user types in the dropdown select box.
|
||||
|
||||
Query
|
||||
```sql
|
||||
SELECT hostname FROM my_host WHERE hostname LIKE $__searchFilter
|
||||
SELECT hostname FROM my_host WHERE hostname LIKE '$__searchFilter'
|
||||
```
|
||||
|
||||
### Using Variables in Queries
|
||||
|
||||
Reference in New Issue
Block a user