Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/out_gstdout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions examples/out_multiinstance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions input/flb_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct flb_plugin_proxy_def {
int flags;
char *name;
char *description;
int event_type;
};

#endif
4 changes: 4 additions & 0 deletions output/flb_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *_;
Expand Down
1 change: 1 addition & 0 deletions output/flb_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct flb_plugin_proxy_def {
int flags;
char *name;
char *description;
int event_type;
};

#endif
16 changes: 16 additions & 0 deletions output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const (
FLB_LOG_WARN = C.FLB_LOG_WARN
FLB_LOG_INFO = C.FLB_LOG_INFO
FLB_LOG_DEBUG = C.FLB_LOG_DEBUG

FLB_OUTPUT_LOGS = C.FLB_OUTPUT_LOGS
FLB_OUTPUT_METRICS = C.FLB_OUTPUT_METRICS
FLB_OUTPUT_TRACES = C.FLB_OUTPUT_TRACES
)

type (
Expand All @@ -63,6 +67,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
}

Expand Down
Loading