From 2211c6d95c70b8ba4bf71e3f47e4fa82a58a2d65 Mon Sep 17 00:00:00 2001 From: jmccormick7 Date: Thu, 9 Oct 2025 17:30:31 -0400 Subject: [PATCH 1/4] output: enable plugin registration with event type. This commit relies on changes being accepted in the fluent-bit repository. The goal is to enable event-type registration for go proxy plugins. This change introduces a new function that will allow event-type setting in registration. This is done in order to not introduce breaking changes to current plugins. This new function can be used instead of the default FLBPluginRegisterFunction to set the event_type to a different value (metrics (2)). Signed-off-by: jmccormick7 Signed-off-by: jmccormick7 --- output/flb_plugin.h | 1 + output/output.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/output/flb_plugin.h b/output/flb_plugin.h index fbdd9e8..61c8eee 100644 --- a/output/flb_plugin.h +++ b/output/flb_plugin.h @@ -38,6 +38,7 @@ struct flb_plugin_proxy_def { int flags; char *name; char *description; + int event_type; }; #endif diff --git a/output/output.go b/output/output.go index ff9c01b..d032459 100644 --- a/output/output.go +++ b/output/output.go @@ -53,6 +53,18 @@ func FLBPluginRegister(def unsafe.Pointer, name, desc string) int { p.flags = 0 p.name = C.CString(name) p.description = C.CString(desc) + p.event_type = 0 + return 0 +} + +func FLBPluginRegisterWithEventType(def unsafe.Pointer, eventType int, name, desc string) int { + p := (*FLBPluginProxyDef)(def) + p._type = FLB_PROXY_OUTPUT_PLUGIN + p.proxy = FLB_PROXY_GOLANG + p.flags = 0 + p.name = C.CString(name) + p.description = C.CString(desc) + p.event_type = C.int(eventType) return 0 } From 88b71fb9026282704e251f7e76e435623db6e69f Mon Sep 17 00:00:00 2001 From: jmccormick7 Date: Fri, 10 Oct 2025 13:26:19 -0400 Subject: [PATCH 2/4] input: add setting event_type to match proposed struct changes This change just adds setting the empty value for event_type on input. Inputs do not set event type. This is related to a prosposed change in the fluent-bit library to ensure that the struct is the same format as the proposed change to enable output plugins to set their event type. Signed-off-by: jmccormick7 --- input/flb_plugin.h | 1 + input/input.go | 1 + 2 files changed, 2 insertions(+) diff --git a/input/flb_plugin.h b/input/flb_plugin.h index c8a7c1d..bbfef98 100644 --- a/input/flb_plugin.h +++ b/input/flb_plugin.h @@ -38,6 +38,7 @@ struct flb_plugin_proxy_def { int flags; char *name; char *description; + int event_type; }; #endif diff --git a/input/input.go b/input/input.go index 9dc2595..ab3bf45 100644 --- a/input/input.go +++ b/input/input.go @@ -52,6 +52,7 @@ func FLBPluginRegister(def unsafe.Pointer, name, desc string) int { p.flags = 0 p.name = C.CString(name) p.description = C.CString(desc) + p.event_type = 0 return 0 } From c1675499c0cd8a7d551933e62729178285e1225a Mon Sep 17 00:00:00 2001 From: jmccormick7 Date: Fri, 10 Oct 2025 13:33:43 -0400 Subject: [PATCH 3/4] output: adding in constants for event types This change adds in the constants from the fluent-bit repository for output types. These can be used in the go modules to then set the event type. Signed-off-by: jmccormick7 --- output/flb_output.h | 4 ++++ output/output.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/output/flb_output.h b/output/flb_output.h index b01fd65..e866044 100644 --- a/output/flb_output.h +++ b/output/flb_output.h @@ -20,6 +20,10 @@ #ifndef FLBGO_OUTPUT_H #define FLBGO_OUTPUT_H +#define FLB_OUTPUT_LOGS 1 +#define FLB_OUTPUT_METRICS 2 +#define FLB_OUTPUT_TRACES 4 + struct flb_api { char *(*output_get_property) (char *, void *); char *_; diff --git a/output/output.go b/output/output.go index d032459..32770d7 100644 --- a/output/output.go +++ b/output/output.go @@ -36,6 +36,9 @@ const ( FLB_PROXY_OUTPUT_PLUGIN = C.FLB_PROXY_OUTPUT_PLUGIN FLB_PROXY_GOLANG = C.FLB_PROXY_GOLANG + FLB_OUTPUT_LOGS = C.FLB_OUTPUT_LOGS + FLB_OUTPUT_METRICS = C.FLB_OUTPUT_METRICS + FLB_OUTPUT_TRACES = C.FLB_OUTPUT_TRACES ) // Local type to define a plugin definition From a2d6f8d63eb117fe0fa679d5b8e749b8d3523f2b Mon Sep 17 00:00:00 2001 From: jmccormick7 Date: Fri, 10 Oct 2025 13:40:00 -0400 Subject: [PATCH 4/4] output documentation: Add examples of `FLBRegisterPluginWithEventType` This change adds to the README.md files of each example output plugin and example of how to enable metric usage using the new function `FLBRegisterPluginWithEventType` Signed-off-by: jmccormick7 --- examples/out_gstdout/README.md | 12 ++++++++++++ examples/out_multiinstance/README.md | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/examples/out_gstdout/README.md b/examples/out_gstdout/README.md index d468f89..9ee3b9d 100644 --- a/examples/out_gstdout/README.md +++ b/examples/out_gstdout/README.md @@ -24,6 +24,18 @@ func FLBPluginRegister(ctx unsafe.Pointer) int { This function is invoked at start time _before_ any configuration is done inside the engine. +### Setting event type + +By default, Fluent Bit Golang plugins process logs. Optionally, the event_type +can be set to allow for metrics by using `output.FLBPluginRegisterWithEventType`. + +```go +//export FLBPluginRegister +func FLBPluginRegister(def unsafe.Pointer) int { + return output.FLBPluginRegisterWithEventType(ctx, output.FLB_OUTPUT_METRICS, "gstdout", "Stdout GO!") +} +``` + ## Plugin Initialization Before the engine starts, it initialize all plugins that were requested to start. Upon initialization a configuration context already exists, so the plugin can ask for configuration parameters or do any other internal checks. E.g: diff --git a/examples/out_multiinstance/README.md b/examples/out_multiinstance/README.md index 44682af..715911d 100644 --- a/examples/out_multiinstance/README.md +++ b/examples/out_multiinstance/README.md @@ -29,6 +29,18 @@ func FLBPluginRegister(def unsafe.Pointer) int { This function is invoked at start time _before_ any configuration is done inside the engine. +### Setting event type + +By default, Fluent Bit Golang plugins process logs. Optionally, the event_type +can be set to allow for metrics by using `output.FLBPluginRegisterWithEventType`. + +```go +//export FLBPluginRegister +func FLBPluginRegister(def unsafe.Pointer) int { + return output.FLBPluginRegisterWithEventType(ctx, output.FLB_OUTPUT_METRICS, "multiinstance", "Testing multiple instances") +} +``` + ## Plugin Initialization Before the engine starts, it initializes all plugins that were configured.