Skip to content

Repository files navigation

Monitoring Platform

Production-grade centralized monitoring platform using Docker Compose.

Stack Components

ComponentVersionPurpose
Prometheusv2.53.0Metrics collection and storage
Grafanav11.1.0Visualization and dashboards
Alertmanagerv0.33.1Alert routing and notification
Lokiv3.7.4Log aggregation
Promtailv3.6.11Log collector
Node Exporterv1.12.1Host system metrics
cAdvisorv0.49.1Container metrics
Blackbox Exporterv0.28.0Endpoint probing

Quick Start

# 1. Copy and configure environment variables
cp .env.example .env
nano .env # Edit credentials and settings# 2. Deploy the stack
./scripts/deploy.sh
# 3. Validate deployment
./scripts/validate.sh

Access URLs

ServiceURLCredentials
Grafanahttp://localhost:3000Configured in .env
Prometheushttp://localhost:9090-
Alertmanagerhttp://localhost:9093-

Directory Structure

monitoring-platform/
├── docker-compose.yml # Main compose file
├── .env.example # Environment variables template
├── .env # Your credentials (git-ignored)
├── prometheus/
│ ├── prometheus.yml # Prometheus configuration
│ └── alert.rules.yml # Alert rules
├── alertmanager/
│ ├── Dockerfile # Custom image with envsubst
│ ├── entrypoint.sh # Config template processor
│ └── alertmanager.yml.tmpl # Alertmanager config template
├── grafana/
│ └── provisioning/
│ ├── datasources/ # Auto-configured datasources
│ └── dashboards/ # Dashboard provisioning
├── loki/
│ └── loki-config.yml # Loki configuration
├── promtail/
│ └── promtail-config.yml # Promtail configuration
├── blackbox-exporter/
│ └── blackbox.yml # Blackbox probe modules
├── scripts/
│ ├── deploy.sh # Deployment script
│ ├── validate.sh # Validation script
│ ├── backup.sh # Backup script
│ └── restore.sh # Restore script
└── docs/
└── DEPLOYMENT.md # Deployment guide

Environment Variables

All credentials and configurable settings are centralized in .env file.

Grafana

VariableDescriptionDefault
GRAFANA_ADMIN_USERAdmin usernameadmin
GRAFANA_ADMIN_PASSWORDAdmin passwordadmin
GRAFANA_ROOT_URLPublic URL for Grafanahttp://localhost:3000

Prometheus

VariableDescriptionDefault
PROMETHEUS_RETENTION_TIMEHow long to keep metrics30d
PROMETHEUS_RETENTION_SIZEMax storage size10GB

Alertmanager - Email (SMTP)

VariableDescriptionExample
SMTP_SMARTHOSTSMTP server:portsmtp.gmail.com:587
SMTP_FROMSender email addressalerts@example.com
SMTP_AUTH_USERNAMESMTP usernamealerts@example.com
SMTP_AUTH_PASSWORDSMTP password/app passwordyour-app-password
SMTP_REQUIRE_TLSRequire TLStrue
ALERT_EMAIL_TOAlert recipient emailoncall@example.com

Alertmanager - Slack

VariableDescriptionExample
SLACK_API_URLSlack webhook URLhttps://hooks.slack.com/...
SLACK_CHANNEL_CRITICALChannel for critical alerts#alerts-critical
SLACK_CHANNEL_WARNINGChannel for warning alerts#alerts-warning

Operations

Deploy

./scripts/deploy.sh

Validate

./scripts/validate.sh

Backup

./scripts/backup.sh [backup_directory]

Restore

./scripts/restore.sh <backup_file.tar.gz>

Stop

docker compose down

View Logs

# All services
docker compose logs -f
# Specific service
docker compose logs -f prometheus

Security Notes

  1. Change default credentials - Update Grafana admin password immediately
  2. Firewall - Only ports 3000, 9090, 9093 are exposed; restrict access via firewall
  3. Exporters - Node Exporter, cAdvisor, Blackbox Exporter are internal only
  4. Network - All services communicate via internal Docker network

Customization

Add Scrape Targets

Edit prometheus/prometheus.yml and add new targets under scrape_configs.

Add Alert Rules

Edit prometheus/alert.rules.yml to add new alerting rules.

Configure Notifications

Edit alertmanager/alertmanager.yml to configure email, Slack, or webhook receivers.

Add HTTP Probes

Edit prometheus/prometheus.yml under the blackbox-http job to add endpoints to monitor.

Troubleshooting

Check container status

docker compose ps

Check container logs

docker compose logs <service_name>

Restart a service

docker compose restart <service_name>

Reload Prometheus configuration

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

About

Production-grade centralized monitoring platform using Docker Compose

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages