grafana/public/app/features/alerting/unified/search
2023-02-01 13:32:06 +01:00
..
README.md Alerting: Alert rules search improvements (#61398) 2023-01-26 13:44:14 +01:00
rulesSearchParser.test.ts Alerting: Add support for "normal" as state filter in rule search (#62630) 2023-02-01 13:32:06 +01:00
rulesSearchParser.ts Alerting: Add support for "normal" as state filter in rule search (#62630) 2023-02-01 13:32:06 +01:00
search.grammar Alerting: Alert rules search improvements (#61398) 2023-01-26 13:44:14 +01:00
search.js Alerting: Alert rules search improvements (#61398) 2023-01-26 13:44:14 +01:00
search.terms.js Alerting: Alert rules search improvements (#61398) 2023-01-26 13:44:14 +01:00
searchParser.ts Alerting: Alert rules search improvements (#61398) 2023-01-26 13:44:14 +01:00

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.