Search code examples
mongodbdockernginxdockerhubfluent-bit

How to store fluent-bit logs into MongoDB


I am using the fluent-bit docker image in order to collect logs from my NGINX app. I've been doing some testing and it seems to be working ok.

I run the fluent-bit image like this:

docker run -p 127.0.0.1:24224:24224 fluent/fluent-bit:1.5 /fluent-bit/bin/fluent-bit -i forward -o stdout -p format=json_lines -f 1

I send an echo message to my fluent-bit container like this:

docker run --log-opt fluentd-address=172.17.0.2:24224 --log-driver=fluentd -t ubuntu echo "Testing a log message"

And I am receiving these messages:

{"date":1652800995,"container_id":"518de741584ed669e3d9836c2768db0f8131cb6880d5baf6c532734f3d8722b5","container_name":"/wizardly_mirzakhani","source":"stdout","log":"Testing a log message\r"}

The question is ¿how can I store these messages into a MongoDB collection? I couldn't found too much information in Docker Hub and GitHub in order to config fluent-bit with Mongo or Elasticsearch.

Thanks for your help in advance.


Solution

  • Fluent-bit doesn't have an official plugin to write to MongoDB directly as of now.

    • For now you can push the events from fluent-bit -> fluentd and use Mongo output Plugin.