Set up uptime monitoring
✓Works with OpenClaudeYou are a DevOps engineer setting up application availability monitoring. The user wants to create an uptime monitor that tracks service availability and alerts when services go down.
What to check first
- Verify you have Node.js 14+ installed:
node --version - Confirm you have curl or a similar HTTP client available:
which curl - Check that you can access the services you want to monitor (test with
curl -I https://example.com)
Steps
- Install the
uptime-monitororaxiospackage for HTTP requests:npm install axios node-cron - Create a configuration file listing all endpoints with expected response codes and check intervals
- Set up a monitoring loop that runs at regular intervals using
node-cronscheduler - Make HTTP HEAD or GET requests to each endpoint and record response times
- Compare response codes against expected values (typically 200-299 for healthy services)
- Calculate uptime percentage over rolling 24-hour and 30-day windows
- Store metrics in a JSON file or simple database for historical tracking
- Configure alert thresholds (e.g., trigger alert if downtime exceeds 5 minutes)
Code
const axios = require('axios');
const cron = require('node-cron');
const fs = require('fs');
const path = require('path');
const CONFIG = {
endpoints: [
{ name: 'API', url: 'https://api.example.com/health', expectedCode: 200 },
{ name: 'Website', url: 'https://example.com', expectedCode: 200 },
{ name: 'Database', url: 'https://db.example.com/status', expectedCode: 200 }
],
checkInterval: '*/5 * * * *', // Every 5 minutes
alertEmail: 'admin@example.com',
metricsFile: './uptime_metrics.json'
};
const initMetricsFile = () => {
if (!fs.existsSync(CONFIG.metricsFile)) {
fs.writeFileSync(CONFIG.metricsFile, JSON.stringify({
checks: [],
alerts: []
}, null, 2));
}
};
const checkEndpoint = async (endpoint) => {
const startTime = Date.now();
try {
const response = await axios.head(endpoint.url, { timeout: 10000 });
const responseTime = Date.now() - startTime;
return {
name: endpoint.name,
status: response.status === endpoint.expectedCode ? 'up' : 'down',
responseCode: response.status,
responseTime,
timestamp: new Date().toISOString(),
success: true
};
} catch (error) {
return {
name: endpoint.name,
status: 'down',
responseCode: error.response?.status || null,
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Monitoring & Logging Skills
Other Claude Code skills in the same category — free to download.
Structured Logging
Implement structured logging (Winston, Pino)
Error Tracking
Set up error tracking (Sentry)
APM Setup
Set up Application Performance Monitoring
Log Rotation
Configure log rotation and management
Health Dashboard
Create health monitoring dashboard
Alert Rules
Configure alerting rules and notifications
Distributed Tracing
Set up distributed tracing
Metrics Collector
Implement custom metrics collection
Want a Monitoring & Logging skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.