bashadvanced
Prometheus Monitoring Setup
Docker Compose setup for Prometheus with Grafana, node exporter, and alerting rules.
bashPress ⌘/Ctrl + Shift + C to copy
# docker-compose.monitoring.yml
version: '3.8'
services:
prometheus:
image: prom/prometheus:latest
ports:
- '9090:9090'
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./alerts.yml:/etc/prometheus/alerts.yml:ro
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=30d'
restart: unless-stopped
grafana:
image: grafana/grafana:latest
ports:
- '3001:3000'
environment:
GF_SECURITY_ADMIN_PASSWORD: admin
volumes:
- grafana-data:/var/lib/grafana
depends_on:
- prometheus
restart: unless-stopped
node-exporter:
image: prom/node-exporter:latest
ports:
- '9100:9100'
restart: unless-stopped
volumes:
prometheus-data:
grafana-data:
# prometheus.yml
# global:
# scrape_interval: 15s
# rule_files:
# - alerts.yml
# scrape_configs:
# - job_name: 'node'
# static_configs:
# - targets: ['node-exporter:9100']
# - job_name: 'app'
# static_configs:
# - targets: ['host.docker.internal:3000']Use Cases
- Infrastructure monitoring with metrics collection
- Setting up dashboards for application observability
- Alerting on system performance thresholds
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
typescriptintermediate
Health Check Endpoint with Dependency Checks
Express health check endpoint that verifies database, Redis, and disk connectivity with status reporting.
Best for: Kubernetes liveness and readiness probes
#health-check#monitoring
typescriptadvanced
Application Metrics Collection
Collect and expose application metrics like request counts, latency histograms, and custom gauges.
Best for: Prometheus metrics endpoint
#nodejs#monitoring
bashbeginner
Docker Health Check Patterns
Docker health check configurations for web apps, databases, and message queues with restart policies.
Best for: Ensuring container readiness before traffic routing
#docker#healthcheck
bashbeginner
Prometheus Advanced
DevOps practice: prometheus-advanced
Best for: infrastructure management
#devops#infrastructure