Skip to content

Commit 564dd26

Browse files
committed
Pipeline: filters: grep: update for style
Signed-off-by: Lynette Miles <[email protected]>
1 parent e8c0dd6 commit 564dd26

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

pipeline/filters/grep.md

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
---
2-
description: Select or exclude records using patterns
2+
description: Select or exclude records using regular expressions.
33
---
44

55
# Grep
66

7-
The _Grep Filter_ plugin lets you match or exclude specific records based on
8-
regular expression patterns for values or nested values.
7+
The _Grep_ filter plugin lets you match or exclude specific records based on regular expression patterns for values or nested values.
98

109
## Configuration parameters
1110

1211
The plugin supports the following configuration parameters:
1312

1413
| Key | Value Format | Description |
1514
| ------------ | ------------ | ----------- |
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. |
15+
| `Regex` | `KEY REGEX` | Keep records where the content of `KEY` matches the regular expression. |
16+
| `Exclude` | `KEY REGEX` | Exclude records where the content of `KEY` matches the regular expression. |
17+
| `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. |
1918

2019
### Record Accessor Enabled
2120

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.
21+
Enable the [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md) feature to specify the `KEY`. Use the record accessor to match values against nested values.
2522

2623
## Filter records
2724

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:
25+
To start filtering records, run the filter from the command line or through the configuration file. The following example assumes that you have a file named `lines.txt` with the following content:
3126

3227
```text
3328
{"log": "aaa"}
@@ -42,16 +37,12 @@ configuration file. The following example assumes that you have a file named
4237

4338
### Command line
4439

45-
When using the command line, pay close attention to quote the regular expressions.
46-
Using a configuration file might be easier.
40+
When using the command line, pay close attention to quote the regular expressions. Using a configuration file might be easier.
4741

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
51-
records with a field value starting with `aa`:
42+
The following command loads the [tail](../../pipeline/inputs/tail) plugin and reads the content of `lines.txt`. Then the `grep` filter applies a regular expression rule over the `log` field created by the `tail` plugin and only passes records with a field value starting with `aa`:
5243

53-
```text
54-
$ bin/fluent-bit -i tail -p 'path=lines.txt' -F grep -p 'regex=log aa' -m '*' -o stdout
44+
```shell
45+
bin/fluent-bit -i tail -p 'path=lines.txt' -F grep -p 'regex=log aa' -m '*' -o stdout
5546
```
5647

5748
### Configuration file
@@ -103,15 +94,11 @@ pipeline:
10394
{% endtab %}
10495
{% endtabs %}
10596

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.
97+
The filter lets you use multiple rules which are applied in order. You can have as many `Regex` and `Exclude` entries as required.
10898

10999
### Nested fields example
110100

111-
To match or exclude records based on nested values, you can use
112-
[Record
113-
Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md)
114-
format as the `KEY` name.
101+
To match or exclude records based on nested values, you can use [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md) format as the `KEY` name.
115102

116103
Consider the following record example:
117104

@@ -132,8 +119,7 @@ Consider the following record example:
132119
}
133120
```
134121

135-
For example, to exclude records that match the nested field `kubernetes.labels.app`,
136-
use the following rule:
122+
For example, to exclude records that match the nested field `kubernetes.labels.app`, use the following rule:
137123

138124
{% tabs %}
139125
{% tab title="fluent-bit.conf" %}
@@ -162,15 +148,15 @@ use the following rule:
162148
163149
You might want to drop records that are missing certain keys.
164150
165-
One way to do this is to `exclude` with a regex that matches anything. A missing
151+
One way to do this is to `exclude` with a regular expression that matches anything. A missing
166152
key fails this check.
167153

168-
The followinfg example checks for a specific valid value for the key:
154+
The following example checks for a specific valid value for the key:
169155

170156
{% tabs %}
171157
{% tab title="fluent-bit.conf" %}
172158

173-
```text
159+
```python
174160
# Use Grep to verify the contents of the iot_timestamp value.
175161
# If the iot_timestamp key does not exist, this will fail
176162
# and exclude the row.
@@ -201,7 +187,7 @@ or is missing or empty, then it will be excluded.
201187
### Multiple conditions
202188

203189
If you want to set multiple `Regex` or `Exclude`, use the `Logical_Op` property
204-
to use a logical conjuction or disjunction.
190+
to use a logical conjunction or disjunction.
205191

206192
If `Logical_Op` is set, setting both `Regex` and `Exclude` results in an error.
207193

0 commit comments

Comments
 (0)