The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/unified/search
Tom Ratcliffe 4f7ffafe98
Alerting: Consistently order member imports in alerting code (#97688)
5 months ago
..
README.md
rulesSearchParser.test.ts Alerting: Consistently order member imports in alerting code (#97688) 5 months ago
rulesSearchParser.ts Alerting: Consistently order member imports in alerting code (#97688) 5 months ago
search.grammar
search.js
search.terms.js
searchParser.ts

README.md

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.