Express
Add monitoring to your Express app. Set up a health endpoint, push heartbeats with node-cron, and embed a status badge.
1
Health endpoint
A simple route that BlueMonitor pings every 5 minutes.
app.get("/api/health", (req, res) => {
res.json({ status: "ok" });
});2
Heartbeat push (optional)
Push detailed dependency health data on a schedule using node-cron. Install it first:
npm install node-cronimport cron from "node-cron";
async function sendHeartbeat() {
const checks = {};
// Database check
const dbStart = Date.now();
try {
await db.query("SELECT 1");
checks.database = { status: "ok", latency: Date.now() - dbStart };
} catch (err) {
checks.database = {
status: "error",
latency: Date.now() - dbStart,
message: err.message,
};
}
// Add more checks: redis, external APIs, etc.
const hasError = Object.values(checks).some((c) => c.status === "error");
await fetch("https://www.bluemonitor.org/api/v1/heartbeat", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BLUEMONITOR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
domain: "yourapp.com",
status: hasError ? "error" : "ok",
timestamp: new Date().toISOString(),
checks,
}),
});
}
// Every 5 minutes
cron.schedule("*/5 * * * *", sendHeartbeat);
sendHeartbeat(); // Send immediately on startup3
Status badge
If you serve HTML, add the badge. Replace your-domain-com with your domain (dots become dashes).
<a href="https://www.bluemonitor.org/status/your-domain-com">
<img
src="https://www.bluemonitor.org/api/badge/your-domain-com"
alt="Status on BlueMonitor"
height="36"
/>
</a>Markdown (README.md)
[](https://www.bluemonitor.org/status/your-domain-com)4
Bot tracking
PROTrack which search engines, AI crawlers, and social bots visit your app. Add bot detection middleware to report visits to BlueMonitor. Requires a Pro plan.
Express middleware
const BOT_PATTERNS = [
{ pattern: /Googlebot/i, name: "googlebot", category: "search_engine" },
{ pattern: /bingbot/i, name: "bingbot", category: "search_engine" },
{ pattern: /GPTBot/i, name: "gptbot", category: "ai_crawler" },
{ pattern: /ClaudeBot/i, name: "claudebot", category: "ai_crawler" },
{ pattern: /PerplexityBot/i, name: "perplexitybot", category: "ai_crawler" },
{ pattern: /Twitterbot/i, name: "twitterbot", category: "social" },
{ pattern: /facebookexternalhit/i, name: "facebookbot", category: "social" },
{ pattern: /AhrefsBot/i, name: "ahrefsbot", category: "seo" },
];
function identifyBot(ua) {
for (const bot of BOT_PATTERNS) {
if (bot.pattern.test(ua)) return bot;
}
return null;
}
// If on serverless (Lambda, etc.), use await
app.use(async (req, res, next) => {
const ua = req.headers["user-agent"] || "";
const bot = identifyBot(ua);
if (bot) {
await fetch("https://www.bluemonitor.org/api/v1/bot-visits", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BLUEMONITOR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
domain: "yourapp.com",
visits: [{
bot_name: bot.name,
bot_category: bot.category,
path: req.path,
user_agent: ua,
}],
}),
}).catch(() => {});
}
next();
});View results in your dashboard under Bot Tracking.
Using an AI coding tool?
Paste this URL in Claude, Cursor, or Copilot and it will set up monitoring for your Express app automatically.
https://www.bluemonitor.org/llm-express.txtNext steps
- API Reference — explore all endpoints
- Badge Generator — customize your badge
- Dashboard — set up webhook alerts