Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipelines: filters: parser: Add a nest_under parameter #1543

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions pipeline/filters/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The plugin supports the following configuration parameters:
| Parser | Specify the parser name to interpret the field. Multiple _Parser_ entries are allowed \(one per line\). | |
| Preserve\_Key | Keep original `Key_Name` field in the parsed result. If false, the field will be removed. | False |
| Reserve\_Data | Keep all other original fields in the parsed result. If false, all other original fields will be removed. | False |
| Reserve\_Data | Keep all other original fields in the parsed result. If false, all other original fields will be removed. | False |
RaJiska marked this conversation as resolved.
Show resolved Hide resolved
| Nest\_Under | Specify field name to nest parsed records under. | |
RaJiska marked this conversation as resolved.
Show resolved Hide resolved

## Getting Started

Expand Down Expand Up @@ -156,3 +158,42 @@ Fluent Bit v2.1.1
[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"}]
[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"}]
```

### Nest parsed fields

Instead of expanding parsed fields at the root of the object,
you may choose to have them nested under a new field defined by `Nest_Under`:
RaJiska marked this conversation as resolved.
Show resolved Hide resolved

```python copy
[SERVICE]
Parsers_File /fluent-bit/etc/parsers.conf

[INPUT]
Name Dummy
Dummy {"log":"error: my error","element":"{\"a\":\"b\",\"c\":{\"x\":\"y\"}}"}
Tag dummy.data

[FILTER]
Name parser
Match dummy.*
Parser json
Key_Name element
Nest_Under parsed

[OUTPUT]
Name stdout
Match *
```

Resulting in the following output:
RaJiska marked this conversation as resolved.
Show resolved Hide resolved

```text
$ fluent-bit -c dummy.conf
Fluent Bit v2.1.1
* Copyright (C) 2015-2022 The Fluent Bit Authors
...
...
[0] dummy.data: [[1736759501.208000317, {}], {"parsed"=>{"a"=>"b", "c"=>{"x"=>"y"}}}]
[0] dummy.data: [[1736759502.207935361, {}], {"parsed"=>{"a"=>"b", "c"=>{"x"=>"y"}}}]
[0] dummy.data: [[1736759503.207765898, {}], {"parsed"=>{"a"=>"b", "c"=>{"x"=>"y"}}}]
```