tutorial

How to Monitor Uce with Vigilmon

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

Uce is a micro HTML template engine that brings tagged template literals to the browser for efficient, reactive DOM updates without a heavy framework. Whether you serve a uce-powered single-page app from a Node.js backend or a CDN, failures happen silently — a broken API route, a crashed background job, or a misconfigured deployment can go undetected 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 uce Node.js backend
  • Vigilmon HTTP monitors for your app and API
  • A heartbeat monitor for background tasks
  • Alert channels (email and Slack)
  • An uptime badge embedded in your uce UI

Prerequisites

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

Step 1: Add a Health Endpoint

Uce handles client-side DOM rendering, but your backend needs an HTTP health route that Vigilmon can poll continuously:

// server.js
import express from "express";

const app = express();

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

  // Database connectivity check
  try {
    // 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 uce app's static files
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-07-03T...","checks":{"database":"ok","externalApi":"ok"}}

Step 2: Configure Vigilmon HTTP Monitors

Log in to VigilmonMonitors → New Monitor:

Monitor 1: Uce App (Frontend)

| Field | Value | |---|---| | URL | https://yourapp.com/ | | Method | GET | | Expected status | 200 | | Expected body | A stable string from your HTML shell | | 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 |

Two independent monitors distinguish a CDN failure (frontend down, API up) from a backend database failure (API down, frontend still cached).


Step 3: Heartbeat for Background Tasks

If your uce app depends on background jobs — data polling, scheduled renders, cache warming — a Vigilmon heartbeat monitor detects silent failures that don't surface in HTTP checks:

// 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
  }
}

// Run every 10 minutes
cron.schedule("*/10 * * * *", async () => {
  try {
    await refreshDataCache();
    await pingHeartbeat(); // Only ping on success
  } catch (err) {
    console.error("[scheduler] Cache refresh failed:", err);
    // No ping → Vigilmon alerts when the heartbeat window expires
  }
});

async function refreshDataCache() {
  // Fetch and store the data your uce UI consumes
}

Set up the heartbeat in Vigilmon:

  1. Monitors → New Heartbeat Monitor
  2. Set Expected interval to 20 minutes (2× the cron interval for a 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 Uce UI

Uce's html tagged template literal makes it easy to include a live Vigilmon status badge in your rendered output:

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

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

const App = {
  render() {
    return html`
      <div class="app">
        <main>${this.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>
    `;
  },
  renderContent() {
    return html`<p>Your app content here.</p>`;
  },
};

render(document.body, App);

The badge reflects your current uptime status automatically — no client-side polling required.


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. Remove the heartbeat URL 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

  • Create separate Vigilmon projects for staging and production environments
  • Use Vigilmon's response time graphs to detect latency regressions when your uce component tree grows
  • 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 →