Skip to content

cosmostation/pharos-monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pharos RPC & Sync Monitoring with Telegram Alerts

Service that monitors an EVM JSON-RPC endpoint (e.g. http://127.0.0.1:18100) and sends Telegram alerts

  • checks eth_blockNumber from http://localhost:${RPC_PORT}
  • sends Telegram alert when RPC becomes DOWN
  • sends Telegram alert when height stops progressing (STUCK)
  • sends Telegram alert when syncing resumes
  • periodically posts current height (heartbeat)

🚀 Getting Started

1️⃣ Create new Telegram Bot following the instructions and get the token:

TELEGRAM_TOKEN=110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw

2️⃣ Invite above created 🤖Telegram Bot to 💬Telegram group or channel and give admin permissions for the bot to be able to send alert notifications

3️⃣ Get the particular Telegram Chat ID (e.g. -123456789)

Using Telegram Web
  1. Open Telegram Web: Go to web.telegram.org in your browser.
  2. Log In: Scan the QR code or log in with your credentials.
  3. Select the Chat: Click on the user, group, or channel you need the ID for.
  4. Check the URL: Look at the address bar
    • For a personal chat: The number after # is your User ID (e.g., web.telegram.org).
    • For a group/channel: The ID is the number after #, but you must prepend a minus sign (e.g., -123456789)
TELEGRAM_CHAT_ID=-123456789

4️⃣ Clone the pharos-monitoring repository in a remote server where your Pharos node is running and build the binary

git clone https://github.com/cosmostation/pharos-monitoring.git 
cd pharos-monitoring && make build

5️⃣ Setup the .env file and update the variables:

cd pharos-monitoring
cp .env.example .env

6️⃣ Setup the systemd pharos-monitoring.service

sudo cp ./pharos-monitoring/systemd/pharos-monitoring.service /etc/systemd/system/ 

# change <USERNAME> and <PATH> according to your infrastructure:
sudo vim /etc/systemd/system/pharos-monitoring.service

User=<USERNAME>                                             # e.g. pharos
ExecStart=<PATH>/pharos-monitoring/bin/pharos-monitoring    # where the binary is located
WorkingDirectory=<PATH>/pharos-monitoring                   # where the repo is located
EnvironmentFile=<PATH>/pharos-monitoring/.env               # Load env vars from this file

7️⃣ Reload the daemon service file

sudo systemctl daemon-reload
sudo systemctl enable pharos-monitoring

8️⃣ Change the permission mode of the run.sh script file and start the process

cd pharos-monitoring && chmod 700 run.sh
./run.sh start

# check logs:
./run.sh log

📝 Expected Results

  • check ./run.sh log
systemd[1]: pharos-monitoring.service: Activated successfully.
systemd[1]: Started pharos-monitoring.service - Pharos RPC Sync Monitoring (Telegram).
pharos-monitoring[7]: ✅ Pharos monitoring started
pharos-monitoring[7]:  - RPC: http://localhost:18100
pharos-monitoring[7]:  - check interval: 1m0s
pharos-monitoring[7]:  - height report interval: 1h0m0s
pharos-monitoring[7]: ❌ RPC error: RPC call failed: Post "http://localhost:18100": dial tcp 127.0.0.1:18100: connect: connection refused
  • Telegram alerting

tg_alert

About

Lightweight monitoring tool that checks Pharos EVM JSON-RPC endpoint and sends Telegram alerts

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors