WASM Filter Plugins
Last updated
Last updated
is binary instruction format for stack based virtual machine.
Calyptia Core Agent supports integration of wasm plugins built as wasm/wasi objects for input and filter plugins only. The interface for the WASM filter plugins is currently under development but is functional.
flb-wamrc
is just flb-
prefixed AOT (Ahead Of Time) compiler that is provided from .
For flb-wamrc
support, users have to install llvm infrastructure, e.g:
Calyptia Core Agent supports the following WASM toolchains:
Rust on wasm32-unknown-unknown
.
rustc 1.62.1 (e092d0b6b 2022-07-16) or later
on wasm32-wasi
v0.24.0 or later
13 or later.
The Calyptia Core Agent WASM filter assumes C ABI that is also known as wasm32-unknown-unknown
on Rust target and wasm32-wasi
on TinyGo target.
WASM filter plugins execute the function that has the following signagure.
For C:
For Go(TinyGo):
For Rust:
Note that //export XXX
on TinyGo and #[no_mangle]
attributes on Rust are required. This is because TinyGo and Rust will mangle their function names if they are not specified.
Once built, a WASM program will be available. Then, that built program can be executed with the following Calyptia Core Agent configuration:
To optimize WASM program execution, there is the option of using flb-wamrc
. flb-wamrc
will reduce runtime footprint and to be best perforemance for filtering operations. This tool will be built when -DFLB_WAMRC=On
cmake option is specififed and llvm infrastructure is installed on the building box.
For further optimizations to the specific CPU such as Cortex-A57 series:
Then, when AOT (Ahead Of Time) compiling is succeeded:
Note that AOT compiling should generate CPU architecture-dependent objects. If users want to use AOT compiled object on the different archtecture, it must align the target and target cpu for actual environments.
C Filter
https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_c
Rust Filter
https://github.com/fluent/fluent-bit/tree/master/examples/filter_rust
TinyGo Filter
https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_go
TinyGo and WASI SDK support wasm target by default. When using Rust's wasm32-unknown-unknown
target, users must install wasm32-unknown-unknown
by using . Then, installing that target components as:
For example, one of the examples of should generate its filtered logs as follows: