DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Bun.js Application with Vigilmon

How to Monitor Your Bun.js Application with Vigilmon

Bun is the fast all-in-one JavaScript runtime — bundler, test runner, and HTTP server built in. As teams migrate from Node.js to Bun for performance, monitoring becomes just as important. Here's how to monitor your Bun application with Vigilmon.

Why Bun Apps Need Uptime Monitoring

Bun runs as a persistent server process. When it crashes or hangs:

  • HTTP requests start failing immediately
  • No built-in watchdog restarts the process automatically
  • Error output goes to stderr with no user notification
  • If you use bun run directly (not PM2 or systemd), crashes aren't auto-recovered

External uptime monitoring catches these failures independently of your Bun process.

Add a Health Check Route

Bun's built-in HTTP server makes this trivial:

const server = Bun.serve({
  port: 3000,
  async fetch(req) {
    const url = new URL(req.url);

    // Health check endpoint
    if (url.pathname === '/health') {
      return Response.json({
        status: 'ok',
        runtime: 'bun',
        version: Bun.version,
        uptime: process.uptime(),
        timestamp: new Date().toISOString()
      });
    }

    // Your app routes here...
    return new Response('Not found', { status: 404 });
  }
});

console.log(`Listening on port ${server.port}`);
Enter fullscreen mode Exit fullscreen mode

For Elysia.js (popular Bun framework):

import { Elysia } from 'elysia';

const app = new Elysia()
  .get('/health', () => ({
    status: 'ok',
    runtime: 'bun',
    version: Bun.version
  }))
  // ... your routes
  .listen(3000);
Enter fullscreen mode Exit fullscreen mode

For Hono on Bun:

import { Hono } from 'hono';

const app = new Hono();

app.get('/health', (c) => {
  return c.json({ status: 'ok', runtime: 'bun' });
});

export default app;
Enter fullscreen mode Exit fullscreen mode

Set Up Vigilmon Monitoring

  1. Sign up at vigilmon.online
  2. Click Add Monitor
  3. Configure:
    • URL: https://your-bun-app.com/health
    • Check interval: 1 minute
    • Expected status: 200
    • Keyword check: "status":"ok"

Monitoring Bun on Different Platforms

Fly.io

https://your-app.fly.dev/health
Enter fullscreen mode Exit fullscreen mode

Fly.io runs Bun apps in Docker containers. Monitor the public URL.

Railway

https://your-app.up.railway.app/health
Enter fullscreen mode Exit fullscreen mode

Railway auto-assigns a subdomain. Use that for your Vigilmon URL.

VPS with PM2

If you run Bun with PM2:

pm2 start --interpreter bun src/index.ts --name myapp
Enter fullscreen mode Exit fullscreen mode

PM2 handles restarts, but Vigilmon still catches the brief downtime window.

Docker

FROM oven/bun:1
WORKDIR /app
COPY . .
RUN bun install
CMD ["bun", "src/index.ts"]
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost:3000/health || exit 1
Enter fullscreen mode Exit fullscreen mode

Response Time Monitoring

Bun is blazing fast — typical response times under 1ms. Set response time alerts:

  • Warning threshold: 200ms (something is wrong)
  • Critical threshold: 1000ms (likely under load or stuck)

Vigilmon tracks p50/p95 response times and alerts when you cross your thresholds.

SSL Monitoring

Vigilmon automatically checks your SSL certificate. For Bun apps behind Caddy or nginx (which handle TLS), you'll get 30-day advance notice before cert expiry.

Summary

Bun's speed makes it great for production servers. Vigilmon's external monitoring makes sure they stay up. Add a /health endpoint, configure Vigilmon in 5 minutes, and get instant alerts when your Bun app goes down.

Start free at vigilmon.online.

Top comments (0)