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
+25-22Lines changed: 25 additions & 22 deletions
Display the source diff
Display the rich diff
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,22 @@ pipeline:
180
176
{% endtab %}
181
177
{% endtabs %}
182
178
183
-
#### Environment variable processing
179
+
### Number Type
180
+
181
+
+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.
182
+
183
+
### Protected Mode
184
+
185
+
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).
186
+
187
+
188
+
## Code Examples
189
+
190
+
For functional examples of this interface, please refer to the code samples provided in the source code of the project located here:
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
197
@@ -197,11 +208,11 @@ We want to extract the `sandboxbsh` name and add it to our record as a special k
197
208
{% tab title="fluent-bit.conf" %}
198
209
```
199
210
[FILTER]
200
-
Name lua
201
-
Alias filter-iots-lua
202
-
Match iots_thread.*
203
-
Script filters.lua
204
-
Call set_landscape_deployment
211
+
Name lua
212
+
Alias filter-iots-lua
213
+
Match iots_thread.*
214
+
Script filters.lua
215
+
Call set_landscape_deployment
205
216
```
206
217
{% endtab %}
207
218
@@ -244,14 +255,6 @@ filters.lua:
244
255
end
245
256
```
246
257
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
258
### Record Split
256
259
257
260
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.
@@ -439,7 +442,6 @@ pipeline:
439
442
440
443
In the output only the messages with response code 0 or greater than 399 are shown.
441
444
442
-
443
445
### Timeformat Conversion
444
446
445
447
The following example converts a field's specific type of `datetime` format to
@@ -568,4 +570,5 @@ The output of this process shows the conversion of the `datetime` of two timezon
0 commit comments