How to Monitor Your Deno 2 Application with Vigilmon
Deno 2 is the TypeScript-first runtime that ships with built-in security, a standard library, and first-class npm compatibility. If you're running Deno in production, here's how to add health checks and connect to Vigilmon for uptime monitoring.
Quick Health Endpoint for Deno 2
Using Deno.serve (built-in)
// server.ts
Deno.serve({ port: 8000 }, (req) => {
const url = new URL(req.url);
if (url.pathname === '/health') {
return new Response(
JSON.stringify({
status: 'ok',
runtime: 'deno',
version: Deno.version.deno,
uptime: performance.now() / 1000,
timestamp: new Date().toISOString(),
}),
{
status: 200,
headers: { 'Content-Type': 'application/json' },
}
);
}
return new Response('Hello from Deno 2!');
});
console.log('Server running on http://localhost:8000');
With Hono on Deno
// main.ts
import { Hono } from 'npm:hono';
const app = new Hono();
app.get('/health', (c) => {
return c.json({
status: 'ok',
runtime: 'deno',
version: Deno.version.deno,
timestamp: new Date().toISOString(),
});
});
app.get('/', (c) => c.text('Hello Hono on Deno!'));
Deno.serve({ port: 8000 }, app.fetch);
With Fresh Framework
For Fresh apps, add a health route in routes/:
// routes/health.ts
import { Handlers } from '$fresh/server.ts';
export const handler: Handlers = {
GET(_req, _ctx) {
return new Response(
JSON.stringify({
status: 'ok',
runtime: 'deno',
version: Deno.version.deno,
timestamp: new Date().toISOString(),
}),
{
status: 200,
headers: { 'Content-Type': 'application/json' },
}
);
},
};
With Oak Framework
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
const router = new Router();
router.get('/health', (ctx) => {
ctx.response.body = {
status: 'ok',
runtime: 'deno',
version: Deno.version.deno,
uptime: performance.now() / 1000,
timestamp: new Date().toISOString(),
};
});
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
app.listen({ port: 8000 });
Heartbeat Monitoring for Deno Cron Jobs
Deno 2 has built-in cron support. Send heartbeats to Vigilmon after each run:
// cron.ts
const HEARTBEAT_URL = 'https://vigilmon.online/api/heartbeat/YOUR_MONITOR_ID';
Deno.cron('Daily cleanup', '0 2 * * *', async () => {
console.log('Running daily cleanup...');
// Your job logic
await runCleanup();
// Signal success to Vigilmon
try {
await fetch(HEARTBEAT_URL, { method: 'POST' });
console.log('Heartbeat sent');
} catch (err) {
console.error('Failed to send heartbeat:', err);
}
});
Deno Deploy Monitoring
For apps on Deno Deploy:
// Fresh app on Deno Deploy — routes/health.ts
import { Handlers } from '$fresh/server.ts';
export const handler: Handlers = {
GET(_req) {
return Response.json({
status: 'ok',
platform: 'deno-deploy',
region: Deno.env.get('DENO_REGION') ?? 'unknown',
timestamp: new Date().toISOString(),
});
},
};
Then monitor https://your-app.deno.dev/health in Vigilmon.
Running Deno in Production (systemd)
[Unit]
Description=Deno Application
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/app
ExecStart=/usr/local/bin/deno run --allow-net --allow-env --allow-read server.ts
Restart=always
RestartSec=5
Environment=DENO_NO_UPDATE_CHECK=1
[Install]
WantedBy=multi-user.target
Setting Up Vigilmon
- Sign up at vigilmon.online
- Add monitor → paste your health endpoint URL
- Configure alerts (email + Slack)
- Add SSL monitor for your domain
Vigilmon checks from multiple global regions every 1-5 minutes.
Monitoring Checklist for Deno Apps
- [ ]
/healthendpoint returning 200 JSON - [ ] KV or database connectivity check
- [ ] Heartbeat monitors for Deno.cron jobs
- [ ] Uptime monitor in Vigilmon
- [ ] SSL certificate monitor
- [ ] Process manager / systemd service
- [ ] Alert channels configured
Top comments (0)