Monitor Your Bot's Uptime 24/7
Set up comprehensive uptime monitoring for your AI chatbot. Get alerts when your bot goes down and track performance metrics.
Why Monitor Your Bot?
Without monitoring, you won't know when your bot goes offline until users complain. Proper monitoring helps you:
- Get instant alerts when the bot goes down
- Track uptime percentage
- Identify performance issues before they escalate
- Maintain user trust with high availability
Monitoring Options
| Tool | Cost | Features | |------|------|----------| | UptimeRobot | Free | Basic HTTP monitoring | | BetterStack | Free tier | Logs + monitoring | | PM2 Plus | $14/mo | Process monitoring | | Self-hosted | Free | Full control |
Method 1: PM2 Built-in Monitoring
PM2 includes basic monitoring out of the box.
Real-time Dashboard
pm2 monit
This shows CPU, memory, and logs in real-time.
Process Status
pm2 status
pm2 list
Log Monitoring
pm2 logs your-bot --lines 100
Auto-restart on Crash
PM2 automatically restarts crashed processes. Configure limits:
pm2 start index.js --name your-bot --max-restarts 10 --restart-delay 5000
Method 2: UptimeRobot (Free)
UptimeRobot can monitor a health endpoint on your bot.
Step 1: Add Health Endpoint
Add to your bot code:
const http = require('http');
http.createServer((req, res) => {
if (req.url === '/health') {
res.writeHead(200);
res.end('OK');
}
}).listen(3001);
Step 2: Configure Firewall
sudo ufw allow 3001/tcp
Step 3: Set Up UptimeRobot
- Sign up at uptimerobot.com
- Click Add New Monitor
- Select HTTP(s)
- Enter:
http://your-server-ip:3001/health - Set check interval (5 minutes for free)
- Add alert contacts (email, Telegram, Discord webhook)
Method 3: BetterStack (Recommended)
BetterStack combines uptime monitoring with log management.
Setup
- Sign up at betterstack.com
- Create a new monitor
- Install the agent:
curl -fsSL https://logs.betterstack.com/setup/linux | sudo bash
Features
- 30-second check intervals
- Status pages
- Incident management
- Log aggregation
Method 4: Discord Webhook Alerts
Get alerts directly in Discord when your bot has issues.
Create Webhook
- In Discord, go to Server Settings → Integrations
- Click Webhooks → New Webhook
- Copy the webhook URL
PM2 Alert Script
Create /opt/scripts/alert.sh:
#!/bin/bash
WEBHOOK_URL="your-discord-webhook-url"
curl -H "Content-Type: application/json" \
-d "{\"content\": \"⚠️ Bot Alert: $1\"}" \
$WEBHOOK_URL
Make it executable:
chmod +x /opt/scripts/alert.sh
Integrate with PM2
pm2 set pm2:webhook:url "your-discord-webhook-url"
Method 5: Custom Health Checks
Create a comprehensive health check script:
#!/bin/bash
# /opt/scripts/health-check.sh
BOT_NAME="your-bot"
WEBHOOK_URL="your-discord-webhook-url"
# Check if PM2 process is running
if ! pm2 pid $BOT_NAME > /dev/null 2>&1; then
curl -H "Content-Type: application/json" \
-d '{"content": "🔴 Bot is DOWN! Attempting restart..."}' \
$WEBHOOK_URL
pm2 restart $BOT_NAME
exit 1
fi
# Check memory usage
MEM=$(pm2 jlist | jq ".[] | select(.name==\"$BOT_NAME\") | .monit.memory")
MEM_MB=$((MEM / 1024 / 1024))
if [ $MEM_MB -gt 500 ]; then
curl -H "Content-Type: application/json" \
-d "{\"content\": \"⚠️ High memory usage: ${MEM_MB}MB\"}" \
$WEBHOOK_URL
fi
echo "Health check passed"
Schedule with cron:
crontab -e
# Add:
*/5 * * * * /opt/scripts/health-check.sh
Setting Up Alerts
Email Alerts
Most monitoring services include email alerts. Configure:
- Primary email
- Backup email
- SMS for critical alerts (if available)
Discord Alerts
Use webhooks for instant Discord notifications:
# Example alert payload
{
"embeds": [{
"title": "Bot Status Alert",
"description": "Your bot went offline",
"color": 15158332,
"timestamp": "2025-01-27T12:00:00Z"
}]
}
Telegram Alerts
Create a Telegram bot for alerts:
- Message @BotFather to create a bot
- Get your chat ID
- Send alerts via API:
curl "https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAT_ID>&text=Bot%20is%20down!"
Dashboard Setup
PM2 Web Dashboard
pm2 install pm2-server-monit
pm2 web
Access at http://your-server:9615
Grafana Dashboard (Advanced)
For detailed metrics:
- Install Prometheus
- Add PM2 exporter
- Connect Grafana
- Import bot monitoring dashboard
Best Practices
- Multiple alert channels - Don't rely on just email
- Escalation policy - Alert phone if not acknowledged
- Check intervals - 1-5 minutes for production
- Log retention - Keep 7-30 days of logs
- Regular testing - Test alerts monthly
Related Guides
Managed Monitoring
Our maintenance plans include 24/7 monitoring with:
- Instant alerts
- Automatic restarts
- Monthly uptime reports
- UK-based support
Need a VPS for Your Bot?
We recommend Hostinger KVM 2 VPS - reliable, fast, and perfect for AI chatbots. Get started with our recommended setup.
Get Hostinger VPSNeed Help With Setup?
Got your VPS? Let us handle the technical work. Professional setup and maintenance for OpenClaw (formerly Clawd.bot).