DEV Community

Cover image for Deploying Grafana Metrics Visualization Platform on Ubuntu 24.04
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya • Originally published at docs.vultr.com

Deploying Grafana Metrics Visualization Platform on Ubuntu 24.04

Grafana is an open-source dashboard and visualization platform that connects to dozens of data sources (Prometheus, Loki, Mimir, Tempo, PostgreSQL, and more) and renders metrics, logs, and traces in interactive panels. This guide deploys Grafana using Docker Compose with Traefik handling automatic HTTPS. By the end, you'll have Grafana running with a persistent data store and a secured admin login at your domain.


Set Up the Directory Structure

1. Create the project directory structure:

$ mkdir -p ~/grafana-monitoring/grafana-data
$ cd ~/grafana-monitoring
Enter fullscreen mode Exit fullscreen mode

2. Set ownership for the Grafana data directory:

$ sudo chown -R 472:472 grafana-data
Enter fullscreen mode Exit fullscreen mode

3. Create the environment file:

$ nano .env
Enter fullscreen mode Exit fullscreen mode
DOMAIN=grafana.example.com
LETSENCRYPT_EMAIL=admin@example.com
GF_ADMIN_PASSWORD=changeme
Enter fullscreen mode Exit fullscreen mode

Deploy with Docker Compose

1. Create the Docker Compose manifest:

$ nano docker-compose.yaml
Enter fullscreen mode Exit fullscreen mode
services:
  traefik:
    image: traefik:v3.6
    container_name: traefik
    command:
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
      - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    restart: unless-stopped

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    hostname: grafana
    expose:
      - "3000"
    volumes:
      - "./grafana-data:/var/lib/grafana"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=${GF_ADMIN_PASSWORD}
      - GF_SERVER_ROOT_URL=https://${DOMAIN}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.grafana.entrypoints=websecure"
      - "traefik.http.routers.grafana.tls.certresolver=letsencrypt"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"
    restart: unless-stopped

volumes:
  letsencrypt:
Enter fullscreen mode Exit fullscreen mode

2. Start the services:

$ docker compose up -d
Enter fullscreen mode Exit fullscreen mode

3. Verify the services are running:

$ docker compose ps
Enter fullscreen mode Exit fullscreen mode

4. View the logs:

$ docker compose logs
Enter fullscreen mode Exit fullscreen mode

Access Grafana

Open https://grafana.example.com in a browser. Sign in with:

  • Username: admin
  • Password: the value of GF_ADMIN_PASSWORD from .env

Navigate to Connections → Data sources to wire in Prometheus, Loki, or other backends.


Next Steps

Grafana is running and served securely over HTTPS. From here you can:

  • Add Prometheus, Loki, Mimir, or Tempo as data sources
  • Import community dashboards or build custom ones for your stack
  • Configure alerting rules and notification channels

For the full guide with additional tips, visit the original article on Vultr Docs.

Top comments (0)