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.
| Route | Answer |
|---|---|
GET /health | 200 and the server state as JSON. 503 while requests are refused because memory is almost exhausted |
GET /metrics | Metrics 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_.
| Metrics | What they show |
|---|---|
info, uptime_seconds | Version, server id and time since start |
connections, subscribers | Open client connections |
requests_total, request_seconds_total | Requests 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, documents | Counts; 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
| Key | Default | Description |
|---|---|---|
http | 1 | 0 turns the HTTP server off |
http_port | 34568 | Port |
http_host | 127.0.0.1 | Address 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
The HTTP server has no TLS of its own. Set
http_token before opening it to other machines, and keep it inside a private network or behind a proxy that adds TLS. 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.