Filebeat正则表达式的支持是基于RE2的,本文译自 elastic。
Filebeat有几个接受正则表达式的配置选项。例如multiline.pattern
, include_lines
,exclude_lines
,和 exclude_files
所有接受正则表达式。
注意:建议正则放在单引号内,例如'^\[?[0-9][0-9]:?[0-9][0-9]|^[[:graph:]]+'
。
样例 | 描述 |
---|---|
单个字符 |
|
| 单个字符 |
| 任何字符 |
| 字符类 |
| 非字符类 |
| ASCII字符类 |
| 非ASCII字符类 |
| Perl字符类 |
| 非Perl字符类 |
| Unicode字符类(一个字母的名称) |
| Unicode字符类 |
| 非Unicode字符类(一个字母的名称) |
| 非Unicode字符类 |
复合类型 |
|
| 且 |
| 或 |
重复类型 |
|
| 以x开头 |
| 一个或者多个x |
| 零或一个x |
|
|
|
|
| exactly |
| zero or more |
| one or more |
| zero or one |
|
|
|
|
| exactly |
分组 |
|
| numbered capturing group (submatch) |
| named & numbered capturing group (submatch) |
| non-capturing group |
| set flags within current group, non-capturing |
| set flags during re, non-capturing |
| case-insensitive (default false) |
| multi-line mode: |
| let |
| ungreedy: swap meaning of |
空字符串 |
|
| at beginning of text or line ( |
| at end of text (like |
| at beginning of text |
| at ASCII word boundary ( |
| not at ASCII word boundary |
| at end of text |
转义序列 |
|
| bell (same as |
| form feed (same as |
| horizontal tab (same as |
| newline (same as |
| carriage return (same as |
| vertical tab character (same as |
| literal |
| octal character code (up to three digits) |
| two-digit hex character code |
| hex character code |
| literal text |
ASCII字符类 |
|
| alphanumeric (same as |
| alphabetic (same as |
| ASCII (same as |
| blank (same as |
| control (same as |
| digits (same as |
| graphical (same as |
| lower case (same as |
| printable (same as |
| punctuation (same as |
| whitespace (same as |
| upper case (same as |
| word characters (same as |
| hex digit (same as |
支持Perl字符类 |
|
| digits (same as |
| not digits (same as |
| whitespace (same as |
| not whitespace (same as |
| word characters (same as |
| not word characters (same as |
实际使用整理,待续...