summaryrefslogtreecommitdiffstats
path: root/fluent-bit/examples/wasi_serde_json/README.md
blob: 9df44189d10938ca1532cf876a29a3358bad2fde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Fluent Bit / wasi_serde_json

This source source tree provides an example of WASM program with WASI mode.

## Prerequisites

* Rust
  * rustc 1.61.0 (fe5b13d68 2022-05-18)
* [rustup](https://rustup.rs/) (For preparing rust compiler and toolchains)

## How to build

Add `wasm32-wasi` target for Rust toolchain:

```console
$ rustup target add wasm32-wasi
```

Then, execute _cargo build_ as follows:

```console
$ cargo build --target wasm32-wasi --release
```

Finally, under target/wasm32-wasi/release directory, `*.wasm` file will be created:

```console
$ ls target/wasm32-wasi/release/*.wasm
target/wasm32-wasi/release/wasi_serde_json.wasm
```

## How to confirm WASI integration

Create parsers.conf as follows:

```ini
[PARSER]
    Name        wasi
    Format      json
    Time_Key    time
    Time_Format %Y-%m-%dT%H:%M:%S.%L %z
```

And Create fluent-bit configuration file as follows:

```ini
[SERVICE]
    Flush        1
    Daemon       Off
    Parsers_File parsers.conf
    Log_Level    info
    HTTP_Server  Off
    HTTP_Listen  0.0.0.0
    HTTP_Port    2020

[INPUT]
    Name exec_wasi
    Tag  exec.wasi.local
    WASI_Path /path/to/wasi_serde_json.wasm
    Parser wasi

[OUTPUT]
    Name  stdout
    Match *
```