David Chou @ Golang Taipei
david74.chou @ facebook
david74.chou @ medium
david7482 @ github
//export FLBPluginRegister
func FLBPluginRegister(def unsafe.Pointer) int {
// Gets called only once when the .so is loaded.
return output.FLBPluginRegister(def, "gstdout", "Stdout GO!")
}
//export FLBPluginInit
func FLBPluginInit(plugin unsafe.Pointer) int {
// Gets called once for each instance you have configured.
param := output.FLBPluginConfigKey(plugin, "param")
return output.FLB_OK
}
//export FLBPluginFlushCtx
func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int {
// Gets called once for each message to be written to an instance.
}
//export FLBPluginExit
func FLBPluginExit() int {
// Gets called on teardown.
return output.FLB_OK
}
func main() {
}# Build fluent bit go plugin
$ go build -o plugin.so -buildmode c-shared plugin.go
# Run Fluent Bit with the new plugin
$ fluent-bit -e plugin.so -i cpu -o gstdout# Build fluent bit go plugin
$ go build -o plugin.so -buildmode c-shared plugin.go
# Run Fluent Bit with the new plugin
$ fluent-bit -e plugin.so -i cpu -o gstdoutSupport a wide-array of AWS Services as log destinations
Require no additional configuration beyond ECS Task Definition
Use Open Source for extensibility: Fluent Bit, Fluentd
Facilitate partner integration
A Fluent Bit image with AWS Go plugins
amazon/aws-for-fluent-bit on Docker Hub
Regional public images hosted on ECR
$ cat entrypoint.sh
exec /fluent-bit/bin/fluent-bit \
-e /fluent-bit/firehose.so \
-e /fluent-bit/cloudwatch.so \
-e /fluent-bit/kinesis.so \
-c /fluent-bit/etc/fluent-bit.conf{
"essential": true,
"image": "amazon/aws-for-fluent-bit:latest",
"name": "log_router",
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"enable-ecs-log-metadata": "true",
"config-file-type": "file",
"config-file-value": "/json.conf"
}
}
},
{
"essential": true,
"image": "<your-app-image>",
"name": "app",
"logConfiguration": {
"logDriver": "awsfirelens",
"options": {
"Name": "cloudwatch",
"region": "us-west-2",
"log_group_name": "firelens-fluent-bit",
"log_stream_prefix": "from-fluent-bit",
"include-pattern": "[Ee]rror"
}
}
}[INPUT]
Name forward
unix_path /var/run/fluent.sock
[INPUT]
Name forward
Listen 0.0.0.0
Port 24224
[FILTER]
Name grep
Match app-firelens*
Regex log [Ee]rror
[FILTER]
Name record_modifier
Match *
Record ecs_cluster firelens-example
Record ecs_task_arn arn:aws:ecs:us-west-2:0123456789:task/1111
Record ecs_task_definition firelens-example-session:5
@INCLUDE /json.conf
[OUTPUT]
Name cloudwatch
Match app-firelens*
region us-west-2
log_group_name firelens-fluent-bit
log_stream_prefix from-fluent-bit
ECS task defition
fluent-bit.conf
$ ls -lh bin/fluent-bit *.so
root root 18M Dec 12 23:14 bin/fluent-bit
root root 24M Jan 08 20:50 cloudwatch.so
root root 26M Dec 12 23:04 firehose.so
root root 26M Dec 12 23:03 kinesis.so