A complete local DevOps Monitoring Stack built using Terraform, the Docker provider, and custom container resources. This project provisions:
- π Prometheus for metrics collection
- π Grafana for visualization
- π‘ Node Exporter for system metrics
- π A custom Nginx web server for simulating a static web app
β Entire stack is provisioned using Infrastructure as Code (IaC) β no manual Docker CLI or Compose!
| Tool | Purpose |
|---|---|
| Terraform | Infrastructure as Code |
| Docker | Containerization |
| Nginx | Static Web Server |
| Prometheus | Metrics collection |
| Grafana | Dashboards & Visualization |
| Node Exporter | Host system metrics exporter |
terraform-devops-stack/
βββ main.tf
βββ variables.tf
βββ outputs.tf
βββ terraform.tfvars
βββ prometheus/
β βββ prometheus.yml
βββ nginx/
β βββ Dockerfile
β βββ index.html
βββ grafana/
β βββ provisioning/
β βββ dashboards/ # Optional JSON dashboards
βββ README.md
π¦ How It Works
Terraform provisions Docker images & containers with all configurations.
prometheus.yml is mounted inside the Prometheus container.
Grafana uses provisioning to auto-detect Prometheus as a data source.
Nginx serves a custom HTML file on port 8080.
Node Exporter runs on port 9100, monitored by Prometheus.
βΆοΈ Getting Started
π¦ Prerequisites
Docker installed and running
Terraform v1.6+ installed
VS Code (recommended)
π Run the Stack
bash
ΰ€ΰ₯ΰ€ͺΰ₯ ΰ€ΰ€°ΰ₯ΰ€
ΰ€¬ΰ€¦ΰ€²ΰ₯ΰ€
# Clone the repository
git clone https://github.com/your-username/terraform-devops-stack.git
cd terraform-devops-stack
# Initialize and apply Terraform
terraform init
terraform apply
π Access the Services
Service URL
π Nginx http://localhost:8080
π Grafana http://localhost:3000
π Prometheus http://localhost:9090
π° Node Exporter http://localhost:9100/metrics
Grafana Login
Username: admin
Password: admin (default)
πΈ Screenshots
π₯οΈ Custom Nginx Page

π Prometheus UI

π Grafana Dashboard

π Learning Outcomes
Built a monitoring stack from scratch using only Terraform and Docker.
Practiced defining volumes, networks, and multi-container setup with IaC.
Understood how observability tools connect in a real-world scenario.
No use of Docker Compose or cloudβeverything runs locally and is reproducible.
β
Next Goals (Ideas to Extend)
Add Alertmanager for Prometheus.
Integrate a backend app (Flask/Node.js) instead of static Nginx.
Push this stack to a VM or cloud environment.
Auto-provision Grafana dashboards using JSON.
πββοΈ Author
Sayed Mohsin Ali
π¨βπ» DevOps Engineer | 3.5 YOE | Azure | Terraform | Kubernetes
π LinkedIn
π GitHub
π‘ If this helped you, feel free to β the repo and connect with me!