Skip to content

Commit 374db58

Browse files
authored
exec_wasi: wasm: Add documents for Wasm based plugins (#881)
* pipelines: inputs: exec_wasi: Add document for in_exec_wasi plugin Signed-off-by: Hiroshi Hatake <[email protected]> * summary: Add Exec Wasi section Signed-off-by: Hiroshi Hatake <[email protected]> * pipelines: filters: wasm: Add document for filter_wasm plugin Signed-off-by: Hiroshi Hatake <[email protected]> * summary: Add wasm section Signed-off-by: Hiroshi Hatake <[email protected]> Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 8151375 commit 374db58

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
* [Docker Events](pipeline/inputs/docker-events.md)
8686
* [Dummy](pipeline/inputs/dummy.md)
8787
* [Exec](pipeline/inputs/exec.md)
88+
* [Exec Wasi](pipeline/inputs/exec_wasi.md)
8889
* [Fluent Bit Metrics](pipeline/inputs/fluentbit-metrics.md)
8990
* [Forward](pipeline/inputs/forward.md)
9091
* [Head](pipeline/inputs/head.md)
@@ -134,6 +135,7 @@
134135
* [Standard Output](pipeline/filters/standard-output.md)
135136
* [Throttle](pipeline/filters/throttle.md)
136137
* [Tensorflow](pipeline/filters/tensorflow.md)
138+
* [Wasm](pipeline/filters/wasm.md)
137139
* [Outputs](pipeline/outputs/README.md)
138140
* [Amazon CloudWatch](pipeline/outputs/cloudwatch.md)
139141
* [Amazon Kinesis Data Firehose](pipeline/outputs/firehose.md)

pipeline/filters/wasm.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
description: Use Wasm programs as a filter
3+
---
4+
5+
# Wasm Filter
6+
7+
Wasm Filter allows you to modify the incoming records using [Wasm](https://webassembly.org/) technology.
8+
9+
Due to the necessity to have a flexible filtering mechanism, it is now possible to extend Fluent Bit capabilities by writing custom filters using built Wasm programs and its runtime. A Wasm-based filter takes two steps:
10+
11+
0. (Optional) Compiled as AOT (Ahead Of Time) objects to optimize Wasm execution pipeline
12+
1. Configure the Filter in the main configuration
13+
2. Prepare a Wasm program that will be used by the Filter
14+
15+
## Configuration Parameters <a id="config"></a>
16+
17+
The plugin supports the following configuration parameters:
18+
19+
| Key | Description |
20+
| :--- | :--- |
21+
| Wasm\_Path | Path to the built Wasm program that will be used. This can be a relative path against the main configuration file. |
22+
| Function\_Name | Wasm function name that will be triggered to do filtering. It's assumed that the function is built inside the Wasm program specified above. |
23+
| Accessible\_Paths | Specify the whilelist of paths to be able to access paths from WASM programs. |
24+
25+
## Configuration Examples <a id="config_example"></a>
26+
27+
Here is a configuration example.
28+
29+
```python
30+
[INPUT]
31+
Name dummy
32+
Tag dummy.local
33+
34+
[FILTER]
35+
Name wasm
36+
Match dummy.*
37+
WASM_Path /path/to/wasm_program.wasm
38+
Function_Name filter_function_name
39+
Accessible_Paths .,/path/to/accessible
40+
41+
[OUTPUT]
42+
Name stdout
43+
Match *
44+
```

pipeline/inputs/exec_wasi.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Exec Wasi
2+
3+
The **exec_wasi** input plugin, allows to execute WASM program that is WASI target like as external program and collects event logs from there.
4+
5+
## Configuration Parameters
6+
7+
The plugin supports the following configuration parameters:
8+
9+
| Key | Description |
10+
| :--- | :--- |
11+
| WASI\_Path | The place of a WASM program file. |
12+
| Parser | Specify the name of a parser to interpret the entry as a structured message. |
13+
| Accessible\_Paths | Specify the whilelist of paths to be able to access paths from WASM programs. |
14+
| Interval\_Sec | Polling interval \(seconds\). |
15+
| Interval\_NSec | Polling interval \(nanosecond\). |
16+
| Buf\_Size | Size of the buffer \(check [unit sizes](https://docs.fluentbit.io/manual/configuration/unit_sizes) for allowed values\) |
17+
| Oneshot | Only run once at startup. This allows collection of data precedent to fluent-bit's startup (bool, default: false) |
18+
19+
## Configuration Examples
20+
21+
Here is a configuration example.
22+
in\_exec\_wasi can handle parser.
23+
To retrieve from structured data from WASM program, you have to create parser.conf:
24+
25+
Note that `Time_Format` should be aligned for the format of your using timestamp.
26+
In this documents, we assume that WASM program should write JSON style strings into stdout.
27+
28+
29+
```python
30+
[PARSER]
31+
Name wasi
32+
Format json
33+
Time_Key time
34+
Time_Format %Y-%m-%dT%H:%M:%S.%L %z
35+
```
36+
37+
Then, you can specify the above parsers.conf in the main fluent-bit configuration:
38+
39+
```python
40+
[SERVICE]
41+
Flush 1
42+
Daemon Off
43+
Parsers_File parsers.conf
44+
Log_Level info
45+
HTTP_Server Off
46+
HTTP_Listen 0.0.0.0
47+
HTTP_Port 2020
48+
49+
[INPUT]
50+
Name exec_wasi
51+
Tag exec.wasi.local
52+
WASI_Path /path/to/wasi/program.wasm
53+
Accessible_Paths .,/path/to/accessible
54+
Parser wasi
55+
56+
[OUTPUT]
57+
Name stdout
58+
Match *
59+
60+
```

0 commit comments

Comments
 (0)