Skip to content

Commit 740e9dc

Browse files
committed
filters: lua: reorganize docs
Signed-off-by: lecaros <[email protected]>
1 parent f5d285d commit 740e9dc

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

pipeline/filters/lua.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,9 @@ Each callback **must** return three values:
114114
| timestamp | double | If code equals 1, the original record timestamp will be replaced with this new value. |
115115
| 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) |
116116

117-
### Code Examples
117+
## Features
118118

119-
For functional examples of this interface, please refer to the code samples provided in the source code of the project located here:
120-
121-
[https://github.com/fluent/fluent-bit/tree/master/scripts](https://github.com/fluent/fluent-bit/tree/master/scripts)
122-
123-
#### Inline configuration
119+
### Inline configuration
124120

125121
The [Fluent Bit smoke tests](https://github.com/fluent/fluent-bit/tree/master/packaging/testing/smoke/container) include examples to verify during CI.
126122

@@ -180,7 +176,22 @@ pipeline:
180176
{% endtab %}
181177
{% endtabs %}
182178

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:
191+
192+
[https://github.com/fluent/fluent-bit/tree/master/scripts](https://github.com/fluent/fluent-bit/tree/master/scripts)
193+
194+
### Processing environment variables
184195

185196
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.
186197

@@ -197,11 +208,11 @@ We want to extract the `sandboxbsh` name and add it to our record as a special k
197208
{% tab title="fluent-bit.conf" %}
198209
```
199210
[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
205216
```
206217
{% endtab %}
207218

@@ -244,14 +255,6 @@ filters.lua:
244255
end
245256
```
246257

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-
255258
### Record Split
256259

257260
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:
439442

440443
In the output only the messages with response code 0 or greater than 399 are shown.
441444

442-
443445
### Timeformat Conversion
444446

445447
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
568570
[0] event_category_a: [[1722452186.727104902, {}], {"event"=>"Restock", "pub_date"=>"2024-07-30T18:01:06Z"}]
569571
[0] event_category_b: [[1722452186.730255842, {}], {"event"=>"Soldout", "pub_date"=>"2024-07-29T04:15:00Z"}]
570572
...
571-
```
573+
```
574+

0 commit comments

Comments
 (0)