Step-by-step guide to monitor logs with Grafana, Loki, and FluentBit #5317
Replies: 5 comments 1 reply
-
|
Attention: It seems that this doesn't work for services deployed via Docker Compose, unfortunately. Does anyone have a clue why, and how to solve it? |
Beta Was this translation helpful? Give feedback.
-
|
Ok, got it! I'll update the first post. |
Beta Was this translation helpful? Give feedback.
-
|
I tried this setup and it works, but I did run into one limitation: Coolify needs to avoid explicit container names so it can generate them dynamically and handle rolling updates properly. Once we add container names for FluentBit → Loki integration, rolling updates are no longer supported, which breaks part of the workflow. |
Beta Was this translation helpful? Give feedback.
-
|
Can I deploy loki and grafana on a different server than the one where I want to configure the log drains? |
Beta Was this translation helpful? Give feedback.
-
|
Works great, thank you. services:
loki:
---
networks:
- log-drains_default
---
networks:
log-drains_default:
name: log-drains_default
external: true |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
After struggling for a while to monitor my Coolify apps using Grafana, I finally made it! Here’s a step-by-step tutorial on how to do it with Loki, Grafana, and FluentBit. I have not find any straightforward instructions, so I hope you find it helpful.
1. Deploy Loki and Grafana Services
Deploy Grafana and Loki in a Docker Compose resource:
Note: Replace the Grafana admin password with a strong one.
2. Configure FluentBit on the Server
Update the FluentBit configuration:
Go to Servers >> your server >> Log Drains.
Paste the following into "Custom FluentBit Configuration". Replace the
Hostvalue with the name of your Loki container.Mark "enabled" and then click save.
3. Connect the Loki Container to the FluentBit Network
Again, replace the Loki container name with yours.
4. Set Environment Variable in Each Service and enable Log Drains
For single Docker resourcers
Define the variable:
In each service container, set the following environment variable:
Go to Advanced >> Drain Logs and activate it.
Restart each container after setting this.
For Docker Compose resourcers
Add this to each service of your docker-compose file:
Redeploy.
5. Access Grafana and Explore Logs
Visit
http://<server_ip>:3000in your browser.Go to Connections >> Data Sources >> Loki. URL:
http://loki-mcs40ccs40cmcs40ccs40c:3100. Save and Test.Go to Connections >> Data Sources >> Loki >> Explore and view your logs.
6. Troubleshooting
Check the FluentBit logs by running:
If the logs appear correctly, everything is working and you can now create dashboards to monitor your application logs.
Beta Was this translation helpful? Give feedback.
All reactions