@@ -21,16 +21,61 @@ The plugin needs a parser file which defines how to parse each field.
21
21
22
22
This is an example of parsing a record ` {"data":"100 0.5 true This is example"} ` .
23
23
24
- ``` python
24
+ {% tabs %}
25
+ {% tab title="fluent-bit.yaml" %}
26
+
27
+ ``` yaml
28
+ parsers :
29
+ - name : dummy_test
30
+ format : regex
31
+ regex : ' ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$'
32
+ ` ` `
33
+
34
+ {% endtab %}
35
+
36
+ {% tab title="fluent-bit.conf" %}
37
+
38
+ ` ` ` text
25
39
[PARSER]
26
40
Name dummy_test
27
41
Format regex
28
42
Regex ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$
29
43
```
30
44
45
+ {% endtab %}
46
+ {% endtabs %}
47
+
31
48
The path of the parser file should be written in configuration file under the ` [SERVICE] ` section.
32
49
33
- ``` python
50
+ {% tabs %}
51
+ {% tab title="fluent-bit.yaml" %}
52
+
53
+ ``` yaml
54
+ service :
55
+ parsers_file : /path/to/parsers.yaml
56
+
57
+ pipeline :
58
+ inputs :
59
+ - name : dummy
60
+ tag : dummy.data
61
+ dummy : ' {"data":"100 0.5 true This is example"}'
62
+
63
+ filters :
64
+ - name : parser
65
+ match : ' dummy.*'
66
+ key_name : data
67
+ parser : dummy_test
68
+
69
+ outputs :
70
+ - name : stdout
71
+ match : ' *'
72
+ ` ` `
73
+
74
+ {% endtab %}
75
+
76
+ {% tab title="fluent-bit.conf" %}
77
+
78
+ ` ` ` text
34
79
[SERVICE]
35
80
Parsers_File /path/to/parsers.conf
36
81
@@ -50,21 +95,42 @@ The path of the parser file should be written in configuration file under the `[
50
95
Match *
51
96
```
52
97
53
- The output is
98
+ {% endtab %}
99
+ {% endtabs %}
100
+
101
+ The output when running the corresponding configuration is as follows:
54
102
55
103
``` text
56
- $ fluent-bit -c dummy.conf
57
- Fluent Bit v1.x.x
58
- * Copyright (C) 2019-2020 The Fluent Bit Authors
59
- * Copyright (C) 2015-2018 Treasure Data
104
+ # For YAML configuration.
105
+ $ ./fluent-bit --config fluent-bit.yaml
106
+
107
+ # For classic configuration.
108
+ $ ./fluent-bit --config fluent-bit.conf
109
+
110
+ Fluent Bit v4.0.0
111
+ * Copyright (C) 2015-2025 The Fluent Bit Authors
60
112
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
61
113
* https://fluentbit.io
62
-
63
- [2017/07/06 22:33:12] [ info] [engine] started
64
- [0] dummy.data: [1499347993.001371317, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
65
- [1] dummy.data: [1499347994.001303118, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
66
- [2] dummy.data: [1499347995.001296133, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
67
- [3] dummy.data: [1499347996.001320284, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
114
+ ______ _ _ ______ _ _ ___ _____
115
+ | ___| | | | | ___ (_) | / || _ |
116
+ | |_ | |_ _ ___ _ __ | |_ | |_/ /_| |_ __ __/ /| || |/' |
117
+ | _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / / /_| || /| |
118
+ | | | | |_| | __/ | | | |_ | |_/ / | |_ \ V /\___ |\ |_/ /
119
+ \_| |_|\__,_|\___|_| |_|\__| \____/|_|\__| \_/ |_(_)___/
120
+
121
+ [2025/06/19 10:58:47] [ info] [fluent bit] version=4.0.0, commit=3a91b155d6, pid=76206
122
+ [2025/06/19 10:58:47] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
123
+ [2025/06/19 10:58:47] [ info] [simd ] disabled
124
+ [2025/06/19 10:58:47] [ info] [cmetrics] version=0.9.9
125
+ [2025/06/19 10:58:47] [ info] [ctraces ] version=0.6.2
126
+ [2025/06/19 10:58:47] [ info] [input:dummy:dummy.0] initializing
127
+ [2025/06/19 10:58:47] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
128
+ [2025/06/19 10:58:47] [ info] [output:stdout:stdout.0] worker #0 started
129
+ [2025/06/19 10:58:47] [ info] [sp] stream processor started
130
+ [0] dummy.data: [[1750323528.603308000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
131
+ [0] dummy.data: [[1750323529.603788000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
132
+ [0] dummy.data: [[1750323530.604204000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
133
+ [0] dummy.data: [[1750323531.603961000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}]
68
134
```
69
135
70
136
You can see the records ` {"data":"100 0.5 true This is example"} ` are parsed.
@@ -73,16 +139,65 @@ You can see the records `{"data":"100 0.5 true This is example"}` are parsed.
73
139
74
140
By default, the parser plugin only keeps the parsed fields in its output.
75
141
76
- If you enable ` Reserve_Data ` , all other fields are preserved:
142
+ If you enable ` Reserve_Data ` , all other fields are preserved. First the contents of the corresponding parsers file,
143
+ depending on the choice for YAML or classic configurations, would be as follows:
144
+
145
+ {% tabs %}
146
+ {% tab title="parsers.yaml" %}
147
+
148
+ ``` yaml
149
+ parsers :
150
+ - name : dummy_test
151
+ format : regex
152
+ regex : ' ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$'
153
+ ` ` `
77
154
78
- ``` python
155
+ {% endtab %}
156
+
157
+ {% tab title="parsers.conf" %}
158
+
159
+ ` ` ` text
79
160
[PARSER]
80
161
Name dummy_test
81
162
Format regex
82
163
Regex ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$
83
164
```
84
165
85
- ``` python
166
+ {% endtab %}
167
+ {% endtabs %}
168
+
169
+ Now add ` Reserve_Data ` to the filter section of the corresponding configuration file as follows:
170
+
171
+ {% tabs %}
172
+ {% tab title="fluent-bit.yaml" %}
173
+
174
+ ``` yaml
175
+ service :
176
+ parsers_file : /path/to/parsers.yaml
177
+
178
+ pipeline :
179
+ inputs :
180
+ - name : dummy
181
+ tag : dummy.data
182
+ dummy : ' {"data":"100 0.5 true This is example", "key1":"value1", "key2":"value2"}'
183
+
184
+ filters :
185
+ - name : parser
186
+ match : ' dummy.*'
187
+ key_name : data
188
+ parser : dummy_test
189
+ reserve_data : on
190
+
191
+ outputs :
192
+ - name : stdout
193
+ match : ' *'
194
+ ` ` `
195
+
196
+ {% endtab %}
197
+
198
+ {% tab title="fluent-bit.conf" %}
199
+
200
+ ` ` ` text
86
201
[SERVICE]
87
202
Parsers_File /path/to/parsers.conf
88
203
@@ -97,32 +212,109 @@ If you enable `Reserve_Data`, all other fields are preserved:
97
212
Key_Name data
98
213
Parser dummy_test
99
214
Reserve_Data On
215
+
216
+ [OUTPUT]
217
+ Name stdout
218
+ Match *
100
219
```
101
220
102
- This will produce the output:
221
+ {% endtab %}
222
+ {% endtabs %}
223
+
224
+ The output when running the corresponding configuration is as follows:
103
225
104
226
``` text
105
- $ fluent-bit -c dummy.conf
106
- Fluent-Bit v0.12.0
107
- Copyright (C) Treasure Data
108
-
109
- [2017/07/06 22:33:12] [ info] [engine] started
110
- [0] dummy.data: [1499347993.001371317, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}, "key1":"value1", "key2":"value2"]
111
- [1] dummy.data: [1499347994.001303118, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}, "key1":"value1", "key2":"value2"]
112
- [2] dummy.data: [1499347995.001296133, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}, "key1":"value1", "key2":"value2"]
113
- [3] dummy.data: [1499347996.001320284, {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example"}, "key1":"value1", "key2":"value2"]
227
+ # For YAML configuration.
228
+ $ ./fluent-bit --config fluent-bit.yaml
229
+
230
+ # For classic configuration.
231
+ $ ./fluent-bit --config fluent-bit.conf
232
+
233
+ Fluent Bit v4.0.0
234
+ * Copyright (C) 2015-2025 The Fluent Bit Authors
235
+ * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
236
+ * https://fluentbit.io
237
+ ______ _ _ ______ _ _ ___ _____
238
+ | ___| | | | | ___ (_) | / || _ |
239
+ | |_ | |_ _ ___ _ __ | |_ | |_/ /_| |_ __ __/ /| || |/' |
240
+ | _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / / /_| || /| |
241
+ | | | | |_| | __/ | | | |_ | |_/ / | |_ \ V /\___ |\ |_/ /
242
+ \_| |_|\__,_|\___|_| |_|\__| \____/|_|\__| \_/ |_(_)___/
243
+
244
+ [2025/06/19 10:58:47] [ info] [fluent bit] version=4.0.0, commit=3a91b155d6, pid=76206
245
+ [2025/06/19 10:58:47] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
246
+ [2025/06/19 10:58:47] [ info] [simd ] disabled
247
+ [2025/06/19 10:58:47] [ info] [cmetrics] version=0.9.9
248
+ [2025/06/19 10:58:47] [ info] [ctraces ] version=0.6.2
249
+ [2025/06/19 10:58:47] [ info] [input:dummy:dummy.0] initializing
250
+ [2025/06/19 10:58:47] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
251
+ [2025/06/19 10:58:47] [ info] [output:stdout:stdout.0] worker #0 started
252
+ [2025/06/19 10:58:47] [ info] [sp] stream processor started
253
+ [0] dummy.data: [[1750325238.681398000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "key1"=>"value1", "key2"=>"value2"}]
254
+ [0] dummy.data: [[1750325239.682090000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "key1"=>"value1", "key2"=>"value2"}]
255
+ [0] dummy.data: [[1750325240.682903000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "key1"=>"value1", "key2"=>"value2"}]
114
256
```
115
257
116
- If you enable ` Reserved_Data ` and ` Preserve_Key ` , the original key field will also be preserved:
258
+ If you enable ` Reserve_Data ` and ` Preserve_Key ` , the original key field will also be preserved. First the contents of
259
+ the corresponding parsers file, depending on the choice for YAML or classic configurations, would be as follows:
117
260
118
- ``` python
261
+ {% tabs %}
262
+ {% tab title="parsers.yaml" %}
263
+
264
+ ``` yaml
265
+ parsers :
266
+ - name : dummy_test
267
+ format : regex
268
+ regex : ' ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$'
269
+ ` ` `
270
+
271
+ {% endtab %}
272
+
273
+ {% tab title="parsers.conf" %}
274
+
275
+ ` ` ` text
119
276
[PARSER]
120
277
Name dummy_test
121
278
Format regex
122
279
Regex ^(?<INT>[^ ]+) (?<FLOAT>[^ ]+) (?<BOOL>[^ ]+) (?<STRING>.+)$
123
280
```
124
281
125
- ``` python
282
+ {% endtab %}
283
+ {% endtabs %}
284
+
285
+ Now add ` Reserve_Data ` and ` Preserve_Key ` to the filter section of the corresponding configuration file as follows:
286
+
287
+ {% tabs %}
288
+ {% tab title="fluent-bit.yaml" %}
289
+
290
+ ``` yaml
291
+ service :
292
+ parsers_file : /path/to/parsers.yaml
293
+
294
+ pipeline :
295
+ inputs :
296
+ - name : dummy
297
+ tag : dummy.data
298
+ dummy : ' {"data":"100 0.5 true This is example", "key1":"value1", "key2":"value2"}'
299
+
300
+ filters :
301
+ - name : parser
302
+ match : ' dummy.*'
303
+ key_name : data
304
+ parser : dummy_test
305
+ reserve_data : on
306
+ preserve_key : on
307
+
308
+ outputs :
309
+ - name : stdout
310
+ match : ' *'
311
+ ` ` `
312
+
313
+ {% endtab %}
314
+
315
+ {% tab title="fluent-bit.conf" %}
316
+
317
+ ` ` ` text
126
318
[SERVICE]
127
319
Parsers_File /path/to/parsers.conf
128
320
@@ -138,21 +330,45 @@ If you enable `Reserved_Data` and `Preserve_Key`, the original key field will al
138
330
Parser dummy_test
139
331
Reserve_Data On
140
332
Preserve_Key On
141
-
142
- [OUTPUT ]
333
+
334
+ [OUTPUT]
143
335
Name stdout
144
336
Match *
145
337
```
146
338
147
- This will produce the following output:
339
+ {% endtab %}
340
+ {% endtabs %}
341
+
342
+ The output when running the corresponding configuration is as follows:
148
343
149
344
``` text
150
- $ fluent-bit -c dummy.conf
151
- Fluent Bit v2.1.1
152
- * Copyright (C) 2015-2022 The Fluent Bit Authors
153
- ...
154
- ...
155
- [0] dummy.data: [[1687122778.299116136, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "data"=>"100 0.5 true This is example", "key1"=>"value1", "key2"=>"value2"}]
156
- [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"}]
157
- [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"}]
158
- ```
345
+ # For YAML configuration.
346
+ $ ./fluent-bit --config fluent-bit.yaml
347
+
348
+ # For classic configuration.
349
+ $ ./fluent-bit --config fluent-bit.conf
350
+
351
+ Fluent Bit v4.0.0
352
+ * Copyright (C) 2015-2025 The Fluent Bit Authors
353
+ * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
354
+ * https://fluentbit.io
355
+ ______ _ _ ______ _ _ ___ _____
356
+ | ___| | | | | ___ (_) | / || _ |
357
+ | |_ | |_ _ ___ _ __ | |_ | |_/ /_| |_ __ __/ /| || |/' |
358
+ | _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / / /_| || /| |
359
+ | | | | |_| | __/ | | | |_ | |_/ / | |_ \ V /\___ |\ |_/ /
360
+ \_| |_|\__,_|\___|_| |_|\__| \____/|_|\__| \_/ |_(_)___/
361
+
362
+ [2025/06/19 10:58:47] [ info] [fluent bit] version=4.0.0, commit=3a91b155d6, pid=76206
363
+ [2025/06/19 10:58:47] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
364
+ [2025/06/19 10:58:47] [ info] [simd ] disabled
365
+ [2025/06/19 10:58:47] [ info] [cmetrics] version=0.9.9
366
+ [2025/06/19 10:58:47] [ info] [ctraces ] version=0.6.2
367
+ [2025/06/19 10:58:47] [ info] [input:dummy:dummy.0] initializing
368
+ [2025/06/19 10:58:47] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
369
+ [2025/06/19 10:58:47] [ info] [output:stdout:stdout.0] worker #0 started
370
+ [2025/06/19 10:58:47] [ info] [sp] stream processor started
371
+ [0] dummy.data: [[1750325678.572817000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "data"=>"100 0.5 true This is example", "key1"=>"value1", "key2"=>"value2"}]
372
+ [0] dummy.data: [[1750325679.574538000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "data"=>"100 0.5 true This is example", "key1"=>"value1", "key2"=>"value2"}]
373
+ [0] dummy.data: [[1750325680.569750000, {}], {"INT"=>"100", "FLOAT"=>"0.5", "BOOL"=>"true", "STRING"=>"This is example", "data"=>"100 0.5 true This is example", "key1"=>"value1", "key2"=>"value2"}]
374
+ ```
0 commit comments