A complete observability solution combining Grafana for visualization and Loki for log aggregation, optimized for DigitalOcean App Platform.
- Grafana 11.4.0 - Modern, feature-rich dashboarding and visualization
- Loki 3.3.2 - Cost-effective log aggregation with label-based indexing
- PostgreSQL Database - Persistent storage for Grafana dashboards and users
- DigitalOcean Spaces - S3-compatible object storage for logs
- Internal Networking - Secure communication between services
- Health Checks - Automatic monitoring and restart
- One-Click Deploy - Deploy directly from this repository
┌─────────────────────────────────────────────┐
│ DigitalOcean App Platform │
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ Loki │◄────────│ Grafana │ │
│ │ :3100 │ │ :3000 │◄────────┼─── Users (HTTPS)
│ └────┬─────┘ └────┬─────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌──────────────┐ │
│ │ │ PostgreSQL │ │
│ │ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ DO Spaces │ │
│ │ (Log Storage) │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────┘
- DigitalOcean Account with billing enabled
- DigitalOcean Spaces bucket for log storage
- Spaces API Keys (access key and secret key)
Click the Deploy to DO button above, then:
- Connect your GitHub account (if prompted)
- Configure environment variables:
SPACES_ENDPOINT- Your Spaces region endpoint (e.g.,nyc3.digitaloceanspaces.com)SPACES_BUCKET- Name of your Spaces bucketSPACES_ACCESS_KEY- Your Spaces access key (mark as SECRET)SPACES_SECRET_KEY- Your Spaces secret key (mark as SECRET)GF_SECURITY_ADMIN_PASSWORD- Strong password for Grafana admin (mark as SECRET)GF_SECURITY_SECRET_KEY- Random secret key for Grafana (mark as SECRET)
- Click "Deploy"
- Wait 5-10 minutes for deployment to complete
- Access your Grafana instance at the provided App URL
- Go to DigitalOcean Control Panel → Spaces
- Click "Create Bucket"
- Choose a region (e.g., NYC3, SFO3)
- Name your bucket (e.g.,
my-company-loki-logs) - Set permissions to Private
- Click "Create Bucket"
- Go to API → Spaces Keys
- Click "Generate New Key"
- Name it (e.g., "Loki Storage")
- Save both the Access Key and Secret Key immediately (you won't see the secret again)
# Generate admin password
openssl rand -base64 32
# Generate secret key
openssl rand -base64 64- Purpose: Visualization, dashboarding, and alerting
- Port: 3000 (HTTPS via App Platform)
- Database: PostgreSQL for dashboards and user management
- Datasource: Pre-configured Loki connection
- Health Check:
/api/health
- Purpose: Log aggregation and querying
- Port: 3100 (internal only)
- Storage: DigitalOcean Spaces (S3-compatible)
- Mode: Monolithic (good for up to 20GB/day)
- Health Check:
/ready
- Purpose: Grafana state (dashboards, users, sessions)
- Engine: PostgreSQL 16
- Size: Development database (can upgrade to production)
-
How to Use - Complete getting started guide
- First login and setup
- Sending logs to Loki
- Creating dashboards
- Setting up alerts
- Common LogQL queries
-
Environment Variables - All configuration options
- Required variables
- Optional settings
- Security best practices
- Configuration examples
-
Production Hardening - Production deployment guide
- Security hardening
- Performance tuning
- Scaling strategies
- Cost optimization
- Backup and recovery
-
Version Information - Component versions and upgrade guide
- Current versions
- Update policy
- Upgrade procedures
| Component | Instance | Cost |
|---|---|---|
| Loki | professional-xs (1 vCPU, 2GB RAM) | $12/mo |
| Grafana | professional-xs (1 vCPU, 2GB RAM) | $12/mo |
| PostgreSQL | db-s-1vcpu-1gb (Dev or Managed) | $7-15/mo |
| Spaces | 250GB storage + 1TB transfer | $5/mo |
| Total | $36-44/mo |
For higher log volumes or traffic:
| Log Volume | Configuration | Est. Cost |
|---|---|---|
| <20GB/day | Default (2x professional-xs) | $36-44/mo |
| 20-100GB/day | Loki: professional-s, Grafana: professional-xs | $48-56/mo |
| 100-500GB/day | Loki: professional-m, Grafana: professional-s | $96-104/mo |
| >500GB/day | Simple Scalable mode (3+ services) | $150+/mo |
Note: Spaces costs scale with usage ($0.02/GB/month for storage over 250GB).
Loki doesn't collect logs automatically. You need to send logs using an agent:
# promtail-config.yaml
clients:
- url: https://your-app.ondigitalocean.app/loki/api/v1/push
# Or internal: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*logSee examples/promtail/ for complete setup.
loki.write "default" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}See examples/alloy/ for complete setup.
services:
myapp:
logging:
driver: loki
options:
loki-url: "http://loki:3100/loki/api/v1/push"- Navigate to your App URL:
https://your-app-name.ondigitalocean.app - Login with:
- Username:
admin - Password: (value you set for
GF_SECURITY_ADMIN_PASSWORD)
- Username:
- Change your password immediately via Profile → Change Password
Once logs are flowing to Loki, try these queries in Grafana's Explore page:
# View all logs
{job="myapp"}
# Filter by content
{job="myapp"} |= "error"
# Regex match
{job="myapp"} |~ "error|warning"
# Count over time
count_over_time({job="myapp"}[5m])
# Rate of errors
rate({job="myapp"} |= "error" [5m])
# Parse JSON logs
{job="myapp"} | json | level="error"
- Aggregate logs from all your applications
- Filter by service, environment, or region
- Track error rates and patterns
- Set up alerts for critical issues
- Live tail logs in real-time
- Search historical logs
- Correlate errors across services
- Trace request flows
- Centralized audit logging
- Retain logs for compliance (configurable retention)
- Alert on suspicious patterns
- Secure storage with encryption
- Service health monitoring
- Performance analysis
- Incident response
- Post-mortem analysis
- Ephemeral local storage: Loki uses 2GB ephemeral disk for index caching
- Single instance: Monolithic mode runs single Loki instance
- Log volume: Best for <20GB/day (can scale to Simple Scalable mode)
- No automatic log collection: Requires log agent setup
- >500GB logs/day: Consider Grafana Cloud or self-hosted Kubernetes
- Multi-region: Requires custom setup with multiple deployments
- High availability: Requires Simple Scalable or Microservices mode
Grafana supports multiple instances with shared PostgreSQL:
services:
- name: grafana
instance_count: 2
# Or enable autoscalingFor >20GB/day, upgrade to Simple Scalable deployment mode:
- Separate read, write, and backend services
- Independent scaling of each component
- See
examples/simple-scalable/for configuration
- Check Loki health:
curl https://your-app.app/loki/ready - Verify Spaces credentials are correct
- Check log agent configuration (Promtail/Alloy)
- Review Loki logs:
doctl apps logs <app-id> --component loki
- Verify
GF_SECURITY_ADMIN_PASSWORDis set - Check for typos in username/password
- Review Grafana logs:
doctl apps logs <app-id> --component grafana
- Ensure PostgreSQL database is running
- Verify
${db.DATABASE_URL}is being populated - Check database firewall/trusted sources settings
- Verify Spaces bucket exists in specified region
- Check Spaces keys have read/write permissions
- Ensure
SPACES_ENDPOINTmatches bucket region - Test access with AWS CLI or similar tool
- Documentation: See
docs/folder - Issues: GitHub Issues
- Community: Grafana Community Forums
- App Platform: DigitalOcean Community
Contributions are welcome! Please:
- Fork this repository
- Create a feature branch
- Make your changes
- Submit a pull request
When reporting issues, please include:
- App Platform logs
- Environment variable configuration (sanitized)
- Steps to reproduce
- Expected vs actual behavior
This repository is provided as-is under the MIT License. Grafana and Loki are licensed under AGPL-3.0.
- Grafana Labs for Grafana and Loki
- DigitalOcean for App Platform
- Community contributors for feedback and improvements
- Grafana Documentation: https://grafana.com/docs/grafana/latest/
- Loki Documentation: https://grafana.com/docs/loki/latest/
- LogQL Guide: https://grafana.com/docs/loki/latest/logql/
- App Platform Docs: https://docs.digitalocean.com/products/app-platform/
- DigitalOcean Spaces: https://docs.digitalocean.com/products/spaces/
Ready to get started? Click the Deploy to DO button at the top of this page!