Prometheus Monitoring
Overview
Prometheus provides metrics collection and alerting for comprehensive application monitoring. This skill should be invoked when collecting application metrics, monitoring performance, or setting up observability.
Core Principles
- Metric Types: Counters, Gauges, Histograms, Summaries
- Pull Model: Prometheus scrapes /metrics endpoints
- Labels: Use labels for dimensional data
- Alerts: Define alert rules for anomalies
Preparation Checklist
- Set up Prometheus server
- Choose client library for your language
- Plan metrics and labels
- Design alerting rules
Step-by-Step Process
- Add Library: Install Prometheus client
- Define Metrics: Create counters, gauges, histograms
- Expose: Implement /metrics endpoint
- Configure: Set up Prometheus scrape config
- Visualize: Create Grafana dashboards
- Alert: Define alerting rules
Do's and Don'ts
- ✅ Do use appropriate metric types
- ✅ Do add meaningful labels
- ✅ Do set appropriate histogram buckets
- ❌ Don't use high-cardinality labels
- ❌ Don't expose sensitive data
- ❌ Don't forget to instrument code
Anti-Patterns
- Cardinality Explosion: Too many label values
- Missing Metrics: Not instrumenting critical paths
- No Alerts: Setting up Prometheus without alerting
- Sensitive Exposure: Exposing internal metrics