How to Monitor Your Bun Application with Vigilmon
Bun is a blazing-fast JavaScript runtime that's rapidly gaining adoption. This guide shows how to add uptime monitoring to your Bun application using Vigilmon.
Native Bun HTTP Server
const server = Bun.serve({
port: 3000,
fetch(req) {
const url = new URL(req.url);
if (url.pathname === '/health') {
return new Response(
JSON.stringify({
status: 'ok',
runtime: 'bun',
version: Bun.version,
timestamp: new Date().toISOString(),
}),
{ headers: { 'Content-Type': 'application/json' }, status: 200 }
);
}
return new Response('Not Found', { status: 404 });
},
});
console.log(`Server running on port ${server.port}`);
Elysia Framework (Most Popular Bun Framework)
import { Elysia } from 'elysia';
const app = new Elysia()
.get('/health', () => ({
status: 'ok',
timestamp: new Date().toISOString(),
}))
.listen(3000);
console.log(`Running at ${app.server?.hostname}:${app.server?.port}`);
Hono with Bun
import { Hono } from 'hono';
const app = new Hono();
app.get('/health', (c) => c.json({ status: 'ok' }));
export default { port: 3000, fetch: app.fetch };
Database Health Check with Bun SQLite
import { Database } from 'bun:sqlite';
const db = new Database('app.db');
Bun.serve({
port: 3000,
fetch(req) {
const url = new URL(req.url);
if (url.pathname === '/health') {
let dbStatus = 'ok';
try {
db.query('SELECT 1').get();
} catch {
dbStatus = 'error';
}
const ok = dbStatus === 'ok';
return new Response(
JSON.stringify({ status: ok ? 'ok' : 'degraded', db: dbStatus }),
{ status: ok ? 200 : 503, headers: { 'Content-Type': 'application/json' } }
);
}
return new Response('Not Found', { status: 404 });
},
});
Add to Vigilmon
- Deploy your Bun app (Railway, Fly.io, Render, or a VPS)
- Go to vigilmon.online
- Click Add Monitor and enter your
/healthURL - Set check interval: 1 minute
- Configure email, Slack, or webhook alerts
Why Monitor Bun Apps?
Bun starts fast and crashes fast. Without external monitoring you find out from users. Vigilmon pings your endpoint every minute from external servers and alerts you within 30 seconds of any failure.
Free tier includes 5 monitors with 1-minute intervals. Start at vigilmon.online.
Top comments (0)