Commit 81da849f authored by Xiaowu Zhang's avatar Xiaowu Zhang

example to get parameters

parent c4dc05e7
[SERVICE]
Flush 5
Daemon off
flush 5
[INPUT]
Name cpu
name cpu
[output]
Name http
Match *
Host softinst143538.host.vifib.net
URI /erp5/fluentbit_upload_test
name wendelin_fluentbit
match *
streamtool_uri https://softinst143538.host.vifib.net
user xx
password xx
buffer_type memory
flush_interval 60s
disable_retry_limit true
......@@ -13,28 +13,41 @@ import (
//export FLBPluginRegister
func FLBPluginRegister(def unsafe.Pointer) int {
return output.FLBPluginRegister(def, "gstdout", "Stdout GO!")
return output.FLBPluginRegister(def, "wendelin_fluentbit", "Wendelin Fluentbit")
}
//export FLBPluginInit
// (fluentbit will call this)
// plugin (context) pointer to fluentbit context (state/ c code)
func FLBPluginInit(plugin unsafe.Pointer) int {
// Example to retrieve an optional configuration parameter
param := output.FLBPluginConfigKey(plugin, "param")
fmt.Printf("[flb-go] plugin parameter = '%s'\n", param)
streamtool_uri := output.FLBPluginConfigKey(plugin, "streamtool_uri")
user := output.FLBPluginConfigKey(plugin, "user")
password := output.FLBPluginConfigKey(plugin, "password")
buffer_type := output.FLBPluginConfigKey(plugin, "buffer_type")
flush_interval := output.FLBPluginConfigKey(plugin, "flush_interval")
disable_retry_limit := output.FLBPluginConfigKey(plugin, "disable_retry_limit")
dict := map[string]string{
"streamtool_uri": streamtool_uri,
"user": user,
"password": password,
"buffer_type": buffer_type,
"flush_interval": flush_interval,
"disable_retry_limit": disable_retry_limit,
}
output.FLBPluginSetContext(plugin, dict)
return output.FLB_OK
}
//export FLBPluginFlush
func FLBPluginFlush(data unsafe.Pointer, length C.int, tag *C.char) int {
//export FLBPluginFlushCtx
func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int {
var count int
var ret int
var ts interface{}
var record map[interface{}]interface{}
// Create Fluent Bit decoder
dec := output.NewDecoder(data, int(length))
dict := output.FLBPluginGetContext(ctx).(map[string]string)
fmt.Printf("streamtool_uri %s \n", dict["streamtool_uri"])
// Iterate Records
count = 0
var result string
......
......@@ -73,7 +73,7 @@ extern GoInt FLBPluginRegister(void* def);
// (fluentbit will call this)
// plugin (context) pointer to fluentbit context (state/ c code)
extern GoInt FLBPluginInit(void* plugin);
extern GoInt FLBPluginFlush(void* data, int length, char* tag);
extern GoInt FLBPluginFlushCtx(void* ctx, void* data, int length, char* tag);
extern GoInt FLBPluginExit();
#ifdef __cplusplus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment