loading…
Search for a command to run...
loading…
Valkey-first observability with Redis compatibility. Query real-time metrics, analyze slow commands, detect hot keys, and investigate performance issues directl
Valkey-first observability with Redis compatibility. Query real-time metrics, analyze slow commands, detect hot keys, and investigate performance issues directly from AI coding assistants.
A monorepo application for monitoring Valkey/Redis databases with a NestJS backend and React frontend.
BetterDB is built by BetterDB Inc., a public benefit company operating under the OCV Open Charter.
betterdb-monitor/
├── apps/
│ ├── api/ # NestJS backend (Fastify)
│ └── web/ # React frontend (Vite)
├── packages/
│ ├── cli/ # CLI package (npx betterdb)
│ └── shared/ # Shared TypeScript types
├── docker-compose.yml # Local Valkey (port 6380) and Redis (port 6382) for testing
└── package.json # Workspace root
pnpm install
cp .env.example .env
pnpm docker:up
To connect to Redis instead of Valkey, update .env:
DB_PORT=6382
pnpm dev
The application will be available at:
Run only the API:
pnpm dev:api
Run only the web frontend:
pnpm dev:web
Stop Docker containers:
pnpm docker:down
Build for production:
pnpm build
The easiest way to run BetterDB Monitor without Docker:
npx @betterdb/monitor
On first run, an interactive setup wizard will guide you through configuration:
Configuration is saved to ~/.betterdb/config.json.
npm install -g @betterdb/monitor
betterdb
betterdb --setup # Re-run setup wizard, then start server
betterdb --port 8080 # Override server port
betterdb --db-host 1.2.3.4 # Override database host
betterdb --help # Show all options
To use SQLite storage with the CLI, install better-sqlite3:
npm install -g better-sqlite3
pnpm docker:build
For multi-arch builds (AMD64 + ARM64), first set up buildx:
docker buildx create --name mybuilder --use --bootstrap
Then build:
pnpm docker:build:multiarch
The Docker image contains only the monitoring application (backend + frontend). It requires:
docker run -d \
--name betterdb-monitor \
-p 3001:3001 \
-e DB_HOST=your-valkey-host \
-e DB_PORT=6379 \
-e DB_PASSWORD=your-password \
-e STORAGE_TYPE=memory \
betterdb/monitor
You can run the application on any port by setting the PORT environment variable with -e PORT=<port>:
docker run -d \
--name betterdb-monitor \
-p 8080:8080 \
-e PORT=8080 \
-e DB_HOST=your-valkey-host \
-e DB_PORT=6379 \
-e DB_PASSWORD=your-password \
-e STORAGE_TYPE=memory \
betterdb/monitor
Note: When not using --network host, make sure the -p flag port mapping matches the PORT environment variable (e.g., -p 8080:8080 -e PORT=8080).
docker run -d \
--name betterdb-monitor \
-p 3001:3001 \
-e DB_HOST=your-valkey-host \
-e DB_PORT=6379 \
-e DB_PASSWORD=your-password \
-e STORAGE_TYPE=postgres \
-e STORAGE_URL=postgresql://user:pass@postgres-host:5432/dbname \
betterdb/monitor
If your Valkey and PostgreSQL are running on the same host:
docker run -d \
--name betterdb-monitor \
--network host \
-e DB_HOST=localhost \
-e DB_PORT=6380 \
-e DB_PASSWORD=devpassword \
-e STORAGE_TYPE=postgres \
-e STORAGE_URL=postgresql://dev:devpass@localhost:5432/postgres \
betterdb/monitor
To automatically remove any existing container with the same name:
docker rm -f betterdb-monitor 2>/dev/null; docker run -d \
--name betterdb-monitor \
-p 3001:3001 \
-e DB_HOST=your-valkey-host \
-e DB_PORT=6379 \
-e DB_PASSWORD=your-password \
-e STORAGE_TYPE=postgres \
-e STORAGE_URL=postgresql://user:pass@postgres-host:5432/dbname \
betterdb/monitor
| Variable | Required | Default | Description |
|---|---|---|---|
DB_HOST |
Yes | localhost |
Valkey/Redis host to monitor |
DB_PORT |
No | 6379 |
Valkey/Redis port |
DB_PASSWORD |
No | - | Valkey/Redis password |
DB_USERNAME |
No | default |
Valkey/Redis ACL username |
DB_TYPE |
No | auto |
Database type: auto, valkey, or redis |
STORAGE_TYPE |
No | memory |
Storage backend: memory or postgres |
STORAGE_URL |
Conditional | - | PostgreSQL connection URL (required if STORAGE_TYPE=postgres) |
PORT |
No | 3001 |
Application HTTP port |
NODE_ENV |
No | production |
Node environment |
ANOMALY_DETECTION_ENABLED |
No | true |
Enable anomaly detection |
ANOMALY_PROMETHEUS_INTERVAL_MS |
No | 30000 |
Prometheus summary update interval (ms) |
Once running, access the web interface at:
http://localhost:3001http://localhost:3001/healthhttp://localhost:3001/prometheus/metricsnode:20-alpinelinux/amd64, linux/arm64docker logs -f betterdb-monitor
docker stop betterdb-monitor
docker rm betterdb-monitor
For deployments running RediSearch or valkey-search, BetterDB ships a dedicated Vector / AI tab that surfaces FT.SEARCH ops/sec and average latency over time alongside per-index health (docs, records, deleted docs, indexing failures, backfill progress). Stale Prometheus labels are reconciled when indexes are dropped, and the tab hides automatically when the Search module isn't available. See docs/vector-ai/ for the full walkthrough and screenshots.
| Database | Minimum Version | Supported Features |
|---|---|---|
| Valkey | 8.0+ | All features including COMMANDLOG and CLUSTER SLOT-STATS |
| Redis | 6.0+ | All features except COMMANDLOG and CLUSTER SLOT-STATS |
| Feature | Command | Valkey | Redis |
|---|---|---|---|
| Server Info | INFO |
Yes | Yes |
| Health Check | PING |
Yes | Yes |
| Slowlog | SLOWLOG |
Yes | Yes (2.2+) |
| Client List | CLIENT LIST |
Yes | Yes (2.4+) |
| Latency Monitor | LATENCY |
Yes | Yes (2.8+) |
| Memory Stats | MEMORY STATS |
Yes | Yes (4.0+) |
| ACL Log | ACL LOG |
Yes | Yes (6.0+) |
| Command Log | COMMANDLOG |
Yes (8.1+) | No (Valkey-only) |
| Cluster Slot Stats | CLUSTER SLOT-STATS |
Yes (8.0+) | No (Valkey-only) |
Unified Adapter Pattern: The backend uses a unified UnifiedDatabaseAdapter that works seamlessly with both Valkey and Redis through the wire-compatible iovalkey client library.
Auto-detection: The application automatically detects whether it's connecting to Valkey or Redis by inspecting the INFO response.
Capability Detection: Features like Command Log (Valkey 8.1+) and Slot Stats (Valkey 8.0+) are automatically detected based on database type and version. The UI gracefully degrades when connecting to Redis, showing only supported features.
Graceful Degradation: When connected to Redis, Valkey-specific features return clear error messages indicating they're not supported, while all shared features work identically.
Metrics are exposed at GET /prometheus/metrics in Prometheus text format.
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_acl_denied |
gauge | - | Total ACL denied events captured |
betterdb_acl_denied_by_reason |
gauge | reason |
ACL denied events by reason |
betterdb_acl_denied_by_user |
gauge | username |
ACL denied events by username |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_client_connections_current |
gauge | - | Current number of client connections |
betterdb_client_connections_peak |
gauge | - | Peak connections in retention period |
betterdb_client_connections_by_name |
gauge | client_name |
Current connections by client name |
betterdb_client_connections_by_user |
gauge | user |
Current connections by ACL user |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_slowlog_pattern_count |
gauge | pattern |
Number of slow queries per pattern |
betterdb_slowlog_pattern_avg_duration_us |
gauge | pattern |
Average duration in microseconds per pattern |
betterdb_slowlog_pattern_percentage |
gauge | pattern |
Percentage of slow queries per pattern |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_commandlog_large_request |
gauge | - | Total large request entries |
betterdb_commandlog_large_reply |
gauge | - | Total large reply entries |
betterdb_commandlog_large_request_by_pattern |
gauge | pattern |
Large request count by command pattern |
betterdb_commandlog_large_reply_by_pattern |
gauge | pattern |
Large reply count by command pattern |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_process_cpu_user_seconds_total |
counter | - | Total user CPU time spent in seconds |
betterdb_process_cpu_system_seconds_total |
counter | - | Total system CPU time spent in seconds |
betterdb_process_cpu_seconds_total |
counter | - | Total user and system CPU time spent in seconds |
betterdb_process_start_time_seconds |
gauge | - | Start time of the process since unix epoch in seconds |
betterdb_process_resident_memory_bytes |
gauge | - | Resident memory size in bytes |
betterdb_process_virtual_memory_bytes |
gauge | - | Virtual memory size in bytes |
betterdb_process_heap_bytes |
gauge | - | Process heap size in bytes |
betterdb_process_open_fds |
gauge | - | Number of open file descriptors |
betterdb_process_max_fds |
gauge | - | Maximum number of open file descriptors |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_nodejs_eventloop_lag_seconds |
gauge | - | Lag of event loop in seconds |
betterdb_nodejs_eventloop_lag_min_seconds |
gauge | - | Minimum recorded event loop delay |
betterdb_nodejs_eventloop_lag_max_seconds |
gauge | - | Maximum recorded event loop delay |
betterdb_nodejs_eventloop_lag_mean_seconds |
gauge | - | Mean of recorded event loop delays |
betterdb_nodejs_eventloop_lag_stddev_seconds |
gauge | - | Standard deviation of recorded event loop delays |
betterdb_nodejs_eventloop_lag_p50_seconds |
gauge | - | 50th percentile of recorded event loop delays |
betterdb_nodejs_eventloop_lag_p90_seconds |
gauge | - | 90th percentile of recorded event loop delays |
betterdb_nodejs_eventloop_lag_p99_seconds |
gauge | - | 99th percentile of recorded event loop delays |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_nodejs_active_resources |
gauge | type |
Active resources keeping the event loop alive |
betterdb_nodejs_active_resources_total |
gauge | - | Total number of active resources |
betterdb_nodejs_active_handles |
gauge | type |
Active libuv handles by type |
betterdb_nodejs_active_handles_total |
gauge | - | Total number of active handles |
betterdb_nodejs_active_requests |
gauge | type |
Active libuv requests by type |
betterdb_nodejs_active_requests_total |
gauge | - | Total number of active requests |
betterdb_nodejs_version_info |
gauge | version, major, minor, patch |
Node.js version info |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_nodejs_heap_size_total_bytes |
gauge | - | Process heap size from Node.js in bytes |
betterdb_nodejs_heap_size_used_bytes |
gauge | - | Process heap size used from Node.js in bytes |
betterdb_nodejs_external_memory_bytes |
gauge | - | Node.js external memory size in bytes |
betterdb_nodejs_heap_space_size_total_bytes |
gauge | space |
Process heap space size total in bytes |
betterdb_nodejs_heap_space_size_used_bytes |
gauge | space |
Process heap space size used in bytes |
betterdb_nodejs_heap_space_size_available_bytes |
gauge | space |
Process heap space size available in bytes |
| Metric | Type | Labels | Description |
|---|---|---|---|
betterdb_nodejs_gc_duration_seconds |
histogram | kind |
Garbage collection duration (major, minor, incremental, weakcb) |
Edit .env to configure the Valkey/Redis database connection:
DB_HOST=localhost
DB_PORT=6379
DB_USERNAME=default
DB_PASSWORD=devpassword
DB_TYPE=auto # 'valkey' | 'redis' | 'auto'
BetterDB Monitor supports multiple storage backends for persisting audit trail and client analytics data:
STORAGE_TYPE=sqlite
STORAGE_SQLITE_FILEPATH=./data/audit.db # Optional, defaults to this path
apps/api/data/audit.dbSTORAGE_TYPE=postgres
STORAGE_URL=postgresql://username:password@host:port/database
postgresql://dev:devpass@localhost:5432/postgresSTORAGE_TYPE=memory
STORAGE_TYPE=sqlite \
DB_HOST=localhost \
DB_PORT=6380 \
DB_PASSWORD=devpassword \
pnpm dev:api
# Start PostgreSQL (if using docker-compose)
docker compose up -d postgres
# Run API with PostgreSQL
STORAGE_TYPE=postgres \
STORAGE_URL=postgresql://betterdb:devpassword@localhost:5432/betterdb \
DB_HOST=localhost \
DB_PORT=6380 \
DB_PASSWORD=devpassword \
pnpm dev:api
STORAGE_TYPE=memory \
DB_HOST=localhost \
DB_PORT=6380 \
DB_PASSWORD=devpassword \
pnpm dev:api
The codebase is structured to make it easy to add new monitoring features:
apps/api/src/apps/web/src/api/packages/shared/src/types/any types allowedMIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"betterdb-inc-monitor": {
"command": "npx",
"args": []
}
}
}Query your database in natural language
Read-only database access with schema inspection.
Interact with Redis key-value stores.
Database interaction and business intelligence capabilities.