DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor CouchDB with Vigilmon

How to Monitor CouchDB with Vigilmon

CouchDB is a document-oriented NoSQL database with a unique replication model and built-in HTTP API. Used for offline-first applications, mobile sync with PouchDB, and distributed systems, CouchDB availability is critical to your application's data layer. Vigilmon monitors CouchDB uptime and SSL certificates, alerting you the moment anything goes wrong.

CouchDB's Built-In Health Endpoints

CouchDB has native REST API endpoints that make monitoring straightforward:

# Cluster membership and status
curl http://localhost:5984/_up
# Returns: {"status":"ok"} when healthy

# General server info
curl http://localhost:5984/
# Returns server version and vendor info

# Cluster node status
curl -u admin:password http://localhost:5984/_node/_local
Enter fullscreen mode Exit fullscreen mode

Setting Up Vigilmon for CouchDB

1. Use the Built-In /_up Endpoint

CouchDB's /_up endpoint returns HTTP 200 and {"status":"ok"} when the server is healthy, and HTTP 404 or 503 when it's not. This is purpose-built for load balancers and monitoring tools.

# Test it first:
curl -v http://your-couchdb-host:5984/_up
Enter fullscreen mode Exit fullscreen mode

2. Create Your Vigilmon Account

Sign up at vigilmon.online — free, no credit card required.

3. Add CouchDB Monitor

  1. Click Add Monitor
  2. URL: http://your-couchdb-host:5984/_up
  3. Type: HTTP/HTTPS
  4. Expected Status: 200
  5. Interval: 1 minute
  6. Alert: Email or Slack

CouchDB Behind a Reverse Proxy

For production CouchDB behind Nginx:

server {
    listen 443 ssl;
    server_name couchdb.example.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    # Expose health check endpoint publicly
    location = /_up {
        proxy_pass http://couchdb-backend:5984/_up;
        proxy_set_header X-Real-IP $remote_addr;
    }

    # Protect the rest of the API
    location / {
        auth_basic "CouchDB";
        auth_basic_user_file /etc/nginx/.htpasswd;
        proxy_pass http://couchdb-backend:5984;
    }
}
Enter fullscreen mode Exit fullscreen mode

Monitor https://couchdb.example.com/_up with Vigilmon.

Application-Level Health Check

For deeper health verification from your application:

// Node.js with nano (CouchDB client)
const nano = require('nano')(process.env.COUCHDB_URL);
const express = require('express');
const app = express();

app.get('/health', async (req, res) => {
  try {
    // Check CouchDB is up and a specific DB is accessible
    await nano.db.get(process.env.COUCHDB_DB);
    res.json({ status: 'ok', couchdb: 'healthy' });
  } catch (err) {
    res.status(503).json({
      status: 'error',
      detail: err.message
    });
  }
});

app.listen(3000);
Enter fullscreen mode Exit fullscreen mode
# Python with couchdb-python
import couchdb
from flask import Flask, jsonify
import os

app = Flask(__name__)

@app.get('/health')
def health():
    try:
        server = couchdb.Server(os.environ['COUCHDB_URL'])
        db = server[os.environ['COUCHDB_DB']]
        # Check db info to verify connectivity
        db.info()
        return jsonify({'status': 'ok', 'couchdb': 'healthy'})
    except Exception as e:
        return jsonify({'status': 'error', 'detail': str(e)}), 503
Enter fullscreen mode Exit fullscreen mode

Monitor CouchDB Clusters

CouchDB supports clustering. Monitor each node:

Node Endpoint Notes
Node 1 node1:5984/_up Primary
Node 2 node2:5984/_up Replica
Node 3 node3:5984/_up Replica
Cluster couchdb.example.com/_up Load balancer endpoint

PouchDB Sync Monitoring

If you use CouchDB for PouchDB sync (offline-first web/mobile apps):

// Monitor the sync endpoint
app.get('/health/sync', async (req, res) => {
  try {
    const response = await fetch(`${process.env.COUCHDB_URL}/_up`);
    if (response.ok) {
      res.json({ status: 'ok', sync: 'available' });
    } else {
      res.status(503).json({ status: 'degraded', sync: 'unavailable' });
    }
  } catch (err) {
    res.status(503).json({ status: 'error' });
  }
});
Enter fullscreen mode Exit fullscreen mode

Monitor /health/sync — when it's down, all offline clients stop syncing.

SSL Certificate Monitoring

If CouchDB or your proxy uses HTTPS, Vigilmon automatically monitors the SSL certificate. You'll get alerts 14, 7, and 3 days before expiry.

Alerting Configuration

Alert channels:
- Email: dba@yourcompany.com, devops@yourcompany.com
- Slack: #database-alerts
- Webhook: PagerDuty or OpsGenie integration
Enter fullscreen mode Exit fullscreen mode

Create an Internal Status Page

Create a Vigilmon status page for your database team:

  1. Go to Status PagesCreate
  2. Add CouchDB monitors
  3. Share the link internally

Conclusion

CouchDB's built-in /_up endpoint makes it one of the easiest databases to monitor. Vigilmon gives you:

  • 1-minute availability checks
  • SSL certificate monitoring
  • Multi-channel alerting
  • Status page for your team

Start free at vigilmon.online.

Top comments (0)