DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your SurrealDB Instance with Vigilmon

How to Monitor Your SurrealDB Instance with Vigilmon

SurrealDB is a multi-model database that combines document, relational, graph, and time-series data in a single database. Teams adopting it for modern applications get flexibility without managing multiple data stores. But like any database, SurrealDB needs external monitoring to ensure it's reachable and healthy.

This guide shows how to set up uptime monitoring for SurrealDB with Vigilmon.

SurrealDB Health Endpoints

SurrealDB exposes built-in health check endpoints:

# Health check
curl http://localhost:8000/health
# Returns 200 OK when healthy

# Status check with details
curl http://localhost:8000/status
# {"code":200,"details":"Check was successful","description":"Node is ready for queries"}
Enter fullscreen mode Exit fullscreen mode

Step 1: Start SurrealDB

# Docker
docker run --rm -p 8000:8000 \
  surrealdb/surrealdb:latest \
  start \
  --user root \
  --pass root \
  memory
Enter fullscreen mode Exit fullscreen mode

Step 2: Add to Vigilmon

  1. Log in at vigilmon.online
  2. Click + Add Monitor
  3. Enter URL: https://db.your-app.com/health
  4. Check interval: 1 minute
  5. Expected status: 200
  6. Save and set up alerts

Step 3: Application Health Route

TypeScript (surrealdb.js):

import Surreal from "surrealdb.js";

const db = new Surreal();

async function connect() {
  await db.connect("http://localhost:8000/rpc");
  await db.signin({ user: "root", pass: "root" });
  await db.use({ ns: "myns", db: "mydb" });
}

app.get("/health", async (req, res) => {
  try {
    await db.query("SELECT 1");
    res.json({ status: "ok", database: "surrealdb" });
  } catch (err) {
    res.status(503).json({ status: "error", message: err.message });
  }
});
Enter fullscreen mode Exit fullscreen mode

Rust (surrealdb crate):

use surrealdb::Surreal;
use surrealdb::engine::remote::http::Http;
use axum::{routing::get, Json, Router};

async fn health_check() -> Json<serde_json::Value> {
    let db = Surreal::new::<Http>("localhost:8000").await.unwrap();
    match db.query("SELECT 1").await {
        Ok(_) => Json(serde_json::json!({"status": "ok"})),
        Err(e) => Json(serde_json::json!({"status": "error", "message": e.to_string()})),
    }
}
Enter fullscreen mode Exit fullscreen mode

Docker Compose with Health Check

version: "3.8"
services:
  surrealdb:
    image: surrealdb/surrealdb:latest
    command:
      - start
      - --user=root
      - --pass=${SURREAL_PASS}
      - file:///data/database.db
    ports:
      - "8000:8000"
    volumes:
      - surreal_data:/data
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped

volumes:
  surreal_data:
Enter fullscreen mode Exit fullscreen mode

What to Monitor

Endpoint Purpose
GET /health Is SurrealDB running?
GET /status Is SurrealDB ready for queries?
App GET /health Can your app query SurrealDB?

Alert Configuration

  • Immediate alerts: SurrealDB failures affect all database reads/writes
  • Multi-region checks: Verify reachability from multiple geographic regions
  • Recovery alert: Confirm cluster is back

SurrealDB's flexibility is one of its greatest strengths, but operational reliability still requires external monitoring.


Vigilmon — free uptime monitoring for SurrealDB, PostgreSQL, and any HTTP endpoint.

Top comments (0)