Skip to content

Commit d00a9dd

Browse files
authored
Merge pull request #1456 from fluent/lynettemiles/sc-108045/update-manual-pipeline-parsers-decoders-fluent
docs: decoders: updating decoders page for grammar and style
2 parents b83439e + cd90884 commit d00a9dd

File tree

1 file changed

+40
-30
lines changed

1 file changed

+40
-30
lines changed

pipeline/parsers/decoders.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
# Decoders
22

3-
There are certain cases where the log messages being parsed contains encoded data, a typical use case can be found in containerized environments with Docker: application logs it data in JSON format but becomes an escaped string, Consider the following example
3+
There are cases where the log messages being parsed contain encoded data. A typical
4+
use case can be found in containerized environments with Docker. Docker logs its
5+
data in JSON format, which uses escaped strings.
46

5-
Original message generated by the application:
7+
Consider the following message generated by the application:
68

79
```text
810
{"status": "up and running"}
911
```
1012

11-
Then the Docker log message become encapsulated as follows:
13+
The Docker log message encapsulates something like this:
1214

1315
```text
1416
{"log":"{\"status\": \"up and running\"}\r\n","stream":"stdout","time":"2018-03-09T01:01:44.851160855Z"}
1517
```
1618

17-
as you can see the original message is handled as an escaped string. Ideally in Fluent Bit we would like to keep having the original structured message and not a string.
19+
The original message is handled as an escaped string. Fluent Bit wants to use the
20+
original structured message and not a string.
1821

1922
## Getting Started
2023

21-
Decoders are a built-in feature available through the Parsers file, each Parser definition can optionally set one or multiple decoders. There are two type of decoders type:
24+
Decoders are a built-in feature available through the Parsers file. Each parser
25+
definition can optionally set one or more decoders. There are two types of decoders:
2226

23-
* Decode\_Field: if the content can be decoded in a structured message, append that structure message \(keys and values\) to the original log message.
24-
* Decode\_Field\_As: any content decoded \(unstructured or structured\) will be replaced in the same key/value, no extra keys are added.
27+
- `Decode_Field`: If the content can be decoded in a structured message, append
28+
the structured message (keys and values) to the original log message.
29+
- `Decode_Field_As`: Any decoded content (unstructured or structured) will be
30+
replaced in the same key/value, and no extra keys are added.
2531

26-
Our pre-defined Docker Parser have the following definition:
32+
Our pre-defined Docker parser has the following definition:
2733

2834
```text
2935
[PARSER]
@@ -37,54 +43,59 @@ Our pre-defined Docker Parser have the following definition:
3743
Decode_Field_As escaped log
3844
```
3945

40-
Each line in the parser with a key _Decode\_Field_ instruct the parser to apply a specific decoder on a given field, optionally it offer the option to take an extra action if the decoder cannot succeed.
46+
Each line in the parser with a key `Decode_Field` instructs the parser to apply
47+
a specific decoder on a given field. Optionally, it offers the option to take an
48+
extra action if the decoder doesn't succeed.
4149

42-
### Decoders
50+
### Decoder options
4351

44-
| Name | Description |
45-
| :--- | :--- |
46-
| json | handle the field content as a JSON map. If it find a JSON map it will replace the content with a structured map. |
47-
| escaped | decode an escaped string. |
48-
| escaped\_utf8 | decode a UTF8 escaped string. |
52+
| Name | Description |
53+
| -------------- | ----------- |
54+
| `json` | Handle the field content as a JSON map. If it finds a JSON map, it replaces the content with a structured map. |
55+
| `escaped` | Decode an escaped string. |
56+
| `escaped_utf8` | Decode a UTF8 escaped string. |
4957

5058
### Optional Actions
5159

52-
By default if a decoder fails to decode the field or want to try a next decoder, is possible to define an optional action. Available actions are:
60+
If a decoder fails to decode the field or, you want to try another decoder, you can
61+
define an optional action. Available actions are:
5362

5463
| Name | Description |
55-
| :--- | :--- |
56-
| try\_next | if the decoder failed, apply the next Decoder in the list for the same field. |
57-
| do\_next | if the decoder succeeded or failed, apply the next Decoder in the list for the same field. |
64+
| -----| ----------- |
65+
| `try_next` | if the decoder failed, apply the next decoder in the list for the same field. |
66+
| `do_next` | if the decoder succeeded or failed, apply the next decoder in the list for the same field. |
5867

59-
Note that actions are affected by some restrictions:
68+
Actions are affected by some restrictions:
6069

61-
* on Decode\_Field\_As, if succeeded, another decoder of the same type in the same field can be applied only if the data continues being an unstructured message \(raw text\).
62-
* on Decode\_Field, if succeeded, can only be applied once for the same field. By nature Decode\_Field aims to decode a structured message.
70+
- `Decode_Field_As`: If successful, another decoder of the same type and the same
71+
field can be applied only if the data continues being an unstructured message (raw text).
72+
- `Decode_Field`: If successful, can only be applied once for the same field.
73+
`Decode`_Field` is intended to decode a structured message.
6374

6475
### Examples
6576

66-
### escaped\_utf8
77+
#### `escaped_utf8`
6778

68-
Example input \(from `/path/to/log.log` in configuration below\)
79+
Example input from `/path/to/log.log`:
6980

7081
```text
7182
{"log":"\u0009Checking indexes...\n","stream":"stdout","time":"2018-02-19T23:25:29.1845444Z"}
7283
{"log":"\u0009\u0009Validated: _audit _internal _introspection _telemetry _thefishbucket history main snmp_data summary\n","stream":"stdout","time":"2018-02-19T23:25:29.1845536Z"}
7384
{"log":"\u0009Done\n","stream":"stdout","time":"2018-02-19T23:25:29.1845622Z"}
7485
```
7586

76-
Example output
87+
Example output:
7788

7889
```text
79-
[24] tail.0: [1519082729.184544400, {"log"=>" Checking indexes...
90+
[24] tail.0: [1519082729.184544400, {"log"=>" Checking indexes...
8091
", "stream"=>"stdout", "time"=>"2018-02-19T23:25:29.1845444Z"}]
8192
[25] tail.0: [1519082729.184553600, {"log"=>" Validated: _audit _internal _introspection _telemetry _thefishbucket history main snmp_data summary
8293
", "stream"=>"stdout", "time"=>"2018-02-19T23:25:29.1845536Z"}]
83-
[26] tail.0: [1519082729.184562200, {"log"=>" Done
94+
[26] tail.0: [1519082729.184562200, {"log"=>" Done
8495
", "stream"=>"stdout", "time"=>"2018-02-19T23:25:29.1845622Z"}]
8596
```
8697

87-
Configuration file
98+
Decoder configuration file:
8899

89100
```text
90101
[SERVICE]
@@ -100,7 +111,7 @@ Configuration file
100111
Match *
101112
```
102113

103-
The `fluent-bit-parsers.conf` file,
114+
The `fluent-bit-parsers.conf` file:
104115

105116
```text
106117
[PARSER]
@@ -110,4 +121,3 @@ The `fluent-bit-parsers.conf` file,
110121
Time_Format %Y-%m-%dT%H:%M:%S %z
111122
Decode_Field_as escaped_utf8 log
112123
```
113-

0 commit comments

Comments
 (0)