tutorial

Monitoring Your Riot.js App with Vigilmon: Health Checks, Heartbeats & Uptime Alerts

Add production-grade monitoring to a Riot.js application — a health API, background job heartbeats, and instant alerts when your custom-tag UI or backend goes down.

Riot.js takes a minimal, component-centric approach to building web UIs — custom tags keep markup, logic, and styles together without a heavy build pipeline. But a clean component model won't save you when your app is down or your API is silently returning 503s. Vigilmon gives you the visibility you need: continuous HTTP monitoring, heartbeat checks, and instant alerts via email or Slack.

What You'll Build

  • A health API endpoint alongside your Riot.js frontend
  • Vigilmon HTTP monitors for your SPA and backend
  • A heartbeat for scheduled background tasks
  • Alert channels (email and Slack)
  • An uptime badge embedded in a Riot custom tag

Prerequisites

  • A Riot.js project (Riot + Vite or a classic <script> setup)
  • Node.js/Express backend for the health endpoint
  • A free Vigilmon account

Step 1: Add a Health Endpoint

Riot.js is a frontend library, so health checks live on your backend. Add a /health route to your Express server:

// server.js (Express)
import express from "express";

const app = express();

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

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

  // Cache check
  try {
    // await redisClient.ping();
    checks.cache = "ok";
  } catch (err) {
    checks.cache = `error: ${err.message}`;
    degraded = true;
  }

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

app.listen(process.env.PORT ?? 3000);

Test it:

curl http://localhost:3000/health | jq .
# {"status":"ok","timestamp":"2026-07-03T...","checks":{"database":"ok","cache":"ok"}}

Step 2: Configure Vigilmon HTTP Monitors

Log in to VigilmonMonitors → New Monitor:

Monitor 1: Riot.js SPA

| Field | Value | |---|---| | URL | https://yourapp.com/ | | Method | GET | | Expected status | 200 | | Expected body | A stable string from your HTML (e.g. <app-root> or your page title) | | Check interval | 1 minute |

Monitor 2: Health API

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

Two monitors cover two independent failure surfaces: your CDN/static layer and your backend data layer.


Step 3: Heartbeat for Background Tasks

Silent job failures are one of the most common production blind spots. A Vigilmon heartbeat alerts you when a scheduled job stops pinging within the expected window.

npm install node-cron
// 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 {
    // Monitoring must never crash the job
  }
}

cron.schedule("*/15 * * * *", async () => {
  try {
    await syncContentFromCMS();
    await pingHeartbeat();
  } catch (err) {
    console.error("[scheduler] Content sync failed:", err);
  }
});

async function syncContentFromCMS() {
  // Your actual sync logic
}

Set up the heartbeat in Vigilmon:

  1. Monitors → New Heartbeat Monitor
  2. Set Expected interval to 30 minutes (2× the cron interval)
  3. Copy the ping URL to your .env:
VIGILMON_HEARTBEAT_URL=https://vigilmon.online/api/heartbeat/xxxxxxxx

Step 4: Display Uptime Status in a Riot Custom Tag

Riot custom tags let you encapsulate the badge component cleanly:

<!-- src/tags/status-badge.riot -->
<status-badge>
  <a href="{ statusUrl }" target="_blank" rel="noopener noreferrer" aria-label="Service uptime">
    <img
      src="{ badgeUrl }"
      alt="Uptime"
      width="120"
      height="20"
      onload="{ onImageLoad }"
      style="opacity: { loaded ? 1 : 0 }; transition: opacity 0.2s;"
    />
  </a>

  <script>
    export default {
      badgeUrl: 'https://vigilmon.online/api/badge/your-monitor-id.svg',
      statusUrl: 'https://vigilmon.online/status/your-monitor-slug',
      loaded: false,

      onImageLoad() {
        this.update({ loaded: true });
      },
    };
  </script>
</status-badge>

Mount it anywhere in your app:

<!-- index.html -->
<status-badge></status-badge>

<script type="module">
  import { component } from 'riot';
  import StatusBadge from './src/tags/status-badge.riot';

  component(StatusBadge)(document.querySelector('status-badge'));
</script>

Step 5: Set Up Alert Channels

In Vigilmon's Alert Channels settings:

Email

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

Slack

  1. Create a Slack Incoming Webhook for #alerts
  2. Alert Channels → Webhook → paste the URL
  3. 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. Health endpoint
curl -s https://yourapp.com/health | jq .

# 2. Break the DB connection string → confirm health returns 503
# Expected: Vigilmon alerts within 2 minutes

# 3. Remove VIGILMON_HEARTBEAT_URL → let the cron job run without pinging
# Expected: heartbeat alert fires after the grace window expires

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

Summary

| Monitor | What It Catches | |---|---| | HTTP SPA check | CDN failures, broken static deploys | | HTTP health API | Database, cache, and third-party API failures | | Heartbeat | Scheduler crashes, silent sync failures |


Next Steps

  • Create separate monitors for staging vs. production
  • Use Vigilmon's response time graphs to spot backend latency trends over time
  • Configure multi-channel alerting: email for low-severity, Slack for critical

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 →