Commit 315410d1 authored by Eteri's avatar Eteri

fluentbit: add wendelin plugin (hardcoced params)

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