* Support having a datasources array in the rules filter * Fix tests * Display a MultiplePicker for filtering datasources * Fix tests * Refactor as MultipleDataSourcePicker as FC * Make select box wider * Remove FC from component definition * Display ds options in groups based on whether they manage/don't manage rules * Change dropdown texts and add help info |
||
---|---|---|
.. | ||
README.md | ||
rulesSearchParser.test.ts | ||
rulesSearchParser.ts | ||
search.grammar | ||
search.js | ||
search.terms.js | ||
searchParser.ts |
Alerting search syntax
Lezer grammar
Alerting uses the Lezer parser system to create a search syntax grammar.
File search.grammar describes the search grammar.
@lezer/generator
package is used to generate search.js and search.terms.js files which include a JS grammar parser.
Changing the grammar
After making changes in the search.grammar
file, a new version of the parser needs to be generated.
To do that, the following command needs to be run in the public/app/features/alerting/unified/search
directory
yarn dlx @lezer/generator search.grammar -o search.js
The command will re-create search.js and search.terms.js files which are the files containing grammar parser.
Extensibility
The search.grammar
uses the dialects feature of Lezer to enable parsing of each filter term separately.
This will allow us to have a single grammar file for handling filter expressions for all of our filters (e.g. Rules, Silences, Notification policies). Then we can configure the required set of filters dynamically in the JS code using the parser.