Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
slapos
Commits
8b4fad6c
Commit
8b4fad6c
authored
Jan 18, 2018
by
Eteri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fluentbit-wendelin: fix errors
parent
315410d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
26 deletions
+63
-26
software/fluentbit/wendelin-plugin/conf.cnf
software/fluentbit/wendelin-plugin/conf.cnf
+6
-11
software/fluentbit/wendelin-plugin/out_wendelin.go
software/fluentbit/wendelin-plugin/out_wendelin.go
+57
-15
No files found.
software/fluentbit/wendelin-plugin/conf.cnf
View file @
8b4fad6c
[SERVICE]
Flush 5
Daemon off
Log_Level debug
[INPUT]
Name
cpu
Tag
cpu
Name
dummy
Tag
dummy
[OUTPUT]
Name wendelin_out
Match *
Host https://softinst84835.host.vifib.net/erp5/portal_ingestion_policies
URI /fluentbit_test
U
SER zope
PASSWORD dbguyl
User zope
Password dbguylpn
U
ri https://softinst84835.host.vifib.net/erp5/portal_ingestion_policies/fluentbit_test
Reference fluentbit_test
\ No newline at end of file
software/fluentbit/wendelin-plugin/out_wendelin.go
View file @
8b4fad6c
...
...
@@ -8,9 +8,16 @@ import (
"net/http"
"strconv"
"bytes"
"regexp"
)
// configuration parameters
var
user
string
var
password
string
var
uri
string
var
reference
string
//export FLBPluginRegister
func
FLBPluginRegister
(
ctx
unsafe
.
Pointer
)
int
{
return
output
.
FLBPluginRegister
(
ctx
,
"wendelin_out"
,
"Wendelin Out GO!"
)
...
...
@@ -21,44 +28,79 @@ 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")
user := output.FLBPluginConfigKey(ctx, "user")
password := output.FLBPluginConfigKey(ctx, "password")
uri := output.FLBPluginConfigKey(ctx, "uri")
// param := output.FLBPluginConfigKey(ctx, "param")
user
=
output
.
FLBPluginConfigKey
(
ctx
,
"User"
)
password
=
output
.
FLBPluginConfigKey
(
ctx
,
"Password"
)
uri
=
output
.
FLBPluginConfigKey
(
ctx
,
"Uri"
)
reference
=
output
.
FLBPluginConfigKey
(
ctx
,
"Reference"
)
//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
)
*/
fmt
.
Printf
(
"[flb-go reference] plugin parameter = '%s'
\n
"
,
reference
)
return
output
.
FLB_OK
}
//export FLBPluginFlush
func
FLBPluginFlush
(
data
unsafe
.
Pointer
,
length
C
.
int
,
tag
*
C
.
char
)
int
{
request_string
:=
uri
+
"/ingest?reference="
+
reference
var
b
[]
byte
b
=
C
.
GoBytes
(
data
,
C
.
int
(
length
))
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
,
err
:=
http
.
NewRequest
(
"POST"
,
request_string
,
bytes
.
NewBuffer
(
b
))
if
err
!=
nil
{
return
output
.
FLB_ERROR
}
req
.
Header
.
Set
(
"Content-Type"
,
"application/octet-stream"
)
req
.
SetBasicAuth
(
user
name
,
passw
d
)
req
.
SetBasicAuth
(
user
,
passwor
d
)
resp
,
err
:=
hc
.
Do
(
req
)
if
err
!=
nil
{
return
output
.
FLB_ERROR
}
/*
* Only allow the following HTTP status:
*
* - 200: OK
* - 201: Created
* - 202: Accepted
* - 203: no authorative resp
* - 204: No Content
* - 205: Reset content
*/
re
:=
regexp
.
MustCompile
(
"[0-9]+"
)
// get only the status code
status_code
:=
re
.
FindAllString
(
resp
.
Status
,
-
1
)
resp_status
,
err
:=
strconv
.
Atoi
(
status_code
[
0
])
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
output
.
FLB_RETRY
}
fmt
.
Println
(
resp
.
Status
)
fmt
.
Println
(
err
)
if
resp_status
<
200
&&
resp_status
>
205
{
return
output
.
FLB_RETRY
}
defer
resp
.
Body
.
Close
()
// Return options:
//
// output.FLB_OK = data have been processed.
// output.FLB_ERROR = unrecoverable error, do not try this again.
// output.FLB_RETRY = retry to flush later.
/*
* Return options:
*
* - output.FLB_OK = data have been processed.
* - output.FLB_ERROR = unrecoverable error, do not try this again.
* - output.FLB_RETRY = retry to flush later.
*/
return
output
.
FLB_OK
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment