FLBPluginConfigKey retrieves a named configuration value for a Fluent Bit Go input plugin during initialization. The plugin can use the returned value to inspect settings such as Log_Level, validate configuration, and cache usable parameters. section 10.6.2
Use the call as part of an initialization flow:
- Request a named attribute, such as Log_Level, from the plugin configuration. section 10.6.2
- Apply appropriate type casting when collecting configuration values. section 10.6.2
- Validate that required values are defined and sensible before caching them. section 10.6.2
Inspect the log level
During initialization, call input.FLBPluginConfigKey(plugin, "Log_Level"), compare the result with debug, and print the configuration when debugging is enabled. section 10.6.2
Listing 10.2 Implementation of the initialize function: in.go
//export FLBPluginInit
func FLBPluginInit(plugin unsafe.Pointer) int {
params, err := getParams(plugin) #1
if err != nil {
return input.FLB_ERROR #2
}
if strings.Contains(strings.ToLower(
input.FLBPluginConfigKey(plugin, "Log_Level")),
"debug") { #3
log.Printf("%s configured with %v\n",
params.pluginName, params) #4
}
validateErr := validateSqlParams(params) #5
if validateErr == nil {
cacheParams(params)
return input.FLB_OK #6
} else {
fmt.Printf("%s - Configuration error - %s \n",
params.pluginName, validateErr)
return input.FLB_ERROR
}
}
The initialization implementation shows configuration retrieval, debug-level inspection, validation, parameter caching, and FLB_OK or FLB_ERROR returns. section 10.6.2
