How to Monitor SQLite Databases with Vigilmon
SQLite is the world's most widely deployed database — embedded in mobile apps, IoT devices, edge servers, and many web applications. Unlike PostgreSQL or MySQL, SQLite doesn't have a network interface, so traditional database monitors don't apply. But that doesn't mean you can't monitor it effectively.
This guide shows how to monitor SQLite-backed applications using Vigilmon.
Monitoring SQLite: A Different Approach
Since SQLite is a file-based embedded database with no network port, you monitor:
- The application that uses SQLite (HTTP health endpoints)
- Application-level database checks (can the app query its own DB?)
- Background job liveness (for write-intensive cron jobs)
- Disk space (SQLite databases can grow unexpectedly)
Step 1: Add a Database Health Check to Your App
Node.js (with better-sqlite3)
// healthcheck.js
const Database = require('better-sqlite3');
const express = require('express');
const app = express();
const db = new Database('./app.db');
app.get('/health', (req, res) => {
try {
// Quick query to verify DB is accessible
const result = db.prepare('SELECT 1 AS ok').get();
res.json({ status: 'ok', db: 'ok', timestamp: Date.now() });
} catch (err) {
res.status(503).json({ status: 'error', db: 'error', error: err.message });
}
});
app.listen(3000);
Python (with sqlite3)
# healthcheck.py (Flask example)
import sqlite3
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/health')
def health():
try:
conn = sqlite3.connect('./app.db')
conn.execute('SELECT 1')
conn.close()
return jsonify({'status': 'ok', 'db': 'ok'})
except Exception as e:
return jsonify({'status': 'error', 'db': str(e)}), 503
Go (with modernc.org/sqlite)
// healthcheck.go
func healthHandler(db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if err := db.Ping(); err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
json.NewEncoder(w).Encode(map[string]string{"status": "error"})
return
}
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
}
}
Step 2: Monitor Disk Space
SQLite databases are just files. A full disk = database write failures. Use a lightweight script as a heartbeat:
#!/bin/bash
# check-sqlite-disk.sh — run every 5 minutes via cron
DB_FILE="/var/app/app.db"
VIGILMON_HB="https://hb.vigilmon.online/your-heartbeat-id"
# Check if file exists
if [ ! -f "$DB_FILE" ]; then
echo "ERROR: SQLite database file missing!"
exit 1
fi
# Check disk usage (alert if > 80%)
DISK_USED=$(df "$DB_FILE" | tail -1 | awk '{print $5}' | tr -d '%')
if [ "$DISK_USED" -lt 80 ]; then
curl -s "$VIGILMON_HB" > /dev/null
fi
# Log DB file size
DB_SIZE=$(du -h "$DB_FILE" | cut -f1)
echo "DB size: $DB_SIZE, Disk used: ${DISK_USED}%"
# crontab -e
*/5 * * * * /var/app/check-sqlite-disk.sh
Step 3: Register in Vigilmon
- Sign up at vigilmon.online
- Add an HTTP monitor for your app's
/healthendpoint - Set the keyword check to look for
"status":"ok"and"db":"ok" - Add a heartbeat monitor for your disk-check script
SQLite-Specific Failure Modes to Monitor
| Failure | Symptom | Monitor |
|---|---|---|
| Database file locked | 503 from app | HTTP health check |
| Disk full | Writes fail silently | Disk heartbeat |
| Corrupted DB | Queries return errors | HTTP health check |
| WAL file too large | Slow queries | Response time monitor |
| App crash | No response | HTTP availability |
Turso (Distributed SQLite)
If you're using Turso (distributed SQLite), Vigilmon can monitor your Turso HTTP API endpoint:
https://your-db.turso.io/v2/pipeline
Add this as an HTTP monitor with a POST body containing a simple SQL query.
Conclusion
SQLite monitoring is about monitoring what SQLite does: serving your application and writing to disk. With Vigilmon's HTTP and heartbeat monitors, you get full visibility into your SQLite-backed application's health.
Start monitoring your SQLite app for free at vigilmon.online
Top comments (0)