summaryrefslogtreecommitdiffstats
path: root/fluent-bit/examples/filter_wasm_go/README.md
blob: 863cf83600735a5c40f94b227f45a0c690d18d70 (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
# Fluent Bit / filter_wasm_go

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

## Prerequisites

Tested on

* TinyGo
  * [tinygo](https://tinygo.org/) tinygo version 0.23.0 linux/amd64 (using go version go1.18.2 and LLVM version 14.0.0)
  * [tinygo](https://tinygo.org/) tinygo version 0.24.0 linux/amd64 (using go version go1.18.2 and LLVM version 14.0.0)

For Ubuntu, it's easy to install with:

```console
$ wget https://github.com/tinygo-org/tinygo/releases/download/v0.24.0/tinygo_0.24.0_amd64.deb
$ sudo dpkg -i tinygo_0.24.0_amd64.deb
```

## How to build

Execute _tinygo build_ as follows:

```console
$ tinygo build -wasm-abi=generic -target=wasi -o filter.wasm filter.go
```

Finally, under the same directory, `*.wasm` file will be created:

```console
$ ls *.wasm
filter.wasm
```

## How to confirm WASM filter 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/filter.wasm
    Function_Name go_filter
    accessible_paths .,/path/to/fluent-bit

[OUTPUT]
    Name  stdout
    Match *

```