Monitoring

Since 4.6.5 the server answers HTTP next to the database port, for health checks and metrics. It listens on port 34568 and, unless configured otherwise, on 127.0.0.1 only.

RouteAnswer
GET /health200 and the server state as JSON. 503 while requests are refused because memory is almost exhausted
GET /metricsMetrics in the Prometheus text format

Health


curl http://127.0.0.1:34568/health
        

{
  "status": "ok",
  "version": "4.6.5",
  "serverId": "dianadbnode1",
  "uptimeSeconds": 86400,
  "memory": 21.83,
  "cpu": 0.53,
  "memoryGuard": { "exhausted": false, "used": 125, "limit": 4481, "reservePercent": 5 },
  "cluster": {
    "peers": [{ "address": "10.0.0.2:34569", "serverId": "dianadbnode2", "connected": true, "syncing": false }],
    "receivers": ["dianadbnode2"],
    "pendingChanges": 0
  }
}
        

status is ok or memory exhausted (with HTTP 503, see the memory guard). cluster is present on servers of a cluster; a peer that is not connected has a reason. Use the route for load balancer and container health checks.

Metrics

/metrics reads counters only, so scraping it does not scan data. Every metric name starts with diana_db_.

MetricsWhat they show
info, uptime_secondsVersion, server id and time since start
connections, subscribersOpen client connections
requests_total, request_seconds_totalRequests by action and result, and the time spent executing them
memory_*, heap_*, cpu_percent, event_loop_*Memory in use and its limit, whether requests are being refused, CPU and event loop load
wal_*Write-ahead log: changes written, changes not on disk yet, failures, time of the last write
snapshots_total, snapshot_*Snapshots saved and failed, duration and time of the last one
databases, collections, documentsCounts; documents per database and collection
cluster_* On servers of a cluster: connected peers, changes made, applied, sent and waiting, whole-state transfers, refused connections, remembered removals and the clock difference

Prometheus scrape configuration:


scrape_configs:
  - job_name: diana-db
    static_configs:
      - targets: ['127.0.0.1:34568']
    # with http_token set:
    # authorization:
    #   credentials: <token>
        

Settings

KeyDefaultDescription
http10 turns the HTTP server off
http_port34568Port
http_host127.0.0.1Address to listen on. 0.0.0.0 accepts requests from other machines
http_token–16 or more characters. Requests then need Authorization: Bearer <token>

curl -H "Authorization: Bearer $TOKEN" http://db.example.com:34568/metrics
        

When the port is busy the problem is logged and the database keeps running without the HTTP server. In Docker set DIANA_DB_HTTP_HOST=0.0.0.0 and publish the port to reach it from the host.