How to Install Loki and Promtail use Docker

October 9, 2023

Setup Configuration Directory

Create and navigate to configuration directory:

mkdir grafana_configs
cd grafana_configs

Download Configuration Files

Get Loki and Promtail configuration files:

sudo wget https://raw.githubusercontent.com/grafana/loki/v2.8.0/cmd/loki/loki-local-config.yaml -O loki-config.yaml
sudo wget https://raw.githubusercontent.com/grafana/loki/v2.8.0/clients/cmd/promtail/promtail-docker-config.yaml -O promtail-config.yaml

Run Loki Container

Start Loki with mounted configuration:

docker run -d --name loki \
    -v $(pwd):/mnt/config \
    -p 3100:3100 \
    grafana/loki:2.8.0 \
    --config.file=/mnt/config/loki-config.yaml

Run Promtail Container

Start Promtail with mounted configuration and log access:

docker run -d --name promtail \
    -v $(pwd):/mnt/config \
    -v /var/log:/var/log \
    --link loki \
    grafana/promtail:2.8.0 \
    --config.file=/mnt/config/promtail-config.yaml

Configuration Details

  • Loki Port: 3100
  • Version: 2.8.0
  • Mounted Volumes:
    • Configuration files: /mnt/config
    • System logs: /var/log

Verification Steps

  1. Check container status:
    docker ps | grep 'loki\|promtail'
  2. Verify Loki is accessible:
    curl http://localhost:3100/ready
  3. Check logs for any issues:
    docker logs loki
    docker logs promtail

Next Steps

  • Configure Loki as a data source in Grafana
  • Create log dashboards
  • Set up log alerts
  • Configure retention policies
#Grafana #Loki #Promtail #Docker #Monitoring