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: development/wasm-filter-plugins.md
+24-16Lines changed: 24 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ There are no additional requirements to execute Wasm plugins.
12
12
13
13
#### Build `flb-wamrc` (optional)
14
14
15
-
`flb-wamrc` is a `flb`-prefixed AOT (ahead of time) compiler that's provided from [`wasm-micro-runtime`](https://github.com/bytecodealliance/wasm-micro-runtime).
15
+
`flb-wamrc` is a `flb`-prefixed Ahead of Time (AOT) compiler that's provided from [`wasm-micro-runtime`](https://github.com/bytecodealliance/wasm-micro-runtime).
16
16
17
17
For `flb-wamrc` support, you must install the LLVM infrastructure and some additional libraries (`libmlir`, `libPolly`, `libedit`, and `libpfm`). For example:
18
18
@@ -22,13 +22,13 @@ For `flb-wamrc` support, you must install the LLVM infrastructure and some addit
22
22
23
23
### For Wasm programs
24
24
25
-
Currently, Fluent Bit supports the following Wasm tool chains:
25
+
Fluent Bit supports the following Wasm tool chains:
26
26
27
-
* Rust on `wasm32-unknown-unknown`
28
-
* rustc 1.62.1 (e092d0b6b 2022-07-16) or later
29
-
*[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
30
-
* v0.24.0 or later
31
-
*[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later.
27
+
- Rust on `wasm32-unknown-unknown`
28
+
- rustc 1.62.1 (`e092d0b6b` 2022-07-16) or later
29
+
-[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
30
+
- v0.24.0 or later
31
+
-[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later.
32
32
33
33
## Get started
34
34
@@ -44,8 +44,13 @@ To support AOT-compiled Wasm execution as filter plugins, build Fluent Bit with
44
44
45
45
Once compiled, you can see new plugins that handle `wasm`, for example:
46
46
47
+
```shell
48
+
bin/fluent-bit -h
49
+
```
50
+
51
+
Which returns results similar to:
52
+
47
53
```text
48
-
$ bin/fluent-bit -h
49
54
Usage: fluent-bit [OPTION]
50
55
Inputs
51
56
# ... other input plugin stuffs
@@ -60,9 +65,9 @@ Filters
60
65
61
66
The Fluent Bit Wasm filter assumes C ABI, also known as `wasm32-unknown-unknown` on Rust target and `wasm32-wasi` on TinyGo target.
62
67
63
-
### To Install Additional Components
68
+
### Install additional components
64
69
65
-
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-unknown-unknown` target, you must install `wasm32-unknown-unknown` by using [rustup](https://rustup.rs/). Then, install the target components as follows:
70
+
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-unknown-unknown` target, you must install `wasm32-unknown-unknown` by using [`rustup`](https://rustup.rs/). Then, install the target components as follows:
66
71
67
72
```text
68
73
rustup target add wasm32-unknown-unknown
@@ -116,7 +121,7 @@ pipeline:
116
121
function_name: super_awesome_filter
117
122
# Note: run Fluent Bit from the 'wasm_path' location.
118
123
accessible_paths: /path/to/fluent-bit
119
-
124
+
120
125
outputs:
121
126
- name: stdout
122
127
match: '*'
@@ -152,7 +157,8 @@ For example, one of the sample [Rust Wasm filters](https://github.com/fluent/flu
Another example of a Rust Wasm filter is the [flb_filter_iis](https://github.com/kenriortega/flb_filter_iis) filter.
160
+
161
+
Another example of a Rust Wasm filter is the [`flb_filter_iis`](https://github.com/kenriortega/flb_filter_iis) filter.
156
162
157
163
This filter takes the [Internet Information Services (IIS)](https://learn.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/configure-logging-in-iis)[w3c logs](https://learn.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/configure-logging-in-iis#select-w3c-fields-to-log) (with some custom modifications) and transforms the raw string into a standard Fluent Bit JSON structured record.
158
164
@@ -172,7 +178,7 @@ pipeline:
172
178
wasm_path: /plugins/flb_filter_iis_wasm.wasm
173
179
function_name: flb_filter_log_iis_w3c_custom
174
180
accessible_paths: .
175
-
181
+
176
182
outputs:
177
183
- name: stdout
178
184
match: 'iis.*'
@@ -213,6 +219,7 @@ The output after the filter logic will be:
213
219
```
214
220
215
221
This filter approach offers several advantages inherent to programming languages. For example:
222
+
216
223
- It can be extended by adding type conversion to fields, such as `sc_bytes`, `cs_bytes`, and `time_taken`. You can use this to validate data results.
217
224
- It allows for the use of conditions to apply more descriptive filters. For example, you can get only all logs that contain status codes higher than `4xx` or `5xx`.
218
225
- It can be used to define allow lists and deny lists using a data structure array or a file to store predefined IP addresses.
@@ -254,6 +261,7 @@ AOT compiling should generate CPU architecture-dependent objects. If you want to
Copy file name to clipboardExpand all lines: development/wasm-input-plugins.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,13 @@ There are no additional requirements to execute Wasm plugins.
12
12
13
13
### For Wasm programs
14
14
15
-
Fluent Bit supports the following Wasm toolchains:
15
+
Fluent Bit supports the following Wasm tool chains:
16
16
17
-
* Rust on `wasm32-unknown-unknown`
18
-
* rustc 1.62.1 (e092d0b6b 2022-07-16) or later
19
-
*[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
20
-
* v0.24.0 or later
21
-
*[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later
17
+
- Rust on `wasm32-unknown-unknown`
18
+
- rustc 1.62.1 (`e092d0b6b` 2022-07-16) or later
19
+
-[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
20
+
- v0.24.0 or later
21
+
-[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later
22
22
23
23
## Get started
24
24
@@ -50,7 +50,7 @@ Wasm input in Fluent Bit assumes WASI ABI, also known as `wasm32-wasi` on Rust t
50
50
51
51
### Install additional components
52
52
53
-
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-wasi` target, you must install `wasm32-wasi` by using [rustup](https://rustup.rs/). Then, install the target components as:
53
+
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-wasi` target, you must install `wasm32-wasi` by using [`rustup`](https://rustup.rs/). Then, install the target components as:
54
54
55
55
```text
56
56
rustup target add wasm32-wasi
@@ -74,10 +74,10 @@ pipeline:
74
74
tag: exec.wasi.local
75
75
wasi_path: /path/to/wasi_built_json.wasm
76
76
# For security reasons, WASM/WASI program cannot access its outer world
77
-
# without accessible permissions. Uncomment below 'accessible_paths' and
77
+
# without accessible permissions. Uncomment below 'accessible_paths' and
78
78
# run Fluent Bit from the 'wasi_path' location:
79
79
# accessible_paths /path/to/fluent-bit
80
-
80
+
81
81
outputs:
82
82
- name: stdout
83
83
match: '*'
@@ -92,7 +92,7 @@ pipeline:
92
92
Tag exec.wasi.local
93
93
WASI_Path /path/to/wasi_built_json.wasm
94
94
# For security reasons, WASM/WASI program cannot access its outer world
95
-
# without accessible permissions. Uncomment below 'accessible_paths' and
95
+
# without accessible permissions. Uncomment below 'accessible_paths' and
96
96
# run Fluent Bit from the 'wasi_path' location:
97
97
# accessible_paths /path/to/fluent-bit
98
98
@@ -104,4 +104,5 @@ pipeline:
104
104
{% endtab %}
105
105
{% endtabs %}
106
106
107
-
For an example that handles structured logs, see the [Rust `serde-json` example](https://github.com/fluent/fluent-bit/tree/master/examples/wasi_serde_json).
107
+
For an example that handles structured logs, see the [Rust `serde-json`
0 commit comments