0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-22 20:42:33 +00:00
netdata_netdata/libnetdata/simple_pattern
Costa Tsaousis 7b3308390a
SUBSTRING simple patterns fix ()
* when in substring matches, do not expect an asterisk at the end of the pattern

* fix substring matches in simple patterns; allow negative searches in facets
2023-10-24 02:14:56 +03:00
..
Makefile.am Makefile.am files indentation () 2019-11-11 01:30:00 +02:00
README.md fix a typo in libnetdata/simple_pattern/README.md () 2023-06-02 12:27:20 +03:00
simple_pattern.c SUBSTRING simple patterns fix () 2023-10-24 02:14:56 +03:00
simple_pattern.h /api/v2/X improvements part 3 () 2023-03-10 12:41:14 +02:00

Simple patterns

Unix prefers regular expressions. But they are just too hard, too cryptic to use, write and understand.

So, Netdata supports simple patterns.

Simple patterns are a space separated list of words, that can have * as a wildcard. Each word may use any number of *. Simple patterns allow negative matches by prefixing a word with !.

So, pattern = !*bad* * will match anything, except all those that contain the word bad.

Simple patterns are quite powerful: pattern = *foobar* !foo* !*bar * matches everything containing foobar, except strings that start with foo or end with bar.

You can use the Netdata command line to check simple patterns, like this:

# netdata -W simple-pattern '*foobar* !foo* !*bar *' 'hello world'
RESULT: MATCHED - pattern '*foobar* !foo* !*bar *' matches 'hello world'

# netdata -W simple-pattern '*foobar* !foo* !*bar *' 'hello world bar'
RESULT: NOT MATCHED - pattern '*foobar* !foo* !*bar *' does not match 'hello world bar'

# netdata -W simple-pattern '*foobar* !foo* !*bar *' 'hello world foobar'
RESULT: MATCHED - pattern '*foobar* !foo* !*bar *' matches 'hello world foobar'

Netdata stops processing to the first positive or negative match (left to right). If it is not matched by either positive or negative patterns, it is denied at the end.