10 Building plugins

 

This chapter covers

  • Implementing custom plugins using the Go language.
  • Using the Fluent Bit provided Go binding layer.
  • Consuming Fluent Bit configuration data to control our plugin behavior.
  • Managing data between method calls using the context object.
  • Seeing how contexts are applied for multiple instances of the same plugin type.

So far in the book, we’ve concentrated on using capabilities entirely within a Fluent Bit deployment. The last chapter went through the options for building custom plugins. In this chapter, we will implement input and output plugins using Go.

Figure 10.1 Logical architecture of Fluent Bit, with this Chapter's focus highlighted.

We’ve chosen to use Go for several reasons:

  • We’re not bound to the processes and rules expected of us if we produce a C plugin that compiles into the Fluent Bit core. We don’t have to recompile the entirety of Fluent Bit.
  • Go frees us from worrying about memory resource management without compromising on performance considerations.
  • Go frees us from the additional complexity of WASM and WASI and the constraints for connecting to other services.
  • It helps enforce the API layers as the touchpoints are clearly established.

10.1 Plugin objective

10.2 Go Plugin approach

10.2.1 Simplifying our build process

10.2.2 Code Structure

10.2.3 Fluent Bit feature switches

10.2.4 Build process for the plugins

10.3 Understanding the Plugin Lifecycle

10.3.1 Input Lifecycle

10.3.2 Output Lifecycle

10.4 Implementing the plugin

10.4.1 Setting up MySQL

10.4.2 Input plugin

10.4.3 Building the code

10.4.4 Output plugin

10.5 Deploying the Custom Plugin

10.6 Configuring Our Scenario

10.7 Executing the build

10.8 Running the custom plugins

10.9 Summary