How to Monitor Your Hono.js API with Vigilmon
Hono is a fast, lightweight web framework that runs on Cloudflare Workers, Bun, Node.js, Deno, and edge runtimes. Its edge-first design means your API can run in 100+ locations globally — but you still need external uptime monitoring to know when it goes down. This guide shows you how to monitor your Hono.js API with Vigilmon.
Why Monitor a Hono API?
Edge deployment gives you speed — but it also introduces failure modes you won't see in local development:
- Cloudflare Workers can be blocked in specific regions
- KV/D1/R2 bindings can fail even when the Worker itself is running
- Cold starts on Bun or Deno can spike response times
- Deployment errors can silently break specific routes
- DNS propagation issues can leave some users unable to reach your API
External uptime monitoring from multiple global regions catches all of these.
Step 1: Add a Health Check Route
Hono makes adding a health endpoint trivial:
import { Hono } from 'hono';
const app = new Hono();
// Health check route
app.get('/health', async (c) => {
// Optional: check bindings
// const kv = c.env.MY_KV;
// await kv.get('health-check-sentinel');
return c.json({
status: 'ok',
timestamp: new Date().toISOString(),
runtime: process.env.RUNTIME ?? 'unknown',
});
});
// Your regular routes
app.get('/api/users', async (c) => {
// ...
});
export default app;
The /health route returns 200 OK with a JSON body under normal conditions.
Step 2: Check KV / D1 / R2 Bindings (Cloudflare Workers)
For Cloudflare Workers with bindings, extend the health check to verify they're working:
app.get('/health', async (c) => {
const checks: Record<string, boolean> = {};
// Check KV binding
if (c.env.MY_KV) {
try {
await c.env.MY_KV.put('__health__', '1', { expirationTtl: 60 });
checks.kv = true;
} catch {
checks.kv = false;
}
}
// Check D1 binding
if (c.env.DB) {
try {
await c.env.DB.prepare('SELECT 1').first();
checks.d1 = true;
} catch {
checks.d1 = false;
}
}
const allHealthy = Object.values(checks).every(Boolean);
const status = allHealthy ? 200 : 503;
return c.json({ status: allHealthy ? 'ok' : 'degraded', checks }, status);
});
Step 3: Add the Monitor in Vigilmon
- Log in at vigilmon.online
- Click Add Monitor
- Set URL to
https://your-hono-api.workers.dev/health(or your custom domain) - Set Monitor Type to HTTP/HTTPS
- Set Check Interval to 60 seconds
- Under Advanced Options:
-
Expected Status Code:
200 -
Response Body Must Contain:
"status":"ok"(optional but useful)
-
Expected Status Code:
- Click Save
Vigilmon immediately starts checking your Hono API from probe nodes distributed across multiple continents.
Step 4: Configure Alert Channels
In Vigilmon, add your alert channel:
- Go to Alert Channels → Add Channel
- Choose: Email, Slack (webhook URL), PagerDuty, or Custom Webhook
- Set the trigger: e.g., "alert after 2 consecutive failures from 2+ regions"
With multi-region consensus, you'll only be alerted when your Hono API is genuinely unreachable from multiple locations — not when a single probe node has a network hiccup.
Monitoring Hono on Different Runtimes
Cloudflare Workers
# Your Workers URL
https://your-api.your-account.workers.dev/health
# Or with custom domain
https://api.yourdomain.com/health
Bun
import { Hono } from 'hono';
const app = new Hono();
app.get('/health', (c) => c.json({ status: 'ok' }));
export default {
port: 3000,
fetch: app.fetch,
};
Monitor: https://your-bun-api.com/health
Node.js (with @hono/node-server)
import { serve } from '@hono/node-server';
import { Hono } from 'hono';
const app = new Hono();
app.get('/health', (c) => c.json({ status: 'ok', timestamp: new Date().toISOString() }));
serve({ fetch: app.fetch, port: 3000 });
Monitor: https://your-node-api.com/health
Deno
import { Hono } from 'npm:hono';
const app = new Hono();
app.get('/health', (c) => c.json({ status: 'ok' }));
Deno.serve(app.fetch);
Multi-Region Edge Monitoring
Hono's killer feature is its edge deployment capability — your Workers can run in 200+ Cloudflare data centers. This means users in Tokyo, Frankfurt, and São Paulo all get a nearby replica of your API.
But this also means an outage might be regional — your API works in the US but fails in Asia because of a D1 routing issue. Vigilmon's global probe network detects these regional failures:
- Each check runs from multiple independent probe nodes
- A failure in one region doesn't trigger an alert (could be the probe, not your API)
- An alert fires when 3+ regions simultaneously confirm the failure
- This catches true regional outages while ignoring transient single-probe issues
Heartbeat Monitoring for Hono Scheduled Tasks
Cloudflare Workers supports cron triggers. Monitor these with Vigilmon heartbeats:
// wrangler.toml
[triggers]
crons = ["0 * * * *"] # Every hour
// Worker
export default {
async scheduled(event: ScheduledEvent, env: Env, ctx: ExecutionContext) {
// ... cron logic ...
// Ping Vigilmon heartbeat
await fetch(`https://vigilmon.online/api/heartbeat/${env.VIGILMON_HEARTBEAT_ID}`);
},
async fetch(request: Request, env: Env) {
return app.fetch(request, env);
},
};
If your cron Worker runs but fails to ping Vigilmon, you'll be alerted.
Complete Monitor Setup for a Hono API
| Monitor | URL | Interval | What It Catches |
|---|---|---|---|
| Health check | /health |
60s | App + binding failures |
| Root route | / |
60s | Routing failures |
| SSL certificate | Your domain | Daily | Cert expiry |
| Cron heartbeat | Via heartbeat ID | Per schedule | Silent cron failures |
Conclusion
Hono's speed and edge-first design are significant advantages — but no framework gives you visibility into whether users can actually reach your API from the internet. External monitoring with Vigilmon closes that gap in 2 minutes.
Add your Hono API to Vigilmon — free tier, no credit card required.
Top comments (0)