This repository sets up a monitoring stack using Prometheus and Grafana. It includes a script to dynamically generate Prometheus scrape configurations based on a hosts.json
file.
Prometheus is an open-source systems monitoring and alerting toolkit. It is used to scrape metrics from configured targets at given intervals and provides powerful querying capabilities.
Grafana is an open-source platform for monitoring and observability. It enables visualization and analysis of metrics through customizable dashboards.
Docker Compose simplifies multi-container Docker applications by defining services, networks, and volumes in a single file.
jq is a lightweight and flexible command-line JSON processor. It is used in the script to parse and process the hosts.json
file.
- Install Docker and Docker Compose:
- Install jq for JSON processing:
sudo apt install jq # Ubuntu/Debian brew install jq # macOS sudo yum install jq # CentOS/RHEL
Make sure your project directory looks like this:
├── Makefile
├── README.md
├── docker-compose.yml
├── generate_config.sh
├── grafana
│ └── provisioning
│ ├── dashboards
│ │ ├── Overview.json
│ │ └── dashboard.yml
│ ├── datasources
│ │ └── datasources.yaml
│ └── grafana.ini
├── hosts.json.example
-
Copy
hosts.json.example
tohosts.json
:cp hosts.json.example hosts.json
-
Edit
hosts.json
to include the servers you want to monitor. Each entry should be a list of[Name, IP, Category]
.
Example hosts.json.example
:
[
["Admin-Station", "0.0.0.0", "infrastructure"],
["Proxy", "1.1.1.1", "infrastructure"],
["Mainnet-Validator-A", "2.2.2.2", "mx-node"],
["Mainnet-Validator-B", "3.3.3.3", "mx-node"],
["Web-Apps", "4.4.4.4", "Apps"]
]
Run the script to generate the prometheus.yml
file dynamically:
make generate
Use the following command to start all services (Prometheus, Grafana, and configuration generator):
make start
If you make changes to the configuration, use the refresh command to restart the services:
make refresh
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000
- Default credentials:
- Username:
admin
- Password:
admin
- Username:
- Default credentials:
- Add new dashboards in the
grafana/provisioning/dashboards
directory. - Add new datasources in
grafana/provisioning/datasources/datasources.yaml
.
Feel free to submit issues or contribute to improve this project.
This project is licensed under the MIT License.