grafana/public/app/features/alerting/unified/search
Konrad Lalik 26e71953a4
Alerting: Improve integration with dashboards (#80201)
* Add filtering by dashboard UID annotation

* Update the inline doc for search

* Add AlertRulesDrawer to the dashboards toolbar

* Use DashboardPicker as a filter on the alert rules page

* Fix accessibility errors

* Update drawer subtitle

* Display Alerting toolbar button only if there are linked alert rules

* Change toolbar rendering method, prevent displaying when no linked rules

* Improve text

* Use React.lazy to load the Alert rule toolbar button and drawer when needed
2024-01-29 16:09:10 +01:00
..
README.md Alerting: Alert rules search improvements (#61398) 2023-01-26 13:44:14 +01:00
rulesSearchParser.test.ts Alerting: Support filtering rules by multiple datasources (#64355) 2023-03-22 12:02:56 -03:00
rulesSearchParser.ts Alerting: Improve integration with dashboards (#80201) 2024-01-29 16:09:10 +01:00
search.grammar Alerting: Improve integration with dashboards (#80201) 2024-01-29 16:09:10 +01:00
search.js Alerting: Improve integration with dashboards (#80201) 2024-01-29 16:09:10 +01:00
search.terms.js Alerting: Improve integration with dashboards (#80201) 2024-01-29 16:09:10 +01:00
searchParser.ts Alerting: Improve integration with dashboards (#80201) 2024-01-29 16:09:10 +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.