DEV Community

Cover image for Send fluent bit collected logs to Seq
Minhaz
Minhaz

Posted on • Originally published at github.com

Send fluent bit collected logs to Seq

Here I will setup fluent-bit and seq both with docker and push logs through fluent bit to to seq.
I will also show how to setup fluent bit and seq with docker.

Setup a docker network for the containers

docker network create fluent-bit_seq
Enter fullscreen mode Exit fullscreen mode

Setting up Seq

At first setup a hashed password to be used

PH=$(echo 'seqPass%%' | docker run --rm -i datalust/seq config hash)
Enter fullscreen mode Exit fullscreen mode

Make sure that the password variable is ok

echo $PH
Enter fullscreen mode Exit fullscreen mode

Run the container

docker run --name seq -d --network fluent-bit_seq \
    -p8080:80 --restart unless-stopped \
    -e ACCEPT_EULA=Y -e SEQ_FIRSTRUN_ADMINPASSWORDHASH="$PH" \
    datalust/seq
Enter fullscreen mode Exit fullscreen mode

Now browse to localhost:8080 and login into Seq using username=admin password=seqPass%%

Logging into seq

After logging into seq

Setting up Fluent Bit

Designate a folder where you'll store the fluent bit configs. In my case the directory is D:/fluent-bit

Set the directory where fluent bit's config will come from

export sharedFolder=/var/fluent-bit_seq
Enter fullscreen mode Exit fullscreen mode

Start a temporary container to copy default configs from

docker run -d --rm --name temp cr.fluentbit.io/fluent/fluent-bit
Enter fullscreen mode Exit fullscreen mode

Copy the configs to your designated folder

docker cp temp:/fluent-bit/etc/ $sharedFolder
Enter fullscreen mode Exit fullscreen mode

Stop the temporary container

docker stop temp
Enter fullscreen mode Exit fullscreen mode

Now start fluent bit with the config folder mounted as a volume

docker run -dti --name fluent-bit --network fluent-bit_seq \
    -v $sharedFolder:/fluent-bit/etc \
      cr.fluentbit.io/fluent/fluent-bit
Enter fullscreen mode Exit fullscreen mode

See what is in the shared folder directory

By default fluent bit is configured to output to std out. So see docker log to see what fluent bit is logging.

docker logs fluent-bit
Enter fullscreen mode Exit fullscreen mode

Fluent bit logs

Configuring Fluent Bit to send logs to Seq

Go to the fluent bit configuration directory and search for this section

# fluent-bit.conf
[OUTPUT]
    name  stdout
    match *
Enter fullscreen mode Exit fullscreen mode

Replace this section with this and save

# fluent-bit.conf
[OUTPUT]
    Name             http
    Match            *
    Host             seq
    Port             5341
    URI              /api/events/raw?clef
    Format           json_lines
    Json_date_key    @t
    Json_date_format iso8601
    Log_response_payload False
Enter fullscreen mode Exit fullscreen mode

Now restart the fluent bit container for the changes to take effect.

docker restart fluent-bit
Enter fullscreen mode Exit fullscreen mode

after pasting the config

Now browse to localhost:8080 and login into Seq using username=admin password=seqPass%% and see that the logs are being written into Seq

Fluent bit is sending message to seq

Thanks for reading, Happy Tinkering :)

References

  1. Github repo

Top comments (0)