Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fluentbit-plugin-wendelin
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
nexedi
fluentbit-plugin-wendelin
Commits
7e310ee2
Commit
7e310ee2
authored
Dec 02, 2022
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin: use certificate instead of user/password
parent
c5f4e4dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
src/configuration-files/flb.conf.in
src/configuration-files/flb.conf.in
+2
-2
src/fluentbit_wendelin.go
src/fluentbit_wendelin.go
+13
-7
No files found.
src/configuration-files/flb.conf.in
View file @
7e310ee2
...
...
@@ -10,8 +10,8 @@
name fluentbit_wendelin
match *
streamtool_uri %WENDELIN_URL%
user %WENDELIN_USER
%
password %WENDELIN_PWD
%
key %KEY
%
certificate %CERTIFICATE
%
buffer_type memory
flush_interval 60s
disable_retry_limit true
...
...
src/fluentbit_wendelin.go
View file @
7e310ee2
...
...
@@ -22,16 +22,16 @@ func FLBPluginRegister(def unsafe.Pointer) int {
// plugin (context) pointer to fluentbit context (state/ c code)
func
FLBPluginInit
(
plugin
unsafe
.
Pointer
)
int
{
streamtool_uri
:=
output
.
FLBPluginConfigKey
(
plugin
,
"streamtool_uri"
)
user
:=
output
.
FLBPluginConfigKey
(
plugin
,
"user
"
)
password
:=
output
.
FLBPluginConfigKey
(
plugin
,
"password
"
)
key
:=
output
.
FLBPluginConfigKey
(
plugin
,
"key
"
)
certificate
:=
output
.
FLBPluginConfigKey
(
plugin
,
"certificate
"
)
buffer_type
:=
output
.
FLBPluginConfigKey
(
plugin
,
"buffer_type"
)
flush_interval
:=
output
.
FLBPluginConfigKey
(
plugin
,
"flush_interval"
)
disable_retry_limit
:=
output
.
FLBPluginConfigKey
(
plugin
,
"disable_retry_limit"
)
reference
:=
output
.
FLBPluginConfigKey
(
plugin
,
"reference"
)
dict
:=
map
[
string
]
string
{
"streamtool_uri"
:
streamtool_uri
,
"
user"
:
user
,
"
password"
:
password
,
"
key"
:
key
,
"
certificate"
:
certificate
,
"buffer_type"
:
buffer_type
,
"flush_interval"
:
flush_interval
,
"disable_retry_limit"
:
disable_retry_limit
,
...
...
@@ -81,10 +81,17 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
//body result
// content type "application/octet-stream"
var
b
=
[]
byte
(
result
)
uri
:=
fmt
.
Sprintf
(
"%s/ingest?reference=%s"
,
dict
[
"streamtool_uri"
],
dict
[
"reference"
])
cert
,
err
:=
tls
.
LoadX509KeyPair
(
dict
[
"certificate"
],
dict
[
"key"
])
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"server: loadkey %s"
,
err
.
Error
())
}
uri
:=
fmt
.
Sprintf
(
"%s/uploadComputerFileMetadata?reference=%s"
,
dict
[
"streamtool_uri"
],
dict
[
"reference"
])
client
:=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
,
Certificates
:
[]
tls
.
Certificate
{
cert
},
},
},
}
req
,
err
:=
http
.
NewRequest
(
"POST"
,
uri
,
bytes
.
NewReader
(
b
))
...
...
@@ -92,7 +99,6 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
fmt
.
Fprintf
(
os
.
Stderr
,
"Got error %s"
,
err
.
Error
())
return
output
.
FLB_RETRY
}
req
.
SetBasicAuth
(
dict
[
"user"
],
dict
[
"password"
])
req
.
Header
.
Set
(
"Content-Type"
,
"application/octet-stream"
)
rsp
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
...
...
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