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. 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 } 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/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..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 @@ -53,6 +56,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 }