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"}
Step 1: Start SurrealDB
# Docker
docker run --rm -p 8000:8000 \
surrealdb/surrealdb:latest \
start \
--user root \
--pass root \
memory
Step 2: Add to Vigilmon
- Log in at vigilmon.online
- Click + Add Monitor
- Enter URL:
https://db.your-app.com/health - Check interval: 1 minute
- Expected status: 200
- 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 });
}
});
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()})),
}
}
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:
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)