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
2ff1f2ca
Commit
2ff1f2ca
authored
Jan 17, 2018
by
Eteri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fluentbit: initial commit
parent
7fcabfa0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
out_http.go
out_http.go
+102
-0
No files found.
out_http.go
0 → 100644
View file @
2ff1f2ca
package
main
import
"github.com/fluent/fluent-bit-go/output"
import
(
"fmt"
"unsafe"
"C"
"net/http"
"bytes"
)
// 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!"
)
}
/*
* export FLBPluginInit
* fluentbit will call this
* ctx (context) pointer to fluentbit context (state/ c code)
*/
func
FLBPluginInit
(
ctx
unsafe
.
Pointer
)
int
{
// Retrieve the configuration parameters
user
=
output
.
FLBPluginConfigKey
(
ctx
,
"User"
)
password
=
output
.
FLBPluginConfigKey
(
ctx
,
"Password"
)
uri
=
output
.
FLBPluginConfigKey
(
ctx
,
"Uri"
)
reference
=
output
.
FLBPluginConfigKey
(
ctx
,
"Reference"
)
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
byte_data
[]
byte
byte_data
=
C
.
GoBytes
(
data
,
C
.
int
(
length
))
hc
:=
http
.
Client
{}
req
,
err
:=
http
.
NewRequest
(
"POST"
,
request_string
,
bytes
.
NewBuffer
(
byte_data
))
if
err
!=
nil
{
return
output
.
FLB_ERROR
}
req
.
Header
.
Set
(
"Content-Type"
,
"application/octet-stream"
)
req
.
SetBasicAuth
(
user
,
password
)
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
*/
if
resp
.
Status
<
200
&&
resp
.
Status
>
205
{
return
output
.
FLB_RETRY
}
fmt
.
Println
(
resp
.
Status
)
fmt
.
Println
(
err
)
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
output
.
FLB_OK
}
//export FLBPluginExit
func
FLBPluginExit
()
int
{
return
output
.
FLB_OK
}
func
main
()
{
}
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