You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: development/developer-guide.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,10 @@ For cryptographic support, Fluent Bit uses the system installed version of OpenS
14
14
15
15
When you write Fluent Bit code, you'll use the Fluent Bit versions of the standard C functions for working with memory:
16
16
17
-
*[`flb_malloc()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `malloc`, allocates memory.
18
-
*[`flb_calloc()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `calloc`, allocates memory and initializes it to zero.
19
-
*[`flb_realloc()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `realloc`.
20
-
*[`flb_free()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `free`, releases allocated memory.
17
+
-[`flb_malloc()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `malloc`, allocates memory.
18
+
-[`flb_calloc()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `calloc`, allocates memory and initializes it to zero.
19
+
-[`flb_realloc()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `realloc`.
20
+
-[`flb_free()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_mem.h): Equivalent to `free`, releases allocated memory.
21
21
22
22
{% hint style="info" %}
23
23
Many types have specialized create and destroy functions, like [`flb_sds_create()` and `flb_sds_destroy()`](https://github.com/fluent/fluent-bit/blob/master/include/fluent-bit/flb_sds.h).
@@ -33,9 +33,9 @@ In general, you should use SDS strings in any string processing code. SDS string
33
33
34
34
Fluent Bit has its own network connection library. The key types and functions are defined in the following header files:
The following code demonstrates an HTTP request in Fluent Bit:
41
41
@@ -318,7 +318,8 @@ The [stdout plugin](https://github.com/fluent/fluent-bit/tree/master/plugins/out
318
318
Fluent Bit provides a standalone environment for development. Developers who use different operating systems or distributions can develop on a basic, common stack. The development environment provides the required libraries and tools for you.
Copy file name to clipboardExpand all lines: development/library_api.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ Fluent Bit is written in C and can be used from any C or C++ application.
6
6
7
7
Fluent Bit runs as a service, which means that the exposed API provides interfaces to create and manage contexts, specify inputs and outputs, set configuration parameters, and set routing paths for events or records. A typical usage of this library involves:
8
8
9
-
* Creating library instance and contexts and setting their properties.
10
-
* Enabling input plugins and setting their properties.
11
-
* Enabling output plugins and setting their properties.
12
-
* Starting the library runtime.
13
-
* Optionally ingesting records manually.
14
-
* Stopping the library runtime.
15
-
* Destroying library instances and contexts.
9
+
- Creating library instance and contexts and setting their properties.
10
+
- Enabling input plugins and setting their properties.
11
+
- Enabling output plugins and setting their properties.
Copy file name to clipboardExpand all lines: development/msgpack-format.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,26 @@
1
-
# Msgpack format
1
+
# MessagePack format
2
2
3
-
Fluent Bit **always** handles every Event message as a structured message using a binary serialization data format called [MessagePack](https://msgpack.org/).
3
+
Fluent Bit always handles every Event message as a structured message using a binary serialization data format called [MessagePack](https://msgpack.org/).
4
4
5
5
## Fluent Bit usage
6
6
7
7
MessagePack is a standard and well-defined format, refer to the official documentation for full details.
8
8
This section provides an overview of the specific types used by Fluent Bit within the format to help anyone consuming it.
9
9
10
-
* The data structure used by Fluent Bit is a 2-length [`fixarray`](https://github.com/msgpack/msgpack/blob/master/spec.md#array-format-family) of the timestamp and the data.
11
-
* The timestamp comes from [`flb_time_append_to_msgpack`])(https://github.com/fluent/fluent-bit/blob/2138cee8f4878733956d42d82f6dcf95f0aa9339/src/flb_time.c#L197), so it's either a `uint64`, a `float64`, or a [`fixext`](https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family) where the 4 MSBs are the seconds (big-endian `uint32`) and 4 LSBs are nanoseconds.
12
-
* The data itself is just a [`msgpack` map](https://github.com/msgpack/msgpack/blob/master/spec.md#map-format-family) with the keys as strings.
10
+
- The data structure used by Fluent Bit is a 2-length [`fixarray`](https://github.com/msgpack/msgpack/blob/master/spec.md#array-format-family) of the timestamp and the data.
11
+
- The timestamp comes from [`flb_time_append_to_msgpack`](https://github.com/fluent/fluent-bit/blob/2138cee8f4878733956d42d82f6dcf95f0aa9339/src/flb_time.c#L197), so it's either a `uint64`, a `float64`, or a [`fixext`](https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family) where the 4 MSBs are the seconds (big-endian `uint32`) and 4 LSBs are nanoseconds.
12
+
- The data itself is a [`msgpack` map](https://github.com/msgpack/msgpack/blob/master/spec.md#map-format-family) with the keys as strings.
13
13
14
14
## Example
15
15
16
16
Set up Fluent Bit to send in `msgpack` format to a specific port.
17
17
18
18
```bash
19
19
docker run --rm -it --network=host fluent/fluent-bit /fluent-bit/bin/fluent-bit -i cpu -o tcp://127.0.0.1:5170 -p format=msgpack -v
20
-
21
20
```
22
21
23
-
We could send this to stdout but as it is a serialized format you would end up with strange output.
24
-
As an example we use the [Python msgpack library](https://msgpack.org/#languages) to deal with it:
22
+
You could send this to stdout but as it's a serialized format you would end up with strange output.
23
+
As an example, use the [Python `msgpack` library](https://msgpack.org/#languages) to handle it:
Copy file name to clipboardExpand all lines: development/wasm-filter-plugins.md
+24-16Lines changed: 24 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ There are no additional requirements to execute Wasm plugins.
12
12
13
13
#### Build `flb-wamrc` (optional)
14
14
15
-
`flb-wamrc` is a `flb`-prefixed AOT (ahead of time) compiler that's provided from [`wasm-micro-runtime`](https://github.com/bytecodealliance/wasm-micro-runtime).
15
+
`flb-wamrc` is a `flb`-prefixed Ahead of Time (AOT) compiler that's provided from [`wasm-micro-runtime`](https://github.com/bytecodealliance/wasm-micro-runtime).
16
16
17
17
For `flb-wamrc` support, you must install the LLVM infrastructure and some additional libraries (`libmlir`, `libPolly`, `libedit`, and `libpfm`). For example:
18
18
@@ -22,13 +22,13 @@ For `flb-wamrc` support, you must install the LLVM infrastructure and some addit
22
22
23
23
### For Wasm programs
24
24
25
-
Currently, Fluent Bit supports the following Wasm tool chains:
25
+
Fluent Bit supports the following Wasm tool chains:
26
26
27
-
* Rust on `wasm32-unknown-unknown`
28
-
* rustc 1.62.1 (e092d0b6b 2022-07-16) or later
29
-
*[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
30
-
* v0.24.0 or later
31
-
*[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later.
27
+
- Rust on `wasm32-unknown-unknown`
28
+
- rustc 1.62.1 (`e092d0b6b` 2022-07-16) or later
29
+
-[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
30
+
- v0.24.0 or later
31
+
-[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later.
32
32
33
33
## Get started
34
34
@@ -44,8 +44,13 @@ To support AOT-compiled Wasm execution as filter plugins, build Fluent Bit with
44
44
45
45
Once compiled, you can see new plugins that handle `wasm`, for example:
46
46
47
+
```shell
48
+
bin/fluent-bit -h
49
+
```
50
+
51
+
Which returns results similar to:
52
+
47
53
```text
48
-
$ bin/fluent-bit -h
49
54
Usage: fluent-bit [OPTION]
50
55
Inputs
51
56
# ... other input plugin stuffs
@@ -60,9 +65,9 @@ Filters
60
65
61
66
The Fluent Bit Wasm filter assumes C ABI, also known as `wasm32-unknown-unknown` on Rust target and `wasm32-wasi` on TinyGo target.
62
67
63
-
### To Install Additional Components
68
+
### Install additional components
64
69
65
-
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-unknown-unknown` target, you must install `wasm32-unknown-unknown` by using [rustup](https://rustup.rs/). Then, install the target components as follows:
70
+
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-unknown-unknown` target, you must install `wasm32-unknown-unknown` by using [`rustup`](https://rustup.rs/). Then, install the target components as follows:
66
71
67
72
```text
68
73
rustup target add wasm32-unknown-unknown
@@ -116,7 +121,7 @@ pipeline:
116
121
function_name: super_awesome_filter
117
122
# Note: run Fluent Bit from the 'wasm_path' location.
118
123
accessible_paths: /path/to/fluent-bit
119
-
124
+
120
125
outputs:
121
126
- name: stdout
122
127
match: '*'
@@ -152,7 +157,8 @@ For example, one of the sample [Rust Wasm filters](https://github.com/fluent/flu
Another example of a Rust Wasm filter is the [flb_filter_iis](https://github.com/kenriortega/flb_filter_iis) filter.
160
+
161
+
Another example of a Rust Wasm filter is the [`flb_filter_iis`](https://github.com/kenriortega/flb_filter_iis) filter.
156
162
157
163
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.
158
164
@@ -172,7 +178,7 @@ pipeline:
172
178
wasm_path: /plugins/flb_filter_iis_wasm.wasm
173
179
function_name: flb_filter_log_iis_w3c_custom
174
180
accessible_paths: .
175
-
181
+
176
182
outputs:
177
183
- name: stdout
178
184
match: 'iis.*'
@@ -213,6 +219,7 @@ The output after the filter logic will be:
213
219
```
214
220
215
221
This filter approach offers several advantages inherent to programming languages. For example:
222
+
216
223
- It can be extended by adding type conversion to fields, such as `sc_bytes`, `cs_bytes`, and `time_taken`. You can use this to validate data results.
217
224
- It allows for the use of conditions to apply more descriptive filters. For example, you can get only all logs that contain status codes higher than `4xx` or `5xx`.
218
225
- It can be used to define allow lists and deny lists using a data structure array or a file to store predefined IP addresses.
@@ -254,6 +261,7 @@ AOT compiling should generate CPU architecture-dependent objects. If you want to
Copy file name to clipboardExpand all lines: development/wasm-input-plugins.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,13 @@ There are no additional requirements to execute Wasm plugins.
12
12
13
13
### For Wasm programs
14
14
15
-
Fluent Bit supports the following Wasm toolchains:
15
+
Fluent Bit supports the following Wasm tool chains:
16
16
17
-
* Rust on `wasm32-unknown-unknown`
18
-
* rustc 1.62.1 (e092d0b6b 2022-07-16) or later
19
-
*[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
20
-
* v0.24.0 or later
21
-
*[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later
17
+
- Rust on `wasm32-unknown-unknown`
18
+
- rustc 1.62.1 (`e092d0b6b` 2022-07-16) or later
19
+
-[TinyGo](https://github.com/tinygo-org/tinygo) on `wasm32-wasi`
20
+
- v0.24.0 or later
21
+
-[WASI SDK](https://github.com/WebAssembly/wasi-sdk) 13 or later
22
22
23
23
## Get started
24
24
@@ -50,7 +50,7 @@ Wasm input in Fluent Bit assumes WASI ABI, also known as `wasm32-wasi` on Rust t
50
50
51
51
### Install additional components
52
52
53
-
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-wasi` target, you must install `wasm32-wasi` by using [rustup](https://rustup.rs/). Then, install the target components as:
53
+
TinyGo and WASI SDK support Wasm target by default. When using Rust's `wasm32-wasi` target, you must install `wasm32-wasi` by using [`rustup`](https://rustup.rs/). Then, install the target components as:
54
54
55
55
```text
56
56
rustup target add wasm32-wasi
@@ -74,10 +74,10 @@ pipeline:
74
74
tag: exec.wasi.local
75
75
wasi_path: /path/to/wasi_built_json.wasm
76
76
# For security reasons, WASM/WASI program cannot access its outer world
77
-
# without accessible permissions. Uncomment below 'accessible_paths' and
77
+
# without accessible permissions. Uncomment below 'accessible_paths' and
78
78
# run Fluent Bit from the 'wasi_path' location:
79
79
# accessible_paths /path/to/fluent-bit
80
-
80
+
81
81
outputs:
82
82
- name: stdout
83
83
match: '*'
@@ -92,7 +92,7 @@ pipeline:
92
92
Tag exec.wasi.local
93
93
WASI_Path /path/to/wasi_built_json.wasm
94
94
# For security reasons, WASM/WASI program cannot access its outer world
95
-
# without accessible permissions. Uncomment below 'accessible_paths' and
95
+
# without accessible permissions. Uncomment below 'accessible_paths' and
96
96
# run Fluent Bit from the 'wasi_path' location:
97
97
# accessible_paths /path/to/fluent-bit
98
98
@@ -104,4 +104,5 @@ pipeline:
104
104
{% endtab %}
105
105
{% endtabs %}
106
106
107
-
For an example that handles structured logs, see the [Rust `serde-json` example](https://github.com/fluent/fluent-bit/tree/master/examples/wasi_serde_json).
107
+
For an example that handles structured logs, see the [Rust `serde-json`
0 commit comments