tutorial

How to Monitor Lighterhtml with Vigilmon

Add production-grade uptime monitoring and heartbeat checks to your lighterhtml-powered web application with Vigilmon — catch outages and silent failures before your users do.

Lighterhtml brings enhanced HTML template literals to the browser and Node.js, letting you build dynamic web interfaces without a heavy framework. But when your lighterhtml app is served behind a Node.js backend or a CDN, failures happen silently — a broken API route, a dead cron job, or a CDN misconfiguration can go unnoticed for hours. Vigilmon gives you continuous HTTP monitoring, heartbeat checks, and instant alerts so you know the moment something breaks.

What You'll Build

  • A /health endpoint for your lighterhtml Node.js backend
  • Vigilmon HTTP monitors for your app and API
  • A heartbeat for scheduled background tasks
  • Alert channels (email and Slack)
  • An uptime badge embedded in your lighterhtml UI

Prerequisites

  • A Node.js project using lighterhtml (e.g. with Express or a plain HTTP server)
  • A free Vigilmon account

Step 1: Add a Health Endpoint

Lighterhtml renders HTML on the client, but your backend still needs a /health route that Vigilmon can poll:

// server.js
import express from "express";
import { createRequire } from "module";

const app = express();

app.get("/health", async (req, res) => {
  const checks = {};
  let degraded = false;

  // Database connectivity check
  try {
    // Replace with your actual DB driver check
    // await db.query("SELECT 1");
    checks.database = "ok";
  } catch (err) {
    checks.database = `error: ${err.message}`;
    degraded = true;
  }

  // External dependency check
  try {
    const response = await fetch("https://api.yourservice.com/ping", {
      signal: AbortSignal.timeout(3000),
    });
    checks.externalApi = response.ok ? "ok" : `http_${response.status}`;
  } catch {
    checks.externalApi = "unreachable";
    degraded = true;
  }

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

// Serve your lighterhtml app
app.use(express.static("public"));

app.listen(process.env.PORT ?? 3000, () => {
  console.log("Server running on port", process.env.PORT ?? 3000);
});

Test it locally:

curl http://localhost:3000/health | jq .
# {"status":"ok","timestamp":"2026-06-29T...","checks":{"database":"ok","externalApi":"ok"}}

Step 2: Configure Vigilmon HTTP Monitors

Log in to VigilmonMonitors → New Monitor:

Monitor 1: Lighterhtml App (Frontend)

| Field | Value | |---|---| | URL | https://yourapp.com/ | | Method | GET | | Expected status | 200 | | Expected body | A stable string from your rendered HTML | | Check interval | 1 minute |

Monitor 2: Health API

| Field | Value | |---|---| | URL | https://yourapp.com/health | | Method | GET | | Expected status | 200 | | Expected body | "status":"ok" | | Check interval | 1 minute |

These two monitors cover separate failure classes: static file serving issues won't show up in the API monitor, and backend database failures won't block the frontend monitor.


Step 3: Heartbeat for Background Tasks

If your lighterhtml app relies on background tasks (data polling, scheduled renders, cache warming), use a Vigilmon heartbeat to detect silent job failures:

// scheduler.js
import cron from "node-cron";

const VIGILMON_HEARTBEAT_URL = process.env.VIGILMON_HEARTBEAT_URL ?? "";

async function pingHeartbeat() {
  if (!VIGILMON_HEARTBEAT_URL) return;
  try {
    await fetch(VIGILMON_HEARTBEAT_URL, { signal: AbortSignal.timeout(5000) });
  } catch {
    // Never let heartbeat failures crash the job
  }
}

cron.schedule("*/10 * * * *", async () => {
  try {
    await refreshDataCache();
    await pingHeartbeat(); // Only ping after successful execution
  } catch (err) {
    console.error("[scheduler] Cache refresh failed:", err);
    // Vigilmon alerts when the heartbeat window expires without a ping
  }
});

async function refreshDataCache() {
  // Your actual data refresh logic
}

Set up the heartbeat monitor in Vigilmon:

  1. Monitors → New Heartbeat Monitor
  2. Set Expected interval to 20 minutes (2× the cron interval for grace window)
  3. Add the ping URL to your environment:
VIGILMON_HEARTBEAT_URL=https://vigilmon.online/api/heartbeat/xxxxxxxx

Step 4: Embed an Uptime Badge in Your Lighterhtml UI

Lighterhtml's html tagged template literal makes it straightforward to include a dynamic status badge:

// app.js (client-side lighterhtml)
import { html, render } from "lighterhtml";

const BADGE_URL = "https://vigilmon.online/api/badge/your-monitor-id.svg";
const STATUS_URL = "https://vigilmon.online/status/your-monitor-slug";

function App() {
  return html`
    <div class="app">
      <main>${renderContent()}</main>
      <footer class="footer">
        <a
          href="${STATUS_URL}"
          target="_blank"
          rel="noopener noreferrer"
          aria-label="Service uptime status"
        >
          <img src="${BADGE_URL}" alt="Uptime" width="120" height="20" />
        </a>
      </footer>
    </div>
  `;
}

render(document.body, App);

The badge automatically reflects your current uptime status without any client-side polling logic.


Step 5: Set Up Alert Channels

In Vigilmon's Alert Channels settings:

Email Alerts

  1. Alert Channels → Email → add your on-call address
  2. Attach the channel to both HTTP monitors and the heartbeat monitor

Slack Alerts

  1. Create a Slack Incoming Webhook for your #alerts channel
  2. Alert Channels → Webhook → paste the Slack webhook URL
  3. Use this payload template:
{
  "text": "🚨 *{{ monitor.name }}* is DOWN\n{{ monitor.url }}\nStatus: {{ event.status }}\n<https://vigilmon.online|Open Vigilmon>"
}

Step 6: Verify Everything Works

# 1. Confirm health endpoint returns 200
curl -s https://yourapp.com/health | jq .status

# 2. Simulate a failure — break your DB connection string and redeploy
# Expected: health endpoint returns 503; Vigilmon alerts within ~2 minutes

# 3. Comment out the heartbeat ping and let the scheduler run one cycle
# Expected: heartbeat alert fires after the grace window expires

# 4. In Vigilmon → "Test Alert" to confirm Slack/email delivery

Summary

| Monitor | What It Catches | |---|---| | HTTP app check | CDN failures, broken static file serving | | HTTP health API | Database, cache, and third-party API failures | | Heartbeat | Scheduler crashes, silent data refresh failures |


Next Steps

  • Set up separate monitors for staging and production environments
  • Use Vigilmon's response time graphs to catch latency regressions correlated with lighterhtml re-render cycles
  • Configure escalating alerts: email for recoveries, Slack for active outages

Ready to get started? Sign up for Vigilmon free — have your first monitor running in under 5 minutes.

Monitor your app with Vigilmon

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

Start free →