DEV Community

Thesius Code
Thesius Code

Posted on • Originally published at datanest-stores.pages.dev

Monitoring Stack Setup

Monitoring Stack Setup

Complete observability stack with Prometheus, Grafana, Loki, and AlertManager.

One docker compose up to full production monitoring. Stop flying blind.

License: MIT
Docker
Price


What You Get

  • Docker Compose stack: Prometheus, Grafana, AlertManager, Loki, Promtail, node-exporter, cAdvisor
  • 30+ alert rules covering infrastructure, containers, and application metrics
  • 3 Grafana dashboards: Node overview, Docker containers, Application metrics
  • Log aggregation with Loki + Promtail (search logs in Grafana)
  • One-command setup script with health checks
  • Monitoring strategy guide: SLI/SLO/SLA, alert fatigue, runbooks

File Tree

monitoring-stack-setup/
├── README.md
├── manifest.json
├── LICENSE
├── docker-compose.yml                          # Full stack definition
├── .env.example                                # Configurable variables
├── prometheus/
│   ├── prometheus.yml                          # Scrape configs + relabeling
│   ├── alert-rules.yml                         # 30+ alert rules
│   └── recording-rules.yml                     # Pre-computed aggregations
├── grafana/
│   ├── provisioning/
│   │   ├── datasources.yaml                    # Prometheus + Loki
│   │   └── dashboards.yaml                     # Dashboard provisioning
│   └── dashboards/
│       ├── node-overview.json                  # CPU, memory, disk, network
│       ├── docker-overview.json                # Container metrics
│       └── application-metrics.json            # Request rate, latency, errors
├── alertmanager/
│   └── alertmanager.yml                        # Routing: PagerDuty, Slack
├── loki/
│   └── loki-config.yml                         # Loki with retention
├── promtail/
│   └── promtail-config.yml                     # Log scraping + labels
├── scripts/
│   └── setup.sh                                # One-command setup
└── guides/
    └── monitoring-strategy.md                  # SLI/SLO, alert fatigue
Enter fullscreen mode Exit fullscreen mode

Getting Started

1. Configure environment

cp .env.example .env
# Edit .env with your settings (Slack webhook, PagerDuty key, etc.)
nano .env
Enter fullscreen mode Exit fullscreen mode

2. Start the stack

# One-command setup (creates dirs, starts stack, waits for health)
./scripts/setup.sh

# Or manually:
docker compose up -d
Enter fullscreen mode Exit fullscreen mode

3. Access the dashboards

Service URL Default Credentials
Grafana http://localhost:3000 admin / admin
Prometheus http://localhost:9090
AlertManager http://localhost:9093

4. Add your application

Add scrape targets to prometheus/prometheus.yml:

scrape_configs:
  - job_name: 'my-app'
    static_configs:
      - targets: ['host.docker.internal:8080']
    metrics_path: /metrics
Enter fullscreen mode Exit fullscreen mode

Then reload: curl -X POST http://localhost:9090/-/reload

Architecture

┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│  Your App   │────▶│  Prometheus  │────▶│   Grafana   │
│  /metrics   │     │  (metrics)   │     │ (dashboards)│
└─────────────┘     └──────┬───────┘     └──────▲──────┘
                           │                     │
                    ┌──────▼───────┐      ┌──────┴──────┐
                    │ AlertManager │      │    Loki     │
                    │  (alerting)  │      │   (logs)    │
                    └──────┬───────┘      └──────▲──────┘
                           │                     │
                    ┌──────▼───────┐      ┌──────┴──────┐
                    │ Slack / PD   │      │  Promtail   │
                    │ (notify)     │      │ (log ship)  │
                    └──────────────┘      └─────────────┘
                    ┌──────────────┐     ┌──────────────┐
                    │node-exporter │     │   cAdvisor   │
                    │ (host metrics│     │(container    │
                    │  CPU/mem/disk│     │  metrics)    │
                    └──────────────┘     └──────────────┘
Enter fullscreen mode Exit fullscreen mode

Requirements

  • Docker 24+ and Docker Compose v2
  • 2 GB RAM minimum (4 GB recommended)
  • 10 GB disk for metrics and log retention
  • Ports: 3000, 9090, 9093 (configurable in .env)

Related Products


Datanest Digital | datanest.dev | MIT License


This is 1 of 6 resources in the DevOps Toolkit Pro toolkit. Get the complete [Monitoring Stack Setup] with all files, templates, and documentation for $XX.

Get the Full Kit →

Or grab the entire DevOps Toolkit Pro bundle (6 products) for $178 — save 30%.

Get the Complete Bundle →


Related Articles

Top comments (0)