You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pipeline/filters/lua.md
+82-25
Original file line number
Diff line number
Diff line change
@@ -114,13 +114,9 @@ Each callback **must** return three values:
114
114
| timestamp | double | If code equals 1, the original record timestamp will be replaced with this new value. |
115
115
| record | table | If code equals 1, the original record information will be replaced with this new value. Note that the _record_ value **must** be a valid Lua table. This value can be an array of tables (i.e., array of objects in JSON format), and in that case the input record is effectively split into multiple records. (see below for more details) |
116
116
117
-
### Code Examples
117
+
## Features
118
118
119
-
For functional examples of this interface, please refer to the code samples provided in the source code of the project located here:
The [Fluent Bit smoke tests](https://github.com/fluent/fluent-bit/tree/master/packaging/testing/smoke/container) include examples to verify during CI.
126
122
@@ -180,7 +176,25 @@ pipeline:
180
176
{% endtab %}
181
177
{% endtabs %}
182
178
183
-
#### Environment variable processing
179
+
### Number Type
180
+
181
+
Lua treats numbers as a `double` type, which means an `integer` type
182
+
containing data like user IDs and log levels will be converted to a `double`.
183
+
To avoid type conversion, use the `type_int_key` property.
184
+
185
+
### Protected Mode
186
+
187
+
Fluent Bit supports protected mode to prevent crashes if it executes an invalid Lua script.
188
+
See [Error Handling in Application Code](https://www.lua.org/pil/24.3.1.html) in
189
+
the Lua documentation for more information.
190
+
191
+
192
+
## Code Examples
193
+
194
+
For functional examples of this interface, please refer to the code samples provided in the source code of the project located here:
195
+
196
+
197
+
### Processing environment variables
184
198
185
199
As an example that combines a bit of LUA processing with the [Kubernetes filter](./kubernetes.md) that demonstrates using environment variables with LUA regex and substitutions.
186
200
@@ -197,11 +211,11 @@ We want to extract the `sandboxbsh` name and add it to our record as a special k
197
211
{% tab title="fluent-bit.conf" %}
198
212
```
199
213
[FILTER]
200
-
Name lua
201
-
Alias filter-iots-lua
202
-
Match iots_thread.*
203
-
Script filters.lua
204
-
Call set_landscape_deployment
214
+
Name lua
215
+
Alias filter-iots-lua
216
+
Match iots_thread.*
217
+
Script filters.lua
218
+
Call set_landscape_deployment
205
219
```
206
220
{% endtab %}
207
221
@@ -244,14 +258,6 @@ filters.lua:
244
258
end
245
259
```
246
260
247
-
### Number Type
248
-
249
-
+Lua treats number as double. It means an integer field (e.g. IDs, log levels) will be converted double. To avoid type conversion, The `type_int_key` property is available.
250
-
251
-
### Protected Mode
252
-
253
-
Fluent Bit supports protected mode to prevent crash when executes invalid Lua script. See also [Error Handling in Application Code](https://www.lua.org/pil/24.3.1.html).
254
-
255
261
### Record Split
256
262
257
263
The Lua callback function can return an array of tables (i.e., array of records) in its third _record_ return value. With this feature, the Lua filter can split one input record into multiple records according to custom logic.
@@ -331,7 +337,7 @@ See also [Fluent Bit: PR 811](https://github.com/fluent/fluent-bit/pull/811).
331
337
332
338
### Response code filtering
333
339
334
-
In this example, we want to filter istio logs to exclude lines with response codes between 1 and 399.
340
+
In this example, we want to filter Istio logs to exclude lines with response codes between 1 and 399.
335
341
Istio is configured to write the logs in json format.
336
342
337
343
#### Lua script
@@ -353,7 +359,7 @@ end
353
359
354
360
#### Configuration
355
361
356
-
Configuration to get istio logs and apply response code filter to them.
362
+
Configuration to get Istio logs and apply response code filter to them.
357
363
358
364
{% tabs %}
359
365
{% tab title="fluent-bit.conf" %}
@@ -439,8 +445,7 @@ pipeline:
439
445
440
446
In the output only the messages with response code 0 or greater than 399 are shown.
441
447
442
-
443
-
### Timeformat Conversion
448
+
### Time format Conversion
444
449
445
450
The following example converts a field's specific type of `datetime` format to
446
451
`utc ISO 8601` format.
@@ -568,4 +573,56 @@ The output of this process shows the conversion of the `datetime` of two timezon
0 commit comments