Golang output plugins
Fluent Bit supports integration of Golang plugins built as shared objects for output plugins only. The interface for the Golang plugins is currently under development but is functional.
Get started
Compile Fluent Bit with Golang support:
$ cd build/
$ cmake -DFLB_DEBUG=On -DFLB_PROXY_GO=On ../
$ makeOnce compiled, you can see the new -e option in the binary which stands for external plugin.
$ bin/fluent-bit -h
Usage: fluent-bit [OPTION]
Available Options
-c --config=FILE specify an optional configuration file
-d, --daemon run Fluent Bit in background mode
-f, --flush=SECONDS flush timeout in seconds (default: 1)
-i, --input=INPUT set an input
-m, --match=MATCH set plugin match, same as '-p match=abc'
-o, --output=OUTPUT set an output
-p, --prop="A=B" set plugin configuration property
-e, --plugin=FILE load an external plugin (shared lib)
...Build a Go plugin
The fluent-bit-go package is available to assist developers in creating Go plugins.
https://github.com/fluent/fluent-bit-go
A minimum Go plugin looks like the following:
The previous code is a template to write an output plugin. It's important to keep the package name as main and add an explicit main() function. This is a requirement as the code will be build as a shared library.
To build the code, use the following line:
Once built, a shared library called out_gstdout.so will be available. Confirm the final .so file is as expected. When you use the ldd over the library should see something similar to this:
Run Fluent Bit with the new plugin
Configuration file
Fluent Bit can load and run Golang plugins using two configuration files.
Plugins configuration file
Plugins configuration file
Path
A path for a Golang plugin.
Plugin file example
Main configuration file
The keys for Golang plugin available as of this version are described in the following table:
Plugins_file
Path for a plugins configuration file. A plugins configuration file let you define paths for external plugins. For example, see here.
Main configuration file example
The following is an example of a main configuration file.
Config key constraint
The following configuration keys are reserved by Fluent Bit and must not be used by a custom plugin:
aliashostipv6listenlog_levellog_suppress_intervalmatchmatch_regexmem_buf_limitportretry_limitroutablestorage.pause_on_chunks_overlimitstorage.total_limit_sizestorage.typetagthreadedtlstls.ca_filetls.ca_pathtls.crt_filetls.debugtls.key_filetls.key_passwdtls.verifytls.vhostworkers
Run using a configuration file
You can load a main configuration file using -c option. You don't need to specify a plugins configuration file from command line.
Last updated
Was this helpful?