Skip to content

Commit 7e908ae

Browse files
committed
Adding YAML examples to developers wasm filter plugin docs. Fixes ##1768.
Signed-off-by: Eric D. Schabell <[email protected]>
1 parent cbee81e commit 7e908ae

File tree

1 file changed

+59
-3
lines changed

1 file changed

+59
-3
lines changed

development/wasm-filter-plugins.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,31 @@ 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+
accessible_paths: /path/to/fluent-bit
118+
119+
outputs:
120+
- name: stdout
121+
match: '*'
122+
```
123+
124+
{% endtab %}
125+
{% tab title="fluent-bit.conf" %}
102126
103127
```text
104128
[INPUT]
@@ -110,13 +134,16 @@ Once built, a Wasm program will be available. Then you can execute that built pr
110134
Match dummy.*
111135
WASM_Path /path/to/built_filter.wasm
112136
Function_Name super_awesome_filter
113-
accessible_paths .,/path/to/fluent-bit
137+
accessible_paths /path/to/fluent-bit
114138

115139
[OUTPUT]
116140
Name stdout
117141
Match *
118142
```
119143

144+
{% endtab %}
145+
{% endtabs %}
146+
120147
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:
121148

122149
```text
@@ -125,8 +152,34 @@ For example, one of the sample [Rust Wasm filters](https://github.com/fluent/flu
125152
[0] dummy.local: [1666270590.271107000, {"lang"=>"Rust", "message"=>"dummy", "original"=>"{"message":"dummy"}", "tag"=>"dummy.local", "time"=>"2022-10-20T12:56:30.271107000 +0000"}]
126153
```
127154
Another example of a Rust Wasm filter is the [flb_filter_iis](https://github.com/kenriortega/flb_filter_iis) filter.
155+
128156
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.
129157

158+
{% tabs %}
159+
{% tab title="fluent-bit.yaml" %}
160+
161+
```yaml
162+
pipeline:
163+
inputs:
164+
- name: dummy
165+
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 -"}'
166+
tag: 'iis.*'
167+
168+
filters:
169+
- name: wasm
170+
match: 'iis.*'
171+
wasm_path: /plugins/flb_filter_iis_wasm.wasm
172+
function_name: flb_filter_log_iis_w3c_custom
173+
accessible_paths: .
174+
175+
outputs:
176+
- name: stdout
177+
match: 'iis.*'
178+
```
179+
180+
{% endtab %}
181+
{% tab title="fluent-bit.conf" %}
182+
130183
```text
131184
[INPUT]
132185
Name dummy
@@ -145,6 +198,9 @@ This filter takes the [Internet Information Services (IIS)](https://learn.micros
145198
match iis.*
146199
```
147200

201+
{% endtab %}
202+
{% endtabs %}
203+
148204
The incoming raw strings from an IIS log are composed of the following fields:
149205

150206
`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 +255,4 @@ AOT compiling should generate CPU architecture-dependent objects. If you want to
199255

200256
* [C filter](https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_c)
201257
* [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)
258+
* [TinyGo filter](https://github.com/fluent/fluent-bit/tree/master/examples/filter_wasm_go)

0 commit comments

Comments
 (0)