Skip to content

Commit c721db4

Browse files
Merge pull request #1543 from RaJiska/filter-parser-nest-under
2 parents 10f7763 + cf0a08a commit c721db4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

pipeline/filters/parser.md

+40
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The plugin supports the following configuration parameters:
1212
| Parser | Specify the parser name to interpret the field. Multiple _Parser_ entries are allowed \(one per line\). | |
1313
| Preserve\_Key | Keep original `Key_Name` field in the parsed result. If false, the field will be removed. | False |
1414
| Reserve\_Data | Keep all other original fields in the parsed result. If false, all other original fields will be removed. | False |
15+
| Nest\_Under | Specify the name of the field to nest parsed records under. | |
1516

1617
## Getting Started
1718

@@ -156,3 +157,42 @@ Fluent Bit v2.1.1
156157
[0] dummy.data: [[1687122779.296906553, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "data"=>"100 0.5 true This is example", "key1"=>"value1", "key2"=>"value2"}]
157158
[0] dummy.data: [[1687122780.297475803, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "data"=>"100 0.5 true This is example", "key1"=>"value1", "key2"=>"value2"}]
158159
```
160+
161+
### Nest parsed fields
162+
163+
Instead of expanding parsed fields at the root of the object,
164+
you can nest them under a new field defined by `Nest_Under`:
165+
166+
```python copy
167+
[SERVICE]
168+
Parsers_File /fluent-bit/etc/parsers.conf
169+
170+
[INPUT]
171+
Name Dummy
172+
Dummy {"log":"error: my error","element":"{\"a\":\"b\",\"c\":{\"x\":\"y\"}}"}
173+
Tag dummy.data
174+
175+
[FILTER]
176+
Name parser
177+
Match dummy.*
178+
Parser json
179+
Key_Name element
180+
Nest_Under parsed
181+
182+
[OUTPUT]
183+
Name stdout
184+
Match *
185+
```
186+
187+
This configuration results in the following output:
188+
189+
```text
190+
$ fluent-bit -c dummy.conf
191+
Fluent Bit v2.1.1
192+
* Copyright (C) 2015-2022 The Fluent Bit Authors
193+
...
194+
...
195+
[0] dummy.data: [[1736759501.208000317, {}], {"parsed"=>{"a"=>"b", "c"=>{"x"=>"y"}}}]
196+
[0] dummy.data: [[1736759502.207935361, {}], {"parsed"=>{"a"=>"b", "c"=>{"x"=>"y"}}}]
197+
[0] dummy.data: [[1736759503.207765898, {}], {"parsed"=>{"a"=>"b", "c"=>{"x"=>"y"}}}]
198+
```

0 commit comments

Comments
 (0)