How to configure HA setup for Grafana using docker compose

How to configure HA setup for Grafana using docker compose

Prerequisites

  • Docker

  • Docker-compose

  • git installed

  • Fork & clone the code to your local machine.

Breakdown

  • Nginx alpine image will be used as a load balancer.

  • Postgresql 12 will store our data.

Quick Setup

docker-compose up -d

Check container status

docker-compose ps

Go to localhost:8080 on you browser.

Initial sign-in details

password=admin username=admin123

Test

Open Grafana in multiple browsers and check the logs:

docker-compose logs -f grafana1 grafana2

A look at our nginx configuration file nginx.conf:

upstream grafana-HA { 
    server grafana1:3000;     
    server grafana2:3000;   
}

Conclusion:

All the requests are load balanced to server group grafana-HA, nginx applied HTTP load balancing using the round-robin algorithm.

References:

Blog by Lehlogonolo Masubelele