diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:08:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:08:18 +0000 |
commit | 5da14042f70711ea5cf66e034699730335462f66 (patch) | |
tree | 0f6354ccac934ed87a2d555f45be4c831cf92f4a /src/fluent-bit/examples/filter_rust_clib/README.md | |
parent | Releasing debian version 1.44.3-2. (diff) | |
download | netdata-5da14042f70711ea5cf66e034699730335462f66.tar.xz netdata-5da14042f70711ea5cf66e034699730335462f66.zip |
Merging upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/fluent-bit/examples/filter_rust_clib/README.md')
-rw-r--r-- | src/fluent-bit/examples/filter_rust_clib/README.md | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/fluent-bit/examples/filter_rust_clib/README.md b/src/fluent-bit/examples/filter_rust_clib/README.md new file mode 100644 index 000000000..9be89598b --- /dev/null +++ b/src/fluent-bit/examples/filter_rust_clib/README.md @@ -0,0 +1,77 @@ +# Fluent Bit / filter_rust_clib + +This source source tree provides an example of WASM program with WASI mode mainly written in Rust. + +## Prerequisites + +* Rust + * rustc 1.61.0 (fe5b13d68 2022-05-18) +* [rustup](https://rustup.rs/) (For preparing rust compiler and toolchains) +* [cbindgen](https://github.com/eqrion/cbindgen) (For preparing C headers to include exported Rust's c style function(s)) +* [WASI SDK](https://github.com/WebAssembly/wasi-sdk) + +For Ubuntu, it's easy to install with: + +```console +$ export WASI_VERSION=14 +$ export WASI_VERSION_FULL=${WASI_VERSION}.0 +$ wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz +$ sudo mkdir -p /opt/wasi-sdk/ +$ sudo tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz --strip-components=1 -C /opt/wasi-sdk +``` + +## How to build + +Add `wasm32-unknown-unknown` target for Rust toolchain: + +```console +$ rustup target add wasm32-unknown-unknown +``` + +Install `cbindgen` command as follows: + +```console +$ cargo install --force cbindgen +``` + +Then, execute _make build_ as follows: + +```console +$ make build +``` + +Finally, `*.wasm` file will be created: + +```console +$ ls *.wasm +rust_clib_filter.wasm +``` + +## How to confirm WASI integration + +Create fluent-bit configuration file as follows: + +```ini +[SERVICE] + Flush 1 + Daemon Off + Log_Level info + HTTP_Server Off + HTTP_Listen 0.0.0.0 + HTTP_Port 2020 + +[INPUT] + Name dummy + Tag dummy.local + +[FILTER] + Name wasm + match dummy.* + WASM_Path /path/to/rust_clib_filter.wasm + Function_Name rust_clib_filter + accessible_paths .,/path/to/fluent-bit + +[OUTPUT] + Name stdout + Match * +``` |