Visualization with Grafana: Making Metrics Beautiful and Useful
The Dashboard That Changed Everything
Setting Up Grafana with Prometheus
Installation with Docker Compose
# docker-compose.yml
version: '3.8'
services:
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana-data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
depends_on:
- prometheus
volumes:
prometheus-data:
grafana-data:Adding Prometheus as a Data Source
Building Your First Dashboard
Panel 1: Request Rate
Panel 2: Error Rate
Panel 3: Response Time Percentiles
Panel 4: Status Code Breakdown
Panel 5: Memory Usage
Panel 6: Active Database Connections
My Production API Dashboard Layout
Dashboard Variables for Flexibility
Example: Environment Variable
Example: Endpoint Variable
Example: Time Range Variable
Essential Dashboard Panels for TypeScript APIs
Traffic Panel
Error Tracking
Performance Metrics
Resource Usage
Database Metrics
Advanced Visualization Techniques
Heatmaps for Latency Distribution
Table for Top Endpoints
Metric
Query
Alert State Panel
Dashboard Organization Strategy
For Developers (Detailed)
For Operations (Overview)
For Management (Executive)
Dashboard JSON Export/Import
Dashboard Best Practices from Experience
1. Use Consistent Time Ranges
2. Set Meaningful Y-Axis Ranges
3. Use Units
4. Color Code Thresholds
5. Add Panel Descriptions
6. Link to Related Dashboards
7. Use Annotations for Deploys
My Essential Dashboard Collection
1. API Performance Dashboard
2. Application Health Dashboard
3. Database Dashboard
4. Business Metrics Dashboard
Grafana Alerting
Performance Tips
1. Limit Time Series
2. Use Recording Rules
3. Adjust Refresh Rate
4. Use Dashboard Caching
Key Takeaways
PreviousAlerting with Prometheus: Getting Woken Up Only When It MattersNextPrometheus Best Practices: Lessons from Production
Last updated