tutorial

How to Monitor Lucia with Vigilmon

Add production-grade uptime monitoring to your Lucia-powered server-rendered app — health endpoint, Vigilmon HTTP and keyword monitors, and alert configuration.

How to Monitor Lucia with Vigilmon

Lucia is a tiny JavaScript framework for sprinkling interactivity onto server-rendered HTML with minimal JavaScript. It keeps your pages fast by default — but a fast framework won't catch a downed server or a broken deploy. You need an external eye watching your production URL around the clock.

This tutorial walks through:

  • A /health endpoint in your Lucia-backed server
  • An HTTP uptime monitor in Vigilmon
  • A keyword monitor that confirms your pages are actually rendering
  • Slack or email alerts when anything goes wrong

The full setup takes about 15 minutes.


Step 1: Add a health endpoint to your server

Lucia sits on top of your existing server framework (Express, Hono, Node HTTP, etc.). Add a lightweight /health route that returns JSON:

// server.js (Express example)
import express from 'express';

const app = express();

app.get('/health', (req, res) => {
  res.json({
    status: 'ok',
    service: 'lucia-app',
    timestamp: new Date().toISOString(),
  });
});

app.listen(3000);

For a deeper check that exercises your auth layer or database:

app.get('/health', async (req, res) => {
  const checks = {};
  let healthy = true;

  try {
    // Lightweight database ping
    await db.execute('SELECT 1');
    checks.database = 'ok';
  } catch {
    checks.database = 'error';
    healthy = false;
  }

  res.status(healthy ? 200 : 503).json({
    status: healthy ? 'ok' : 'degraded',
    checks,
    timestamp: new Date().toISOString(),
  });
});

A 503 on failure means Vigilmon immediately detects the outage without needing a body check.

Verify locally:

node server.js
curl http://localhost:3000/health
# {"status":"ok","service":"lucia-app","timestamp":"..."}

Step 2: Set up an HTTP monitor in Vigilmon

Deploy your app then connect it to Vigilmon:

  1. Sign up at vigilmon.online — free, no card required
  2. Click New Monitor → HTTP
  3. URL: https://yourapp.example.com/health
  4. Check interval: 1 minute (paid) or 5 minutes (free)
  5. Expected status: 200
  6. Save

Vigilmon probes from multiple regions. If your /health route returns anything other than 200 — or times out — you get alerted immediately.


Step 3: Add a keyword monitor for your rendered pages

Your health endpoint checks the server. A keyword monitor checks that Lucia's interactivity layer is loading correctly and your HTML is rendering as expected.

In Vigilmon:

  1. Click New Monitor → Keyword
  2. URL: https://yourapp.example.com/
  3. Keyword: a static string from your layout — your app name, a nav label, or a footer copyright line
  4. Match type: Contains
  5. Expected status: 200
  6. Save

If a deploy breaks your template rendering but leaves the server running, only the keyword monitor catches it.


Step 4: Configure alerts

Go to Notifications → New Channel in Vigilmon and pick your channel type:

Slack:

  1. Create an incoming webhook at api.slack.com/apps
  2. Paste the URL into Vigilmon's Slack channel config
  3. Enable it on both your monitors

Email:

  1. Add your email address as a notification channel
  2. Enable it on the monitors you want coverage for

When your app goes down, the alert lands within the check interval:

🔴 DOWN: yourapp.example.com/health
Status: 503
Region: EU-West
3 minutes ago

When it recovers:

✅ RECOVERED: yourapp.example.com/health
Downtime: 6 minutes

For critical production apps, enable both Slack (immediate) and email (paper trail).


Step 5: Heartbeat monitoring for background jobs

If your app runs scheduled tasks — session cleanup, data sync, email jobs — HTTP monitoring won't catch a silent failure there.

Add a heartbeat ping at the end of each job:

// jobs/session-cleanup.js
import { lucia } from '../auth/lucia.js';

async function cleanupExpiredSessions() {
  await lucia.deleteExpiredSessions();

  const heartbeatUrl = process.env.VIGILMON_CLEANUP_HEARTBEAT;
  if (heartbeatUrl) {
    await fetch(heartbeatUrl);
  }
}

cleanupExpiredSessions().catch(console.error);

In Vigilmon, create a Heartbeat Monitor:

  1. Click New Monitor → Heartbeat
  2. Set the expected interval to match your job schedule
  3. Copy the ping URL
  4. Set VIGILMON_CLEANUP_HEARTBEAT=<url> in your environment

If the job stops running or throws, Vigilmon alerts you after one missed interval.


Step 6: Public status page

Go to Status Pages → New Status Page in Vigilmon, add your monitors, and publish. Drop the URL in your README or error pages:

Service unavailable. Check our status page: https://status.yourapp.example.com

Each monitor also generates a live badge:

![App Status](https://vigilmon.online/badge/your-monitor-slug)

What you've built

| What | How | |------|-----| | Health endpoint | /health route in your server | | HTTP uptime check | Vigilmon HTTP monitor | | Rendering check | Vigilmon keyword monitor on home page | | Slack/email alerts | Vigilmon notification channels | | Job monitoring | Heartbeat ping in scheduled handlers | | Status page | Vigilmon public status page |

Lucia keeps your JavaScript footprint small. Vigilmon keeps your uptime visible when it matters.


Next steps

  • Add monitors for critical API routes your frontend depends on
  • Watch response time trends — Vigilmon charts latency over time, and gradual slowdowns are often visible before a full outage
  • Add a heartbeat for every background job

Get started free at vigilmon.online.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →