This README provides step-by-step instructions for setting up Prometheus, Grafana, and a Node.js application for updating Prometheus configurations on an Amazon EC2 instance.
- An Amazon EC2 instance running Amazon Ubuntu
- SSH access to your EC2 instance
- Sufficient permissions to modify EC2 security groups
Before installing the applications, you need to configure your EC2 security group to allow inbound traffic on the necessary ports:
- Open the Amazon EC2 console
- Select your instance and click on the "Security" tab
- Click on the security group link
- In the "Inbound rules" tab, click "Edit inbound rules"
- Add the following rules:
- Type: Custom TCP, Port Range: 9090, Source: 0.0.0.0 (for Prometheus)
- Type: Custom TCP, Port Range: 3000, Source: 0.0.0.0 (for Grafana)
- Type: SSH, Port Range: 22, Source: 0.0.0.0 (if not already added)
- Type: Custom TCP, Port Range: 9100, Source: 0.0.0.0 - Node Exporter
- Type: Custom TCP, Port Range: 4000, Source: 0.0.0.0 - HTTP Generator Web App
- Click "Save rules"
- SSH into your EC2 instance
- Create a new file named
promgraf.sh:nano install promgraf.sh - Copy and paste the contents of the Prometheus and Grafana installation script into this file
- Save and exit the file (in nano, press CTRL+X, then Y, then Enter)
- Make the script executable:
chmod +x promgraf.sh - Run the script:
sudo ./promgraf.sh - Wait for the installation to complete. The script will print the URLs for accessing Prometheus and Grafana. Make sure to check the status of Prometheus and Grafana before proceeding to next step. The status commands are below.
- Create a new file named
nodex.sh:nano nodex.sh - Copy and paste the contents of the Node.js HTTP Generator installation script into this file
- Save and exit the file
- Make the script executable:
chmod +x nodex.sh - Run the script:
sudo ./nodex.sh - Wait for the installation to complete. The script will print information about how to use the application.
- Prometheus: http://[Your-EC2-Public-IP]:9090
- Grafana: http://[Your-EC2-Public-IP]:3000 (default login is admin/admin) You do not have to create a new account, you will have the option to skip after you type in admin/admin.
- Node Exporter: http://[Your-EC2-Public-IP]:9100/add-target (POST requests only)
- You can also use localhost:port
- If you can't access the applications, ensure that your EC2 instance's security group is correctly configured and that the services are running:
sudo systemctl status prometheus sudo systemctl status grafana-server - Check the application logs for any error messages:
sudo journalctl -u prometheus sudo journalctl -u grafana-server