@betterdb/monitor 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -0
- package/bin/betterdb.js +2 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# BetterDB Monitor CLI
|
|
2
|
+
|
|
3
|
+
Monitor and observe your Valkey/Redis databases from the command line.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Quick Start (npx)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @betterdb/monitor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Global Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @betterdb/monitor
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Package Manager
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# pnpm
|
|
23
|
+
pnpm dlx @betterdb/monitor
|
|
24
|
+
|
|
25
|
+
# yarn
|
|
26
|
+
yarn dlx @betterdb/monitor
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### First Run
|
|
32
|
+
|
|
33
|
+
On first run, BetterDB will launch an interactive setup wizard to configure:
|
|
34
|
+
|
|
35
|
+
- Database connection (host, port, type, credentials)
|
|
36
|
+
- Storage backend (SQLite, PostgreSQL, or in-memory)
|
|
37
|
+
- Application settings (port, anomaly detection)
|
|
38
|
+
- Optional security settings (encryption key, license)
|
|
39
|
+
|
|
40
|
+
Configuration is saved to `~/.betterdb/config.json`.
|
|
41
|
+
|
|
42
|
+
### Commands
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Start the monitor (runs setup if no config exists)
|
|
46
|
+
betterdb
|
|
47
|
+
|
|
48
|
+
# Run the setup wizard
|
|
49
|
+
betterdb setup
|
|
50
|
+
betterdb --setup
|
|
51
|
+
|
|
52
|
+
# Skip setup wizard (uses defaults or exits if no config)
|
|
53
|
+
betterdb --no-setup
|
|
54
|
+
|
|
55
|
+
# Show version
|
|
56
|
+
betterdb --version
|
|
57
|
+
|
|
58
|
+
# Show help
|
|
59
|
+
betterdb --help
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### CLI Flags
|
|
63
|
+
|
|
64
|
+
Override configuration with command-line flags:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
betterdb --port 8080 # Custom server port
|
|
68
|
+
betterdb --db-host 192.168.1.5 # Custom database host
|
|
69
|
+
betterdb --db-port 6380 # Custom database port
|
|
70
|
+
betterdb --storage-type memory # Use in-memory storage
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
Configuration is stored at `~/.betterdb/config.json`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"database": {
|
|
80
|
+
"host": "localhost",
|
|
81
|
+
"port": 6379,
|
|
82
|
+
"username": "default",
|
|
83
|
+
"password": "",
|
|
84
|
+
"type": "auto"
|
|
85
|
+
},
|
|
86
|
+
"storage": {
|
|
87
|
+
"type": "sqlite",
|
|
88
|
+
"sqlitePath": "~/.betterdb/data/audit.db"
|
|
89
|
+
},
|
|
90
|
+
"security": {},
|
|
91
|
+
"app": {
|
|
92
|
+
"port": 3001,
|
|
93
|
+
"anomalyDetection": true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Storage Options
|
|
99
|
+
|
|
100
|
+
#### SQLite (Default)
|
|
101
|
+
|
|
102
|
+
Requires `better-sqlite3` to be installed:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install better-sqlite3
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### PostgreSQL
|
|
109
|
+
|
|
110
|
+
Provide a connection URL:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"storage": {
|
|
115
|
+
"type": "postgres",
|
|
116
|
+
"postgresUrl": "postgresql://user:password@localhost:5432/betterdb"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### In-Memory
|
|
122
|
+
|
|
123
|
+
No persistence, data is lost on restart:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"storage": {
|
|
128
|
+
"type": "memory"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Access Points
|
|
134
|
+
|
|
135
|
+
After starting, the following endpoints are available:
|
|
136
|
+
|
|
137
|
+
- **Web UI**: http://localhost:3001
|
|
138
|
+
- **API**: http://localhost:3001/api
|
|
139
|
+
- **API Docs**: http://localhost:3001/api/docs
|
|
140
|
+
|
|
141
|
+
## Requirements
|
|
142
|
+
|
|
143
|
+
- Node.js >= 20.0.0
|
|
144
|
+
- Valkey or Redis instance to monitor
|
|
145
|
+
- (Optional) `better-sqlite3` for SQLite storage
|
|
146
|
+
|
|
147
|
+
## Security
|
|
148
|
+
|
|
149
|
+
When an encryption key is configured, database passwords are encrypted at rest using AES-256-GCM envelope encryption. Set the encryption key during setup or via the `ENCRYPTION_KEY` environment variable.
|
|
150
|
+
|
|
151
|
+
## Publishing (Maintainers)
|
|
152
|
+
|
|
153
|
+
The CLI is published automatically via GitHub Actions when a version tag is pushed:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Update version in root package.json and packages/cli/package.json
|
|
157
|
+
# Then tag and push
|
|
158
|
+
git tag v0.5.0
|
|
159
|
+
git push origin v0.5.0
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This will:
|
|
163
|
+
1. Build the CLI package
|
|
164
|
+
2. Publish to npm with provenance
|
|
165
|
+
3. Create a GitHub Release with the tarball
|
|
166
|
+
|
|
167
|
+
**Required secrets:**
|
|
168
|
+
- `NPM_TOKEN` - npm automation token with publish access
|
|
169
|
+
|
|
170
|
+
**Manual publishing:**
|
|
171
|
+
```bash
|
|
172
|
+
pnpm cli:build
|
|
173
|
+
cd packages/cli
|
|
174
|
+
npm publish --access public
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
See LICENSE in the repository root.
|
package/bin/betterdb.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@betterdb/monitor",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Monitor and observe your Valkey/Redis databases",
|
|
5
|
+
"bin": {
|
|
6
|
+
"betterdb": "./bin/betterdb.js"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"dist/",
|
|
14
|
+
"assets/"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20.0.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "node scripts/build.mjs",
|
|
21
|
+
"prepublishOnly": "pnpm run build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@inquirer/prompts": "^7.0.0",
|
|
25
|
+
"commander": "^12.0.0",
|
|
26
|
+
"picocolors": "^1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@vercel/ncc": "^0.38.0",
|
|
30
|
+
"typescript": "^5.7.0",
|
|
31
|
+
"esbuild": "^0.25.0",
|
|
32
|
+
"@types/node": "^22.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"better-sqlite3": ">=11.0.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"better-sqlite3": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"valkey",
|
|
44
|
+
"redis",
|
|
45
|
+
"monitor",
|
|
46
|
+
"database",
|
|
47
|
+
"cli",
|
|
48
|
+
"observability"
|
|
49
|
+
],
|
|
50
|
+
"author": "BetterDB",
|
|
51
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/BetterDB-inc/monitor.git"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://betterdb.com"
|
|
57
|
+
}
|