master
md 37 lines 1.31 KB
Rendered Raw
1 # Simple patterns
2
3 Unix prefers regular expressions. But they are just too hard, too cryptic
4 to use, write and understand.
5
6 So, Netdata supports **simple patterns**.
7
8 Simple patterns are a space separated list of words, that can have `*`
9 as a wildcard. Each word may use any number of `*`. Simple patterns
10 allow **negative** matches by prefixing a word with `!`.
11
12 So, `pattern = !*bad* *` will match anything, except all those that
13 contain the word `bad`.
14
15 Simple patterns are quite powerful: `pattern = *foobar* !foo* !*bar *`
16 matches everything containing `foobar`, except strings that start
17 with `foo` or end with `bar`.
18
19 You can use the Netdata command line to check simple patterns,
20 like this:
21
22 ```sh
23 # netdata -W simple-pattern '*foobar* !foo* !*bar *' 'hello world'
24 RESULT: MATCHED - pattern '*foobar* !foo* !*bar *' matches 'hello world'
25
26 # netdata -W simple-pattern '*foobar* !foo* !*bar *' 'hello world bar'
27 RESULT: NOT MATCHED - pattern '*foobar* !foo* !*bar *' does not match 'hello world bar'
28
29 # netdata -W simple-pattern '*foobar* !foo* !*bar *' 'hello world foobar'
30 RESULT: MATCHED - pattern '*foobar* !foo* !*bar *' matches 'hello world foobar'
31 ```
32
33 Netdata stops processing to the first positive or negative match
34 (left to right). If it is not matched by either positive or negative
35 patterns, it is denied at the end.
36
37