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
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@ The plugin supports the following configuration parameters:
19
19
| type\_array\_key| If these keys are matched, the fields are handled as array. If more than one key, delimit by space. It is useful the array can be empty. |
20
20
| protected\_mode | If enabled, Lua script will be executed in protected mode. It prevents Fluent Bit from crashing when invalid Lua script is executed or the triggered Lua function throws exceptions. Default is true. |
21
21
| time\_as\_table | By default when the Lua script is invoked, the record timestamp is passed as a *floating number* which might lead to precision loss when it is converted back. If you desire timestamp precision, enabling this option will pass the timestamp as a Lua table with keys `sec` for seconds since epoch and `nsec` for nanoseconds. |
22
+
| code | Inline LUA code instead of loading from a path via `script`. |
22
23
23
24
## Getting Started <aid="getting_started"></a>
24
25
@@ -95,6 +96,62 @@ For functional examples of this interface, please refer to the code samples prov
The [Fluent Bit smoke tests](https://github.com/fluent/fluent-bit/tree/master/packaging/testing/smoke/container) include examples to verify during CI.
102
+
103
+
```yaml
104
+
service:
105
+
flush: 1
106
+
daemon: off
107
+
log_level: info
108
+
109
+
pipeline:
110
+
inputs:
111
+
- random:
112
+
tag: test
113
+
samples: 10
114
+
115
+
filters:
116
+
- lua:
117
+
match: "*"
118
+
call: append_tag
119
+
code: |
120
+
function append_tag(tag, timestamp, record)
121
+
new_record = record
122
+
new_record["tag"] = tag
123
+
return 1, timestamp, new_record
124
+
end
125
+
126
+
outputs:
127
+
- stdout:
128
+
match: "*"
129
+
```
130
+
131
+
In classic mode:
132
+
133
+
```
134
+
[SERVICE]
135
+
flush 1
136
+
daemon off
137
+
log_level debug
138
+
139
+
[INPUT]
140
+
Name random
141
+
Tag test
142
+
Samples 10
143
+
144
+
[FILTER]
145
+
Name Lua
146
+
Match *
147
+
call append_tag
148
+
code function append_tag(tag, timestamp, record) new_record = record new_record["tag"] = tag return 1, timestamp, new_record end
149
+
150
+
[OUTPUT]
151
+
Name stdout
152
+
Match *
153
+
```
154
+
98
155
#### Environment variable processing
99
156
100
157
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.
0 commit comments