⚠️ Production Readiness Warning⚠️
This configuration currently uses in-memory storage for the key-value store (kvstore: { store: inmemory }), which may result in data loss during restarts. This setup is not recommended for production use without proper persistent storage configuration.🤝 Open to Collaboration 🤝
This project welcomes contributions! Feel free to submit pull requests, report issues, or suggest improvements.
This repository contains a Docker Compose configuration for running Grafana Loki, a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus.
Loki is a log aggregation system designed to store and query logs from all your applications and infrastructure. This template is specifically designed to:
- Integrate with external MinIO instances for object storage
- Work alongside Grafana for log visualization
- Provide basic authentication for security
- Support retention policies for log management
The stack consists of:
- Loki: Log aggregation service (port 3100)
- Configured to use external S3-compatible storage (MinIO)
- Basic authentication enabled via Traefik middleware
- TSDB index with 24-hour period rotation
- Object Storage: S3-compatible storage (MinIO) for log chunks
- Local Storage: Temporary index caching at
/loki/indexand/loki/index_cache - KV Store: Currently using in-memory storage (
⚠️ not production-ready)
- Docker and Docker Compose installed
- Access to a MinIO instance (or S3-compatible storage)
- A Grafana instance for log visualization
- The following environment variables configured in your deployment platform (e.g., Coolify):
S3_BUCKET_ENDPOINTS3_BUCKET_NAMES3_BUCKET_ACCESS_KEYS3_BUCKET_ACCESS_SECRETBASIC_AUTH_HASHRETENTION_PERIODSERVICE_FQDN_LOKI_3100
-
Create a new service in Coolify:
- In your Coolify dashboard, create a new "Docker Compose" service
- Copy the contents of
docker-compose.ymlfrom this repository into the empty Docker Compose configuration
-
Configure required environment variables in Coolify:
SERVICE_FQDN_LOKI_3100: Your Loki service domain (e.g.,loki.yourdomain.com)S3_BUCKET_ENDPOINT: MinIO/S3 endpoint URL (e.g.,s3://minio.yourdomain.com:9000)S3_BUCKET_NAME: Name of the bucket for Loki dataS3_BUCKET_ACCESS_KEY: Access key for S3/MinIOS3_BUCKET_ACCESS_SECRET: Secret key for S3/MinIOBASIC_AUTH_HASH: Basic auth hash (see Authentication section below)RETENTION_PERIOD: Log retention period (e.g.,744hfor 31 days)
-
Deploy the stack:
- Click "Deploy" in Coolify to start the service
- Wait for health checks to pass
-
Configure Grafana:
- Add Loki as a data source in Grafana
- Use the URL:
http://<username>:<password>@loki:3100 - Or configure basic auth in Grafana's data source settings
The BASIC_AUTH_HASH environment variable is used for basic authentication. Generate it using:
htpasswd -nbB username passwordImportant: The generated hash may contain special characters that need to be properly escaped. You might need to hardcode the value directly in your environment configuration to avoid auto-escaping issues.
Example:
htpasswd -nbB admin mypassword
# Output: admin:$2y$05$abcdefghijklmnopqrstuvwxyz...Current configuration uses:
- Object Storage: External S3/MinIO for log chunks
- Local Cache: Temporary index storage
- KV Store: In-memory (
⚠️ not persistent)
For production use, consider:
- Configuring a persistent KV store (e.g., Consul, etcd)
- Setting up proper backup strategies
- Implementing high availability configurations
The RETENTION_PERIOD variable controls how long logs are retained. Format examples:
24h- 24 hours7d- 7 days744h- 31 days
The service includes health checks that:
- Test the
/readyendpoint every 30 seconds - Allow 15 seconds for initial startup
- Retry up to 5 times before marking as unhealthy
loki-data: Local volume for temporary index and cache storage- Configuration is embedded in the compose file for easy deployment
- Add Loki as a data source in Grafana
- Configure the URL with basic auth credentials
- Start exploring your logs with LogQL queries
Configure your log shippers to send logs to:
http://username:password@your-loki-domain:3100/loki/api/v1/push
-
Authentication failures:
- Verify
BASIC_AUTH_HASHis properly escaped - Check Traefik middleware configuration
- Test with curl:
curl -u username:password http://your-loki-domain/ready
- Verify
-
Storage connection issues:
- Verify MinIO/S3 credentials
- Check network connectivity to storage backend
- Ensure bucket exists and has proper permissions
-
Data persistence:
- Remember that KV store is currently in-memory
- Index rebuilds may occur after restarts
- Consider implementing persistent KV store for production
In Coolify:
- View logs through the Coolify dashboard
- Monitor Loki's startup and query performance
- Check for storage connectivity issues
-
In-Memory KV Store: Current configuration uses in-memory storage for the ring KV store, which means:
- State is lost on restart
- Not suitable for multi-instance deployments
- May cause temporary query unavailability after restarts
-
Single Instance: This template runs a single Loki instance
- No high availability
- Limited scalability
- Consider distributed mode for production
- Add persistent KV store configuration (Consul/etcd)
- Multi-instance deployment support
- Automated backup configuration
- Prometheus metrics exposure
- Advanced retention policies per tenant
We welcome contributions to improve this template! Areas of focus:
- 🔧 Production-ready configurations - Help make this suitable for production use
- 📚 Documentation improvements - Better examples and explanations
- 🏗️ Architecture enhancements - Multi-instance support, HA configurations
- 🔐 Security improvements - Enhanced authentication options
- 📦 Integration examples - Promtail, Fluentd, and other log shipper configurations
- Test your changes thoroughly
- Document any new environment variables
- Consider backward compatibility
- Include examples where applicable
This template is provided as-is. Loki itself is licensed under the Apache License 2.0.
For issues related to:
- Loki application: Visit the official Loki documentation
- This Docker setup: Create an issue in this repository
- Coolify deployment: Check the Coolify documentation