This repository provides scripts to help you set up a self-hosted monitoring system for your VPS using Prometheus, Node Exporter, and Grafana. This setup enables you to collect and visualize metrics, and create alerts to monitor the health and performance of your servers.
- Prometheus: An open-source monitoring system with a time series database. It collects and stores metrics as time series data, allowing users to query and alert on this data.
- Node Exporter: A Prometheus exporter that collects a choice of hardware and OS metrics exposed by *NIX kernels based on config.
- Grafana: An open-source platform for monitoring and observability. It allows you to visualize and alert on your metrics, with support for various data sources, including Prometheus.
![Screenshot 2024-03-16 at 00 23 37](https://private-user-images.githubusercontent.com/60665157/313264854-79a0f735-f3ce-4e52-b25c-9c0b7867ba7b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMzMzNjYsIm5iZiI6MTcyNTMzMzA2NiwicGF0aCI6Ii82MDY2NTE1Ny8zMTMyNjQ4NTQtNzlhMGY3MzUtZjNjZS00ZTUyLWIyNWMtOWMwYjc4NjdiYTdiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDAzMTEwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQwNjU0MGM2NTAwN2EwZGZlMGFhZjA3ZDAxYjBmYzQ1YzA2YTc0ZmFjYTAwNmY1ZGFkZDVhNGY2YTY2YTBmMTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lmTGaDrU1OxosTAsu1VgQLy7m0mUMPn9duLRcjt1XcA)
- 2 CPU cores
- 4 GB of memory
- 20 GB of free disk space
- Ensure you have root access or sufficient permissions to install packages and make network configurations.
- The instructions are tailored for Debian/Ubuntu systems. Adapt commands accordingly for other distributions.
Git is required to clone the repository containing the necessary scripts.
apt install git
Clone the repository to download the scripts to your server.
git clone https://github.com/ExploreNYM/self-hosted-monitor ~/self-hosted-monitor
Execute the script to install and configure Prometheus.
chmod +x ~/self-hosted-monitor/prometheus.sh && ~/self-hosted-monitor/prometheus.sh
Run the script to install Grafana, which will be used for visualizing the data collected by Prometheus.
chmod +x ~/self-hosted-monitor/grafana.sh && ~/self-hosted-monitor/grafana.sh
For accessing Grafana via HTTP:
ufw allow 3000
Then, access Grafana at http://your-ip-address:3000
.
If you prefer HTTPS access using your domain, ensure your domain DNS is pointing to your server's IP and then run the script to set up Nginx and Certbot for SSL:
chmod +x ~/self-hosted-monitor/nginx-certbot.sh && ~/self-hosted-monitor/nginx-certbot.sh
To monitor a new server, use this script to add it as a target to Prometheus.
chmod +x ~/self-hosted-monitor/prometheus-target.sh && ~/self-hosted-monitor/prometheus-target.sh
These steps should be followed on the server you wish to monitor.
apt install git
git clone https://github.com/ExploreNYM/self-hosted-monitor ~/self-hosted-monitor
This script installs Node Exporter, which will collect metrics to be scraped by Prometheus.
chmod +x ~/self-hosted-monitor/node-exporter.sh && ~/self-hosted-monitor/node-exporter.sh
- After each installation step, verify that the service is running correctly. For example, check if Prometheus and Grafana services are active using
systemctl status prometheus
systemctl status grafana-server
systemctl status node_exporter
. - Access the Grafana UI by navigating to
http://your-ip-address:3000
orhttps://your-domain
based on your setup and confirm that the Prometheus data source is connected. - If you encounter issues, check the respective service logs for detailed error messages (e.g.,
journalctl -u prometheus
).
If you need help or want to contribute to the project, feel free to open an issue or a pull request in the repository.