DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Deno Application with Vigilmon

How to Monitor Your Deno Application with Vigilmon

Deno is a modern JavaScript/TypeScript runtime with built-in security, native TypeScript support, and a standard library. Deno Deploy makes it easy to run Deno apps at the edge globally. This guide shows how to monitor Deno applications with Vigilmon.

Why Monitor Your Deno App?

Deno apps — especially on Deno Deploy — face edge-specific challenges:

  • Cold starts on Deno Deploy's edge network
  • Permission denials crashing the app (Deno's security model)
  • External API failures (Deno's fetch is common in edge apps)
  • Isolate crashes from unhandled errors

Step 1: Create a Health Endpoint

Deno Native HTTP Server

// main.ts
const server = Deno.serve({ port: 8000 }, (req) => {
  const url = new URL(req.url)

  if (url.pathname === '/health') {
    return Response.json({
      status: 'ok',
      runtime: 'deno',
      version: Deno.version.deno,
      timestamp: new Date().toISOString()
    })
  }

  return new Response('Hello from Deno!', { status: 200 })
})
Enter fullscreen mode Exit fullscreen mode

Run with proper permissions:

deno run --allow-net main.ts
Enter fullscreen mode Exit fullscreen mode

Hono on Deno (recommended for Deno Deploy)

import { Hono } from 'npm:hono'

const app = new Hono()

app.get('/health', (c) => {
  return c.json({
    status: 'ok',
    runtime: 'deno',
    version: Deno.version.deno,
    v8: Deno.version.v8,
    timestamp: new Date().toISOString()
  })
})

app.get('/', (c) => c.text('Hello Deno!'))

Deno.serve(app.fetch)
Enter fullscreen mode Exit fullscreen mode

Fresh Framework (Deno-native full-stack)

// routes/api/health.ts
import { Handlers } from '$fresh/server.ts'

export const handler: Handlers = {
  GET(_req, ctx) {
    return Response.json({
      status: 'ok',
      framework: 'fresh',
      timestamp: new Date().toISOString()
    })
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Health Check with External Dependency Validation

app.get('/health', async (c) => {
  const checks: Record<string, string> = {}
  let status = 'ok'

  // Check database connectivity (example: Deno KV)
  try {
    const kv = await Deno.openKv()
    await kv.get(['health_check'])
    checks.kv = 'ok'
    kv.close()
  } catch (err) {
    checks.kv = 'error'
    status = 'degraded'
  }

  // Check external API dependency
  try {
    const resp = await fetch('https://api.example.com/ping', {
      signal: AbortSignal.timeout(3000)
    })
    checks.external_api = resp.ok ? 'ok' : 'error'
  } catch {
    checks.external_api = 'error'
    status = 'degraded'
  }

  return c.json(
    { status, checks, timestamp: new Date().toISOString() },
    { status: status === 'ok' ? 200 : 503 }
  )
})
Enter fullscreen mode Exit fullscreen mode

Step 3: Deploy to Deno Deploy

# Install deployctl
deno install -gArf https://deno.land/x/deploy/deployctl.ts

# Deploy
deployctl deploy --project=my-project main.ts
Enter fullscreen mode Exit fullscreen mode

Your app gets a URL like https://my-project.deno.dev.

Step 4: Set Up Vigilmon Monitoring

  1. Sign up at vigilmon.online
  2. New MonitorHTTP(S)
  3. Configure:
    • URL: https://my-project.deno.dev/health
    • Interval: 1 minute
    • Expected status: 200
    • Timeout: 10 seconds (accounts for edge cold starts)
  4. Add Slack/email alerts

Step 5: Monitor Multiple Deno Services

If you have multiple Deno services:

Service URL Interval
Main API https://api.deno.dev/health 1 min
Webhook handler https://webhooks.deno.dev/health 5 min
Cron worker https://cron.deno.dev/health 15 min

Step 6: SSL Monitoring for Custom Domains

Deno Deploy supports custom domains. Vigilmon monitors your SSL certificate and alerts you before expiry.

For custom domain setup:

deployctl domains add api.yourapp.com --project=my-project
Enter fullscreen mode Exit fullscreen mode

Then monitor https://api.yourapp.com/health in Vigilmon.

Common Deno Issues Vigilmon Catches

Issue Symptom Vigilmon Alert
Permission error on startup 503 / connection refused Downtime alert
Unhandled async error crashes isolate 500 on all routes Status code alert
Deno Deploy cold start spike Response time > 5s Slow response alert
TypeScript compilation error Deploy fails, old version serves Behavioral diff
External API dependency down 503 from health check Downtime alert

Summary

Deno's security model and fresh approach to JavaScript runtimes make it excellent for building secure APIs. Add Vigilmon to close the observability loop — your Deno app deserves the same monitoring attention as any production service.

Start monitoring your Deno app for free →

Top comments (0)