Skip to content

Commit 3a8ea0b

Browse files
authored
Adding YAML examples to developers wasm filter plugin docs. Fixes #1768. (#1769)
* Adding YAML examples to developers wasm filter plugin docs. Fixes ##1768. Signed-off-by: Eric D. Schabell <[email protected]> * Added comment for accessable_path and running Fluent Bit from the wasam app location. Signed-off-by: Eric D. Schabell <[email protected]> --------- Signed-off-by: Eric D. Schabell <[email protected]>
1 parent ecca4b7 commit 3a8ea0b

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

development/wasm-filter-plugins.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,32 @@ pub extern "C" fn rust_filter(tag: *const c_char, tag_len: u32, time_sec: u32, t
9898

9999
The `//export XXX` attribute on TinyGo and `#[no_mangle]` attribute on Rust are required. This is because TinyGo and Rust will mangle their function names if they aren't specified.
100100

101-
Once built, a Wasm program will be available. Then you can execute that built program with the following Fluent Bit configuration:
101+
Once built, a Wasm program will be available. Then you can execute that built program with one of the following Fluent Bit configurations:
102+
103+
{% tabs %}
104+
{% tab title="fluent-bit.yaml" %}
105+
106+
```yaml
107+
pipeline:
108+
inputs:
109+
- name: dummy
110+
tag: dummy.local
111+
112+
filters:
113+
- name: wasm
114+
match: 'dummy.*'
115+
wasm_path: /path/to/built_filter.wasm
116+
function_name: super_awesome_filter
117+
# Note: run Fluent Bit from the 'wasm_path' location.
118+
accessible_paths: /path/to/fluent-bit
119+
120+
outputs:
121+
- name: stdout
122+
match: '*'
123+
```
124+
125+
{% endtab %}
126+
{% tab title="fluent-bit.conf" %}
102127
103128
```text
104129
[INPUT]
@@ -110,13 +135,16 @@ Once built, a Wasm program will be available. Then you can execute that built pr
110135
Match dummy.*
111136
WASM_Path /path/to/built_filter.wasm
112137
Function_Name super_awesome_filter
113-
accessible_paths .,/path/to/fluent-bit
138+
accessible_paths /path/to/fluent-bit
114139

115140
[OUTPUT]
116141
Name stdout
117142
Match *
118143
```
119144

145+
{% endtab %}
146+
{% endtabs %}
147+
120148
For example, one of the sample [Rust Wasm filters](https://github.com/fluent/fluent-bit/tree/master/examples/filter_rust) should generate its filtered logs as follows:
121149

122150
```text
@@ -125,8 +153,34 @@ For example, one of the sample [Rust Wasm filters](https://github.com/fluent/flu
125153
[0] dummy.local: [1666270590.271107000, {"lang"=>"Rust", "message"=>"dummy", "original"=>"{"message":"dummy"}", "tag"=>"dummy.local", "time"=>"2022-10-20T12:56:30.271107000 +0000"}]
126154
```
127155
Another example of a Rust Wasm filter is the [flb_filter_iis](https://github.com/kenriortega/flb_filter_iis) filter.
156+
128157
This filter takes the [Internet Information Services (IIS)](https://learn.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/configure-logging-in-iis) [w3c logs](https://learn.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/configure-logging-in-iis#select-w3c-fields-to-log) (with some custom modifications) and transforms the raw string into a standard Fluent Bit JSON structured record.
129158

159+
{% tabs %}
160+
{% tab title="fluent-bit.yaml" %}
161+
162+
```yaml
163+
pipeline:
164+
inputs:
165+
- name: dummy
166+
dummy: '{"log": "2023-08-11 19:56:44 W3SVC1 WIN-PC1 ::1 GET / - 80 ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/115.0.0.0+Safari/537.36+Edg/115.0.1901.200 - - localhost 304 142 756 1078 -"}'
167+
tag: 'iis.*'
168+
169+
filters:
170+
- name: wasm
171+
match: 'iis.*'
172+
wasm_path: /plugins/flb_filter_iis_wasm.wasm
173+
function_name: flb_filter_log_iis_w3c_custom
174+
accessible_paths: .
175+
176+
outputs:
177+
- name: stdout
178+
match: 'iis.*'
179+
```
180+
181+
{% endtab %}
182+
{% tab title="fluent-bit.conf" %}
183+
130184
```text
131185
[INPUT]
132186
Name dummy
@@ -145,6 +199,9 @@ This filter takes the [Internet Information Services (IIS)](https://learn.micros
145199
match iis.*
146200
```
147201

202+
{% endtab %}
203+
{% endtabs %}
204+
148205
The incoming raw strings from an IIS log are composed of the following fields:
149206

150207
`date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port c-ip cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-bytes cs-bytes time-taken c-authorization-header`
@@ -199,4 +256,4 @@ AOT compiling should generate CPU architecture-dependent objects. If you want to
199256

200257
* [C filter](https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_c)
201258
* [Rust Filter](https://github.com/fluent/fluent-bit/tree/master/examples/filter_rust)
202-
* [TinyGo filter](https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_go)
259+
* [TinyGo filter](https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_go)

0 commit comments

Comments
 (0)