{"id":17780689,"url":"https://github.com/aazme/monitoring-stack-ansible","last_synced_at":"2026-04-26T22:31:25.635Z","repository":{"id":259296382,"uuid":"877401389","full_name":"Aazme/monitoring-stack-ansible","owner":"Aazme","description":"A comprehensive monitoring stack deployment using Ansible for automation and provisioning. This stack includes Prometheus, Grafana, Loki, AlertManager, Node Exporter, and cAdvisor, with Vagrant for local development and testing environments.","archived":false,"fork":false,"pushed_at":"2024-11-04T12:09:11.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-04T13:20:44.067Z","etag":null,"topics":["alert-manager","ansible","cadvisor","grafana","loki","node-exporter","prom","ubuntu2204"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aazme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-10-23T15:29:44.000Z","updated_at":"2024-11-04T12:09:14.000Z","dependencies_parsed_at":"2024-10-24T06:35:21.417Z","dependency_job_id":"5ad99d2d-a4b4-4028-abe0-f74cd1f8deba","html_url":"https://github.com/Aazme/monitoring-stack-ansible","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.15000000000000002","last_synced_commit":"2d6516a21fe419a94ad10c6022b8d88995c1859f"},"previous_names":["aazme/monitoring-stack-ansible"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aazme%2Fmonitoring-stack-ansible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aazme%2Fmonitoring-stack-ansible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aazme%2Fmonitoring-stack-ansible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aazme%2Fmonitoring-stack-ansible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aazme","download_url":"https://codeload.github.com/Aazme/monitoring-stack-ansible/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229701799,"owners_count":18110216,"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","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":["alert-manager","ansible","cadvisor","grafana","loki","node-exporter","prom","ubuntu2204"],"created_at":"2024-10-27T03:03:32.520Z","updated_at":"2026-04-26T22:31:25.603Z","avatar_url":"https://github.com/Aazme.png","language":"Jinja","readme":"\n\n# Monitoring Stack Deployment with Ansible\n\nWelcome to the Monitoring Stack Deployment project! This repository provides an automated solution to deploy a comprehensive monitoring stack using Ansible. The stack includes Prometheus, Grafana, Loki, AlertManager, Node Exporter, and cAdvisor, orchestrated with Docker containers. The setup is designed for testing purposes and suitable for development environments.\n\nCode in Action: \n\n1. DigitalOcean:\n\n   \nhttps://github.com/user-attachments/assets/9448eb22-d5df-42fd-9160-8410cd08cd73\n\n2. Vagrant:\n   \nhttps://github.com/user-attachments/assets/dedc1d7e-092d-461d-a9ae-a3da90c16c1f\n\n\n\n\n## Table of Contents\n- [Introduction](#introduction)\n- [Features](#features)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Testing](#testing)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Introduction\nEffective monitoring is crucial for maintaining the health and performance of your infrastructure. This project automates the deployment of a robust monitoring stack using Ansible, ensuring that you can quickly set up and manage your monitoring tools.\n\nThe stack includes:\n\n- **Prometheus**: Collects metrics from configured targets at given intervals.\n- **Grafana**: Visualizes data through rich dashboards.\n- **Loki**: Provides log aggregation and querying.\n- **AlertManager**: Handles alerts sent by client applications like Prometheus.\n- **Node Exporter**: Exposes machine metrics.\n- **cAdvisor**: Collects container metrics.\n\n## Features\n- **Automated Deployment**: Use Ansible playbooks to deploy the entire monitoring stack with a single command.\n- **Dockerized Services**: All components run in Docker containers for isolation and ease of management.\n- **Scalable Architecture**: Easily add more nodes or services to your monitoring setup.\n- **Customizable Configuration**: Templates and variables allow you to tailor configurations to your needs.\n- **Local Development with Vagrant**: Test the stack locally using Vagrant and VirtualBox.\n- **Automated Testing**: Ensure reliability with pytest and testinfra tests.\n\n## Prerequisites\nBefore you begin, ensure you have the following installed on your control machine (the machine from which you'll run the Ansible playbooks):\n\n1. **Ansible**\n   - **Installation**:\n     ```bash\n     # For Ubuntu/Debian\n     sudo apt update\n     sudo apt install ansible -y\n\n     # For macOS using Homebrew\n     brew install ansible\n     ```\n   - **Version Check**:\n     ```bash\n     ansible --version\n     ```\n\n2. **Python and pip**\n   - **Installation**:\n     ```bash\n     # For Ubuntu/Debian\n     sudo apt install python3 python3-pip -y\n\n     # For macOS using Homebrew\n     brew install python\n     ```\n   - **Version Check**:\n     ```bash\n     python3 --version\n     pip3 --version\n     ```\n\n3. **Git**\n   - **Installation**:\n     ```bash\n     # For Ubuntu/Debian\n     sudo apt install git -y\n\n     # For macOS using Homebrew\n     brew install git\n     ```\n   - **Version Check**:\n     ```bash\n     git --version\n     ```\n\n4. **Vagrant** (Optional, for local development)\n   - **Installation**: [Download from Vagrant Downloads](https://www.vagrantup.com/downloads) and follow the installation instructions for your operating system.\n   - **Version Check**:\n     ```bash\n     vagrant --version\n     ```\n\n5. **Docker** (On Target Hosts)\n   - Note: The Ansible playbooks include roles to install Docker on target hosts. However, if you prefer to install Docker manually:\n     ```bash\n     # For Ubuntu/Debian\n     # Check https://docs.docker.com/engine/install/ubuntu/\n     # Add Docker's official GPG key:\n      sudo apt-get update\n      sudo apt-get install ca-certificates curl\n      sudo install -m 0755 -d /etc/apt/keyrings\n      sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc\n      sudo chmod a+r /etc/apt/keyrings/docker.asc\n      \n      # Add the repository to Apt sources:\n      echo \\\n        \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \\\n        $(. /etc/os-release \u0026\u0026 echo \"$VERSION_CODENAME\") stable\" | \\\n        sudo tee /etc/apt/sources.list.d/docker.list \u003e /dev/null\n      sudo apt-get update\n      sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin\n     ```\n\n## Installation\n1. **Clone the Repository**\n   ```bash\n   git clone https://github.com/Aazme/monitoring-stack-ansible.git\n   cd monitoring-stack-ansible\n   ```\n\n2. **Configure Ansible Inventory**\n   - **Inventory File**: Edit `inventory/inventory.yml` to include your target hosts.\n   \n     Example:\n     ```yaml\n     all:\n       hosts:\n         monitoring-server:\n           ansible_host: your_server_ip\n           ansible_user: your_ssh_user\n           ansible_ssh_private_key_file: path_to_your_private_key\n     ```\n   - **Vagrant Inventory (Optional)**: For local development with Vagrant, use `inventory/vagrant_inventory.yml`.\n\n3. **Update Variables (If Necessary)**\n   - **Ansible Configuration**: Review and update `ansible.cfg` if needed.\n   - **Role Variables**: Customize variables in `playbooks/roles/*/vars/main.yml` as required.\n\n4. **Install Python Dependencies**\n   ```bash\n   pip3 install -r requirements.txt\n   ```\n   **Requirements File (`requirements.txt`)**:\n   ```txt\n   ansible\n   pytest\n   testinfra\n   ```\n\n5. **(Optional) Set Up Vagrant for Local Testing**\n   - **Start the Vagrant VM**:\n     ```bash\n     vagrant up\n     ```\n   - **SSH into the VM**:\n     ```bash\n     vagrant ssh monitoring-server\n     ```\n\n6. **Run the Ansible Playbook**\n   ```bash\n   ansible-playbook playbooks/site.yml\n   ```\n   - `playbooks/site.yml` is the main playbook that includes all roles.\n\n## Usage\n### Accessing the Monitoring Stack\n- **Prometheus**:\n  - **URL**: `http://your_server_ip:9090`\n- **Grafana**:\n  - **URL**: `http://your_server_ip:3000`\n  - **Default Credentials**:\n    - Username: `admin`\n    - Password: `admin` (change after first login)\n- **AlertManager**:\n  - **URL**: `http://your_server_ip:9093`\n- **Loki**:\n  - **URL**: `http://your_server_ip:3100`\n\n### Exploring Metrics and Logs\n- **Node Exporter Metrics**:\n  - Metrics endpoint: `http://your_server_ip:9100/metrics`\n- **cAdvisor Metrics**:\n  - Metrics endpoint: `http://your_server_ip:8080/metrics`\n\n### Customizing Dashboards\n- **Grafana Dashboards**:\n  - Import existing dashboards or create new ones.\n  - Use the provided dashboard template (`grafana_dashboard.json.j2`) as a starting point.\n\n### Configuring Telegram Alerts\nTo configure Telegram alerts in AlertManager, you need to update the `alertmanager/defaults/main.yml` file with your Telegram bot token and chat ID:\n\n**File**: `alertmanager/defaults/main.yml`\n```yaml\n---\ntelegram_bot_token: \"7747059131:AAFZGqnsFFC7u-XXXXXXXXXXXXXXXX\"\ntelegram_chat_id: \"-100XXXXXXXXX\"\n```\nReplace the placeholders with your actual Telegram bot token and chat ID. This configuration will allow AlertManager to send alerts to your specified Telegram chat.\n\n## Testing\n### Running Automated Tests\n1. **Install Test Dependencies**\n   ```bash\n   pip3 install pytest testinfra\n   ```\n\n2. **Run the Tests**\n   ```bash\n    pytest --ansible-inventory=./inventory/inventory.yml --force-ansible --connection=ansible\n   ```\n\n### Manual Testing\n1. **SSH into Target Host**\n   ```bash\n   ssh your_ssh_user@your_server_ip\n   ```\n2. **Check Docker Containers**\n   ```bash\n   docker ps\n   ```\n3. **Verify Services**\n   ```bash\n   systemctl status docker\n   ```\n\n## Troubleshooting\n### Common Issues and Solutions\n1. **SSH Connection Errors**\n   - **Symptom**: Ansible reports `UNREACHABLE` or SSH errors.\n   - **Solution**: Verify SSH connectivity to the target host and ensure SSH user and key are correctly specified.\n\n2. **Permission Denied Errors**\n   - **Symptom**: Containers fail to access necessary resources.\n   - **Solution**: Check file permissions on configuration directories and ensure appropriate permissions for Docker socket.\n\n3. **Services Not Running**\n   - **Symptom**: Docker containers or services are not running.\n   - **Solution**: Use `docker logs container_name` to view logs and check for configuration errors.\n\n### Gathering More Information\n- **Ansible Verbose Mode**: Run playbooks with increased verbosity:\n  ```bash\n  ansible-playbook playbooks/site.yml -vvv\n  ```\n- **System Logs**: Check system logs on the target host for errors:\n  ```bash\n  journalctl -xe\n  ```\n- **Docker Logs**: View logs for individual containers:\n  ```bash\n  docker logs prometheus\n  ```\n\n## Contributing\nWe welcome contributions to enhance the functionality and usability of this project.\n\n### How to Contribute\n1. **Fork the Repository**\n   - Create a personal fork of the repository on GitHub.\n\n2. **Clone Your Fork**\n   ```bash\n   git clone https://github.com/Aazme/monitoring-stack-ansible.git\n   cd monitoring-stack-ansible\n   ```\n\n3. **Create a Feature Branch**\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n4. **Make Your Changes**\n   - Follow coding standards and best practices.\n   - Update or add documentation as necessary.\n   - Write or update tests to cover your changes.\n\n5. **Commit Your Changes**\n   - Use Conventional Commits for commit messages.\n   ```bash\n   git commit -m \"feat: add new feature X\"\n   ```\n\n6. **Push to Your Fork**\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n7. **Open a Pull Request**\n   - Go to the repository on GitHub and open a pull request.\n   - Provide a clear description of your changes.\n\n### Code of Conduct\nPlease read and adhere to the Code of Conduct.\n\n### Contributing Guidelines\nRefer to the Contributing Guide for detailed instructions.\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Acknowledgments\n- **Ansible Community**: For providing extensive documentation and support.\n- **Prometheus and Grafana Teams**: For creating powerful monitoring tools.\n- **Open Source Contributors**: For their valuable contributions to the tools used in this project.\n\n## Additional Resources\n- [Ansible Documentation](https://docs.ansible.com/ansible/latest/index.html)\n- [Prometheus Documentation](https://prometheus.io/docs/introduction/overview/)\n- [Grafana Documentation](https://grafana.com/docs/)\n- [Loki Documentation](https://grafana.com/docs/loki/latest/)\n\n## Contact Information\nFor questions or support, please open an issue on the GitHub repository or contact the maintainer:\n\n- **GitHub**: [https://github.com/Aazme/monitoring-stack-ansible](https://github.com/Aazme/monitoring-stack-ansible)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faazme%2Fmonitoring-stack-ansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faazme%2Fmonitoring-stack-ansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faazme%2Fmonitoring-stack-ansible/lists"}