You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pipeline/filters/grep.md
+66-34Lines changed: 66 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,33 @@
1
1
---
2
-
description: Select or exclude records per patterns
2
+
description: Select or exclude records using patterns
3
3
---
4
4
5
5
# Grep
6
6
7
-
The _Grep Filter_ plugin allows you to match or exclude specific records based on regular expression patterns for values or nested values.
7
+
The _Grep Filter_ plugin lets you match or exclude specific records based on
8
+
regular expression patterns for values or nested values.
8
9
9
-
## Configuration Parameters
10
+
## Configuration parameters
10
11
11
12
The plugin supports the following configuration parameters:
12
13
13
-
| Key | Value Format | Description |
14
-
|:--- |:--- |:--- |
15
-
| Regex| KEY REGEX | Keep records in which the content of KEY matches the regular expression. |
16
-
| Exclude| KEY REGEX | Exclude records in which the content of KEY matches the regular expression. |
17
-
| Logical_Op| Operation | Specify which logical operator to use. `AND`, `OR`and`legacy`are allowed as an Operation. Default is `legacy` for backward compatibility. In `legacy` mode the behaviour is either AND or OR depending whether the `grep` is including (uses AND) or excluding (uses OR). Only available from 2.1+. |
14
+
| Key | Value Format | Description |
15
+
| ------------| ------------|----------- |
16
+
|`Regex`| KEY REGEX | Keep records where the content of KEY matches the regular expression. |
17
+
|`Exclude`| KEY REGEX | Exclude records where the content of KEY matches the regular expression. |
18
+
|`Logical_Op`| Operation | Specify a logical operator: `AND`, `OR`or`legacy`(default). In `legacy` mode the behaviour is either `AND` or `OR` depending on whether the `grep` is including (uses AND) or excluding (uses OR). Available from 2.1 or higher. |
18
19
19
-
####Record Accessor Enabled
20
+
### Record Accessor Enabled
20
21
21
-
This plugin enables the [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md) feature to specify the KEY. Using the _record accessor_ is suggested if you want to match values against nested values.
22
+
Enable the [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md)
23
+
feature to specify the KEY. Use the record accessor to match values against nested
24
+
values.
22
25
23
-
## Getting Started
26
+
## Filter records
24
27
25
-
In order to start filtering records, you can run the filter from the command line or through the configuration file. The following example assumes that you have a file called `lines.txt` with the following content:
28
+
To start filtering records, run the filter from the command line or through the
29
+
configuration file. The following example assumes that you have a file named
30
+
`lines.txt` with the following content:
26
31
27
32
```text
28
33
{"log": "aaa"}
@@ -35,20 +40,25 @@ In order to start filtering records, you can run the filter from the command lin
35
40
{"log": "ggg"}
36
41
```
37
42
38
-
### Command Line
43
+
### Command line
39
44
40
-
> Note: using the command line mode need special attention to quote the regular expressions properly. It's suggested to use a configuration file.
45
+
When using the command line, pay close attention to quote the regular expressions.
46
+
Using a configuration file might be easier.
41
47
42
-
The following command will load the _tail_ plugin and read the content of `lines.txt` file. Then the _grep_ filter will apply a regular expression rule over the _log_ field \(created by tail plugin\) and only _pass_ the records which field value starts with _aa_:
48
+
The following command loads the [tail](../../pipeline/inputs/tail) plugin and
49
+
reads the content of `lines.txt`. Then the `grep` filter applies a regular
50
+
expression rule over the `log` field created by the `tail` plugin and only passes
The filter allows to use multiple rules which are applied in order, you can have many _Regex_ and _Exclude_ entries as required.
106
+
The filter lets you use multiple rules which are applied in order. You can
107
+
have as many `Regex` and `Exclude` entries as required.
94
108
95
109
### Nested fields example
96
110
97
-
If you want to match or exclude records based on nested values, you can use a [Record Accessor ](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md)format as the KEY name. Consider the following record example:
111
+
To match or exclude records based on nested values, you can use
0 commit comments