I am trying to use fluent-bit with Docker Swarm, is it possible to use a unix socket when you use fluentd as a input?
[INPUT]
Name forward
Listen unix:///path/to/fluentd.sock
{
"log-driver": "fluentd",
"log-opts": {
"fluentd-address": "unix:///path/to/fluentd.sock"
}
}
What I am trying to do is to create a fluent-bit service deployed in a global mode.
In this way, I will have a fluent-bit container for each node of the Docker swarm and I can simply bind the socket to the localhost.
Thanks for reaching out. It's not implemented now but not too hard to do. I will make sure to have something functional within < ~2 weeks.
Thanks @edsiper, I'll be happy to test this new feature.
Hi @edsiper, do you have some updates about this feature?
Enhancement implemented on GIT master (upcoming 0.13)
$ docker run --log-driver=fluentd --log-opt "fluentd-address=unix:///tmp/fluent-bit.sock" -ti busybox echo test
$ bin/fluent-bit -i forward -p unix_path=/tmp/fluent-bit.sock -o stdout -f 1
Fluent-Bit v0.13.0
Copyright (C) Treasure Data
[2018/02/19 14:08:44] [ info] [engine] started
[2018/02/19 14:08:44] [ info] [in_fw] listening on unix:///tmp/fluent-bit.sock
[0] 6ef4e5ecd707: [1519070935.000000000, {"container_id"=>"6ef4e5ecd7078dd53ad35a1fa397516f20c19507728b8fdb2b122cf68f5843ff", "container_name"=>"/cranky_torvalds", "source"="}]tdout", "log"=>"test
@edsiper I just had a play with this on master, and my output looks wonkey:
sven@y260:~/src/fluent-bit/build$ ./bin/fluent-bit -i forward -p unix_path=/tmp/fluent-bit.sock -o stdout -f 1
Fluent-Bit v0.13.0
Copyright (C) Treasure Data
[2018/02/23 13:43:22] [ info] [engine] started
[2018/02/23 13:43:22] [ info] [in_fw] listening on unix:///tmp/fluent-bit.sock
", "container_id"=>"58251262ef87b648abe4dfa23da4c425388c3e08a2842a8d478b91e8fc1ee375", "container_name"=>"/reverent_northcutt"}]
", "container_id"=>"b4506c57ce03e74a7917c6ee96660ff7948de8f1f6bd82a76a6da5a574882492"}]=>"stdout", "log"=>"test
The output looks like that because it contains a \r, try file output plugin
with json format and it will be ok
On Feb 22, 2018 21:44, "Sven Dowideit" notifications@github.com wrote:
@edsiper https://github.com/edsiper I just had a play with this on
master, and my output looks wonkey:sven@y260:~/src/fluent-bit/build$ ./bin/fluent-bit -i forward -p unix_path=/tmp/fluent-bit.sock -o stdout -f 1
Fluent-Bit v0.13.0
Copyright (C) Treasure Data[2018/02/23 13:43:22] [ info] [engine] started
[2018/02/23 13:43:22] [ info] [in_fw] listening on unix:///tmp/fluent-bit.sock", "container_id"=>"58251262ef87b648abe4dfa23da4c425388c3e08a2842a8d478b91e8fc1ee375", "container_name"=>"/reverent_northcutt"}]
", "container_id"=>"b4506c57ce03e74a7917c6ee96660ff7948de8f1f6bd82a76a6da5a574882492"}]=>"stdout", "log"=>"test—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/fluent/fluent-bit/issues/388#issuecomment-367901381,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWkNvUoew-Ya3wgDk7ZKzmxqRgYQdUwks5tXjQqgaJpZM4Pp4__
.
I suggest to update this documentation page:
https://fluentbit.io/documentation/0.13/input/forward.html
adding "unix_path" in the "Configuration parameters" table.
Here's a minimal config that "works on my box":
[INPUT]
Name forward
unix_path /tmp/fluent-bit.sock
Here's my set-up with fluent-bit running as a global service inside a docker swarm, hoping it could help.
Step 1: create a dedicated volume to host fluent-bit UNIX socket on every docker swarm node:
sudo su -
mkdir /tmp/fluent-bit
chmod 777 /tmp/fluent-bit/
chmod o+t /tmp/fluent-bit/
Step 2: create your own fluent-bit docker image with the following fluent-bit.conf file:
[SERVICE]
Flush 1
Daemon Off
Log_Level debug
Log_File /fluent-bit/log/fluent-bit.log
Parsers_File parsers.conf
Parsers_File parsers_java.conf
[INPUT]
Name forward
unix_path /tmp/fluent-bit/sock
[OUTPUT]
Name file
Match *
Path /tmp/output.txt
Use command docker build -t fluent/fluent-bit:0.13-unix-sock ./ as explained in image documentation
Step 3: create file fluent-bit-compose.yml as below:
version: "3.3"
services:
forwarder:
image: fluent/fluent-bit:0.13-unix-sock
deploy:
mode: global
volumes:
- /tmp/fluent-bit:/tmp/fluent-bit
Step 4: deploy it as stack "log": docker stack deploy -c fluent-bit-compose.yml log
If everything is OK, you will have a running service (and container) on every swarm node.
Step 5: check fluent-bit is up and running:
tiian@ubuntu001:~/fluent-bit/0.13$ ls -la /tmp/fluent-bit/
total 8
drwxrwxrwt 2 root root 4096 Aug 24 08:02 .
drwxrwxrwt 9 root root 4096 Aug 24 08:04 ..
srwxr-xr-x 1 root root 0 Aug 24 08:02 sock
tiian@ubuntu001:~/fluent-bit/0.13$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8c39967abdd5 fluent/fluent-bit:0.13-unix-sock "/fluent-bit/bin/flu…" 2 minutes ago Up 2 minutes 2020/tcp log_forwarder.l3yzhsv1e32rbaa7gpcn4wczf.1xjg6x1gad1uxnsnmn8ejenvp
tiian@ubuntu001:~/fluent-bit/0.13$ docker exec -ti 8c39967abdd5 bash
root@8c39967abdd5:/# cat /fluent-bit/log/fluent-bit.log
[2018/08/24 08:02:26] [ info] [engine] started (pid=1)
[2018/08/24 08:02:26] [ info] [in_fw] listening on unix:///tmp/fluent-bit/sock
[2018/08/24 08:02:26] [debug] [router] input=forward.0 'DYNAMIC TAG'
Step 6: send a log message from another container (in the same host):
tiian@ubuntu001:~$ docker run --log-driver=fluentd --log-opt "fluentd-address=unix:///tmp/fluent-bit/sock" -ti busybox echo test
test
Step 7: check the log message (from inside fluent-bit container, see step 5):
root@8c39967abdd5:/# cat /fluent-bit/log/fluent-bit.log
[2018/08/24 08:02:26] [ info] [engine] started (pid=1)
[2018/08/24 08:02:26] [ info] [in_fw] listening on unix:///tmp/fluent-bit/sock
[2018/08/24 08:02:26] [debug] [router] input=forward.0 'DYNAMIC TAG'
[2018/08/24 08:07:48] [debug] [input forward.0] [mem buf] size = 140
[2018/08/24 08:07:48] [debug] [task] created task=0x7f691d24b0e0 id=0 OK
[2018/08/24 08:07:48] [debug] [task] destroy task=0x7f691d24b0e0 (task_id=0)
[2018/08/24 08:07:48] [debug] [dyntag forward.0] 0x7f691d29b060 destroy (tag=bae234087c7c, bytes=140)
root@8c39967abdd5:/# cat /tmp/output.txt
bae234087c7c: [1535098068.000000, {"log":"test\r", "container_id":"bae234087c7c14fe7156ab620950de338b657a0674d94f4364719e4a80685883", "container_name":"/serene_easley", "source":"stdout"}]
You can deploy a fluent-bit forwarder in all the nodes of a swarm cluster and collect logging from docker containers that send logs to a dedicated UNIX socket /tmp/fluent-bit/sock.
Of course, fluent-bit forwarders can send collected logs to any supported destination, /tmp/output.txt is just for the sake of easyness.
Please update the docs on in_forward