Skip to content

adacapo21/redbelly-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Redbelly Node Health Monitor

A monitoring solution for Redbelly Node health and performance, utilizing Node.js, Prometheus, and Grafana to provide real-time insights into node operations.


πŸ“Š Features

  • Real-time health checks for Redbelly Node services.
  • Monitoring critical metrics like latest block number, service status, and node logs.
  • Interactive Grafana dashboards for clear visualization.

βš™οΈ 1. Prerequisites

Ensure you have the following installed on your server:

  • Node.js (v14+)
  • Prometheus
  • Grafana
  • Systemd (for service management)

πŸ“¦ 2. Clone the Repository

git clone https://github.com/adacapo21/redbelly-monitor.git
cd redbelly-monitor

πŸš€ 3. Install Dependencies

npm install

πŸ› οΈ 4. Run the Health Check Service

Start the Service Manually (For Testing):

bash

node src/health-check.js

Set Up as a Systemd Service (For Production):

1. Create a Systemd Service File:

sudo nano /etc/systemd/system/node-health.service

2. Add the Following Configuration:

[Unit]
Description=Redbelly Node Health Check Service
After=network.target

[Service]
ExecStart=/usr/bin/node /path/to/redbelly-monitor/src/health-check.js
Restart=always
User=root
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/path/to/redbelly-monitor

[Install]
WantedBy=multi-user.target

3. Reload systemd and enable the service::

sudo systemctl daemon-reload
sudo systemctl enable node-health.service
sudo systemctl start node-health.service
sudo systemctl status node-health.service

4. Check the Service Status:

sudo systemctl status node-health.service

πŸ“ˆ 5. Set Up Prometheus and Grafana

1. Install Prometheus:

sudo apt-get install prometheus

2. Install Grafana:

sudo apt-get install grafana

3. Configure Prometheus:

sudo nano /etc/prometheus/prometheus.yml

4. Add the Following Configuration:

scrape_configs:
  - job_name: 'redbelly-health'
    static_configs:
      - targets: ['localhost:9092']

5. Restart Prometheus:

sudo systemctl restart prometheus
sudo systemctl status prometheus

6. Configure Grafana:

  • Open Grafana in your browser (http://:3000)
  • Log in with the default credentials (admin/admin) - you will be prompt to change these credentials.
  • Add Prometheus as a data source (http://:9090).
  • Import the Grafana dashboard
    • Go to Dashboard > Import
    • Add panels
      • Query: redbelly_latest_block
      • Query: up{job="redbelly-health"}
    • Save the dashboard.
      • Name: Redbelly Node Health Monitoring

πŸŽ‰ 6. Access Monitoring Dashboard

  • Prometheus UI: http://<server-ip>:9090
  • Grafana Dashboard: http://<server-ip>:3000

πŸ“ 7. Configuration

πŸ›‘οΈ Firewall Rules (If Necessary)

sudo ufw allow 9090
sudo ufw allow 9092
sudo ufw allow 3000
sudo ufw reload

🧩 8. Troubleshooting

1. Check the Service Logs:

sudo journalctl -u node-health.service -f
sudo journalctl -u prometheus -f
sudo journalctl -u grafana-server -f

2. Check the Node.js Logs:

cat /path/to/redbelly-monitor/logs/health-check.log

3. Check the Prometheus Logs:

cat /var/log/prometheus/prometheus.log

4. Check the Grafana Logs:

cat /var/log/grafana/grafana.log

Verify Node Service is Active:

sudo systemctl status node-health.service

Verify Metrics are Being Scraped:

  • Prometheus: http://:9092/metrics

🌐 9. Local Health Check API Endpoints

You can access these health endpoints locally on your server:

Service Status:

curl http://localhost:9092/health/service

Returns the status of the Redbelly Node service, including process ID and systemd status.

Latest Block Number:

curl http://localhost:9092/health/block

Returns the latest block number synced by the Redbelly Node.

Node Logs:

curl http://localhost:9092/health/logs

Returns the last 100 lines of the Redbelly Node logs.


🀝 10. Contributing

Feel free to open an issue or submit a pull request to improve this project.

πŸ“œ 11. License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published