Commit 315410d1 authored by Eteri's avatar Eteri

fluentbit: add wendelin plugin (hardcoced params)

parent ad5f9532
...@@ -20,7 +20,7 @@ bin = ${:home}/bin ...@@ -20,7 +20,7 @@ bin = ${:home}/bin
[fluentbit-service] [fluentbit-service]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = command-line =
{{ fluentbit_source_location }}/build/bin/fluent-bit -c {{ wendelin_conf_file }}/conf.cnf -e {{ fluentbit_source_location }}/build/bin/fluent-bit -e
{{ wendelin_test_path}}/{{ wendelin_plugin_filename }}.so {{ wendelin_test_path}}/{{ wendelin_plugin_filename }}.so
-i cpu -o wendelin_out -v -i cpu -o wendelin_out -v
wrapper-path = ${directory:service}/fluentbit-service wrapper-path = ${directory:service}/fluentbit-service
......
[SERVICE]
Flush 5
Daemon off
Log_Level debug
[INPUT] [INPUT]
Name cpu Name cpu
Tag cpu Tag cpu
[OUTPUT] [OUTPUT]
Name http Name wendelin_out
Match * Match *
Host softinst84835.host.vifib.net Host https://softinst84835.host.vifib.net/erp5/portal_ingestion_policies
URI /erp5 URI /fluentbit_test
\ No newline at end of file USER zope
PASSWORD dbguyl
...@@ -5,6 +5,10 @@ import ( ...@@ -5,6 +5,10 @@ import (
"fmt" "fmt"
"unsafe" "unsafe"
"C" "C"
"net/http"
"strconv"
"bytes"
) )
//export FLBPluginRegister //export FLBPluginRegister
...@@ -17,50 +21,39 @@ func FLBPluginRegister(ctx unsafe.Pointer) int { ...@@ -17,50 +21,39 @@ func FLBPluginRegister(ctx unsafe.Pointer) int {
// ctx (context) pointer to fluentbit context (state/ c code) // ctx (context) pointer to fluentbit context (state/ c code)
func FLBPluginInit(ctx unsafe.Pointer) int { func FLBPluginInit(ctx unsafe.Pointer) int {
// Example to retrieve an optional configuration parameter // Example to retrieve an optional configuration parameter
param := output.FLBPluginConfigKey(ctx, "param") /* param := output.FLBPluginConfigKey(ctx, "param")
user := output.FLBPluginConfigKey(ctx, "user") user := output.FLBPluginConfigKey(ctx, "user")
password := output.FLBPluginConfigKey(ctx, "password") password := output.FLBPluginConfigKey(ctx, "password")
uri := output.FLBPluginConfigKey(ctx, "uri") uri := output.FLBPluginConfigKey(ctx, "uri")
fmt.Printf("[flb-go] plugin parameter = '%s'\n", param) //fmt.Printf("[flb-go] plugin parameter = '%s'\n", param)
fmt.Printf("[flb-go] plugin parameter = '%s'\n", user) fmt.Printf("[flb-go user] plugin parameter = '%s'\n", user)
fmt.Printf("[flb-go] plugin parameter = '%s'\n", password) fmt.Printf("[flb-go password] plugin parameter = '%s'\n", password)
fmt.Printf("[flb-go] plugin parameter = '%s'\n", uri) fmt.Printf("[flb-go uri] plugin parameter = '%s'\n", uri)
*/
return output.FLB_OK return output.FLB_OK
} }
//export FLBPluginFlush //export FLBPluginFlush
func FLBPluginFlush(data unsafe.Pointer, length C.int, tag *C.char) int { func FLBPluginFlush(data unsafe.Pointer, length C.int, tag *C.char) int {
// change here for wendelin var b []byte
b = C.GoBytes(data, C.int(length))
// var count int var username string = "zope"
// var ret int var passwd string = "dbguylpn"
// var ts interface{}
// var record map[interface{}]interface{} hc := http.Client{}
/*
// Create Fluent Bit decoder req, err := http.NewRequest("POST", "https://softinst84835.host.vifib.net/erp5/portal_ingestion_policies/fluentbit_test/ingest?reference=fluentbit_test", bytes.NewBuffer(b))
dec := output.NewDecoder(data, int(length)) req.Header.Set("Content-Type", "application/octet-stream")
// Iterate Records req.SetBasicAuth(username, passwd)
count = 0
for { resp, err := hc.Do(req)
// Extract Record fmt.Println(resp.Status)
ret, ts, record = output.GetRecord(dec) fmt.Println(err)
if ret != 0 { defer resp.Body.Close()
break
}
// Print record keys and values
timestamp := ts.(output.FLBTime)
fmt.Printf("[%d] %s: [%s, {", count, C.GoString(tag),
timestamp.String())
for k, v := range record {
fmt.Printf("\"%s\": %v, ", k, v)
}
fmt.Printf("}\n")
count++
}
*/
// Return options: // Return options:
// //
// output.FLB_OK = data have been processed. // output.FLB_OK = data have been processed.
......
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