{"id":31608694,"url":"https://github.com/mghaith/reusable-monitoring-stack","last_synced_at":"2026-04-11T09:39:15.411Z","repository":{"id":312983815,"uuid":"1049485984","full_name":"MGhaith/Reusable-Monitoring-Stack","owner":"MGhaith","description":"Reusable Monitoring Stack","archived":false,"fork":false,"pushed_at":"2025-09-10T07:55:31.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-10T11:15:56.708Z","etag":null,"topics":["alertmanager","ansible","docker","docker-compose","github-actions","grafana","prometheus","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MGhaith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-03T03:53:25.000Z","updated_at":"2025-09-09T21:22:41.000Z","dependencies_parsed_at":"2025-09-10T09:26:04.248Z","dependency_job_id":null,"html_url":"https://github.com/MGhaith/Reusable-Monitoring-Stack","commit_stats":null,"previous_names":["mghaith/reusable-monitoring-stack"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MGhaith/Reusable-Monitoring-Stack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGhaith%2FReusable-Monitoring-Stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGhaith%2FReusable-Monitoring-Stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGhaith%2FReusable-Monitoring-Stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGhaith%2FReusable-Monitoring-Stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MGhaith","download_url":"https://codeload.github.com/MGhaith/Reusable-Monitoring-Stack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGhaith%2FReusable-Monitoring-Stack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278578131,"owners_count":26009739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alertmanager","ansible","docker","docker-compose","github-actions","grafana","prometheus","terraform"],"created_at":"2025-10-06T08:23:28.443Z","updated_at":"2025-10-06T08:23:29.504Z","avatar_url":"https://github.com/MGhaith.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reusable Monitoring Stack\n\n## Overview\n\nThis repository contains a reusable monitoring stack featuring Prometheus, Grafana, and Alertmanager. It's designed to be deployed locally or in the cloud.\n\n## Deployment\n\n### Local Deployment (Docker Environment)\n\n#### 🖼️ Architecture Diagram\n\n\u003cimg width=\"1283\" height=\"780\" alt=\"ReusableMonitoringStack\" src=\"https://github.com/user-attachments/assets/6eb18ea1-4496-4810-8d75-e84410a2d4eb\" /\u003e\n\n#### Prerequisites\n1. Install [Docker Desktop](https://docs.docker.com/get-started/get-docker/)\n2. Make sure Docker is running on your machine\n\n#### Setup Steps\n1. Copy the environment file:\n   ```bash\n   cp .env.example .env\n   ```\n2. Edit the `.env` file\n3. To get alerts using Alert Manager: Edit `prometheus/alertmanager.yml` file to add your **Slack** and/or **Gmail** credentials.\n4. Start the stack:\n   ```bash\n   docker-compose up -d\n   ```\n\n#### Alerts\n\nAlerts are configured to notify via email/Slack when certain thresholds are met. The following alerts are currently configured in `prometheus/alerts.yml`:\n\n- **High CPU Usage**: Triggers when CPU usage exceeds 80% for 5 minutes.\n- **High Memory Usage**: Alerts when memory usage is above 85% for 5 minutes.\n- **Instance Down**: Fires when a monitored instance is unreachable for 2 minutes.\n- **Disk Space Running Low**: Alerts when disk usage reaches 90% capacity.\n\nTo view and manage these alerts, you can access them through the **Prometheus UI** or directly modify the `prometheus/alerts.yml` file.\n\n#### Access\n* Prometheus: http://localhost:9090\n* Alertmanager: http://localhost:9093\n* Grafana: http://localhost:3000 (Username: ```admin```, Password: ```\"your Grafana password\"```)\n\n### Cloud Deployment (AWS)\n\n\u003e ⚠️ **WARNING: Cost Implications** ⚠️\n\u003e \n\u003e Deploying this stack on AWS will incur costs for several resources, including but not limited to:\n\u003e - **NAT Gateway** (~$32/month per gateway)\n\u003e - **Application Load Balancer** (~$20/month)\n\u003e - **EFS Storage** (pricing varies based on usage, ~$0.30/GB-month)\n\u003e\n\u003e Please review AWS pricing carefully before deployment to avoid unexpected charges.\n\n\u003e **Note**: By default, this stack will be deployed in the `eu-central-1` region. To change the deployment region, modify the `provider.tf` file in the terraform directory.\n\n#### 🖼️ Architecture Diagram\n\n![portfolio-full-architecture-Page-3](https://github.com/user-attachments/assets/1d918af2-2ef4-48f5-a01d-22ebcf2dafff)\n\n#### Prerequisites\n\n1. [AWS CLI](https://aws.amazon.com/cli/) installed and configured\n2. [Terraform](https://www.terraform.io/downloads.html) (v1.0.0+) installed\n3. AWS account with appropriate permissions\n\n#### Infrastructure Components\n\n- **VPC**: Isolated network with public and private subnets\n- **ECS Cluster**: For running containerized services\n- **Application Load Balancer**: For routing traffic to services\n- **EFS**: For persistent storage of monitoring data\n- **IAM Roles**: For proper service permissions\n\n#### Setup Steps\n\n1. Configure AWS credentials:\n   ```bash\n   aws configure\n   ```\n\n2. Initialize Terraform:\n   ```bash\n   cd terraform\n   terraform init\n   ```\n\n3. Plan the deployment:\n   ```bash\n   terraform plan -out=tfplan\n   ```\n\n4. Apply the configuration:\n   ```bash\n   terraform apply tfplan\n   ```\n\n5. After successful deployment, Terraform will output the ALB DNS name.\n\n#### Access\n\n* Prometheus: http://[ALB-DNS-NAME]/prometheus\n* Alertmanager: http://[ALB-DNS-NAME]/alertmanager\n* Grafana: http://[ALB-DNS-NAME]/grafana (Username: ```admin```, Password: ```admin```)\n\n#### Cleanup\n\nTo destroy all created resources:\n\n```bash\nterraform destroy\n```\n\n**Note**: This will remove all resources including persistent data stored in EFS.\n\n## CI/CD Workflow\n\nThis project uses GitHub Actions for continuous integration. The workflow includes:\n\n1. **Validation**:\n   - Validates Docker Compose configuration\n   - Validates Prometheus configuration using promtool\n   - Validates Alertmanager configuration using amtool\n\n2. **Smoke Testing**:\n   - Builds and starts the complete monitoring stack\n   - Waits for services to initialize\n   - Verifies container health status\n   - Performs cleanup by tearing down the stack\n\nThe workflow runs automatically on:\n- Push events to the main branch\n- Pull request events targeting the main branch\n\nThis ensures that all configuration files are valid and the stack can be successfully deployed before changes are merged.\n\n## Troubleshooting\n\n### Common Issues\n\n#### Local Deployment\n\n- **Port Conflicts**: If services fail to start, check if ports 9090, 9093, or 3000 are already in use.\n- **Container Startup Failures**: Check logs with `docker-compose logs [service_name]`.\n- **Permission Issues**: Ensure proper permissions on mounted volumes.\n\n#### Cloud Deployment\n\n- **Health Check Failures**: Verify ALB target group settings and container health check endpoints.\n- **ECS Task Failures**: Check CloudWatch Logs for container startup issues.\n- **Networking Issues**: Verify security group rules allow necessary traffic.\n\n## 🎯 Stretch Goals\n\n- **Add Kubernetes Support**: Enable deployment on Kubernetes clusters for better scalability.\n- **Add Loki for Log Aggregation**: Enhance observability by aggregating logs.\n- **Implement Service Discovery**: Add automatic service discovery for dynamic environments.\n\n## License\nMIT\n\n---\n\n*Feel free to clone this repository and customize it as needed. If you have any questions or need further assistance, don't hesitate to ask!*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmghaith%2Freusable-monitoring-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmghaith%2Freusable-monitoring-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmghaith%2Freusable-monitoring-stack/lists"}