@logboard/cli 1.0.0
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/.env.example +37 -0
- package/README.md +200 -0
- package/bin/logboard +536 -0
- package/client/logger.js +309 -0
- package/config/index.js +142 -0
- package/config.js +2 -0
- package/controllers/AnalyticsController.js +46 -0
- package/controllers/ApiAnalyticsController.js +129 -0
- package/controllers/ApiKeyController.js +58 -0
- package/controllers/AuthController.js +131 -0
- package/controllers/HealthController.js +56 -0
- package/controllers/LogController.js +197 -0
- package/controllers/OrgController.js +152 -0
- package/controllers/RoleConfigController.js +20 -0
- package/controllers/SettingsController.js +39 -0
- package/controllers/StreamController.js +55 -0
- package/controllers/UiController.js +789 -0
- package/controllers/UserController.js +79 -0
- package/lib/batchWriter.js +57 -0
- package/lib/cleanup.js +67 -0
- package/lib/ejs.js +103 -0
- package/lib/emitter.js +5 -0
- package/lib/healthMonitor.js +245 -0
- package/lib/logger.js +21 -0
- package/lib/streams.js +32 -0
- package/lib/theme.js +77 -0
- package/lib/userStore.js +13 -0
- package/lib/utils.js +44 -0
- package/middleware/apiKey.js +82 -0
- package/middleware/auth.js +55 -0
- package/middleware/ipWhitelist.js +59 -0
- package/middleware/org.js +85 -0
- package/middleware/pageAccess.js +20 -0
- package/middleware/rateLimit.js +29 -0
- package/middleware/roles.js +11 -0
- package/package.json +77 -0
- package/routes/alerts.js +18 -0
- package/routes/analytics.js +26 -0
- package/routes/api-analytics.js +30 -0
- package/routes/api-keys.js +12 -0
- package/routes/archive.js +91 -0
- package/routes/audit.js +50 -0
- package/routes/auth.js +22 -0
- package/routes/bookmarks.js +13 -0
- package/routes/health.js +11 -0
- package/routes/logs.js +88 -0
- package/routes/metrics.js +66 -0
- package/routes/notifications.js +14 -0
- package/routes/orgs.js +98 -0
- package/routes/registration.js +202 -0
- package/routes/role-config.js +97 -0
- package/routes/saved-searches.js +12 -0
- package/routes/server.js +151 -0
- package/routes/settings.js +28 -0
- package/routes/status.js +21 -0
- package/routes/stream.js +11 -0
- package/routes/super.js +129 -0
- package/routes/ui.js +120 -0
- package/routes/users.js +13 -0
- package/server.js +172 -0
- package/services/AlertRulesService.js +323 -0
- package/services/AnalyticsService.js +665 -0
- package/services/ApiAnalyticsService.js +471 -0
- package/services/ApiKeyService.js +166 -0
- package/services/AuditService.js +249 -0
- package/services/AuthService.js +234 -0
- package/services/BookmarkService.js +49 -0
- package/services/GlobalSettingsService.js +44 -0
- package/services/LogService.js +1066 -0
- package/services/MetricsService.js +116 -0
- package/services/NotificationService.js +70 -0
- package/services/OrgService.js +217 -0
- package/services/ReportService.js +247 -0
- package/services/RoleConfigService.js +201 -0
- package/services/SavedSearchService.js +63 -0
- package/services/SettingsService.js +220 -0
- package/services/UserService.js +121 -0
- package/setup.js +132 -0
- package/views/404.ejs +8 -0
- package/views/alerts.ejs +190 -0
- package/views/analytics.ejs +209 -0
- package/views/api-analytics.ejs +660 -0
- package/views/api-keys.ejs +150 -0
- package/views/archive.ejs +123 -0
- package/views/audit.ejs +314 -0
- package/views/bookmarks.ejs +54 -0
- package/views/custom-dashboard.ejs +162 -0
- package/views/dashboard.ejs +186 -0
- package/views/diff.ejs +98 -0
- package/views/health.ejs +269 -0
- package/views/heatmap.ejs +126 -0
- package/views/insights.ejs +334 -0
- package/views/invite.ejs +74 -0
- package/views/live.ejs +299 -0
- package/views/login.ejs +64 -0
- package/views/logo.png +0 -0
- package/views/logs.ejs +754 -0
- package/views/notifications.ejs +58 -0
- package/views/partials/head.ejs +282 -0
- package/views/partials/sidebar.ejs +168 -0
- package/views/register.ejs +100 -0
- package/views/roles.ejs +279 -0
- package/views/saved-searches.ejs +51 -0
- package/views/service-map.ejs +142 -0
- package/views/settings.ejs +1159 -0
- package/views/sidebar.ejs +129 -0
- package/views/status.ejs +100 -0
- package/views/super-admin-admins.ejs +58 -0
- package/views/super-admin-analytics.ejs +49 -0
- package/views/super-admin-orgs.ejs +310 -0
- package/views/super-admin-profile.ejs +77 -0
- package/views/super-admin-settings.ejs +108 -0
- package/views/super-admin-system.ejs +46 -0
- package/views/users.ejs +153 -0
package/.env.example
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# ──────────────────────────────────────────────────────────────
|
|
2
|
+
# LogBoard — Environment Configuration
|
|
3
|
+
# Copy to .env and fill in your values: cp .env.example .env
|
|
4
|
+
# ──────────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
# Server
|
|
7
|
+
NODE_ENV=development # development | production
|
|
8
|
+
PORT=9900
|
|
9
|
+
|
|
10
|
+
# Security (generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
|
|
11
|
+
JWT_SECRET=change-me-at-least-32-chars-long-random-string
|
|
12
|
+
JWT_EXPIRES_IN=24h # Session duration
|
|
13
|
+
|
|
14
|
+
# Legacy single API key (backward compat — prefer the API Keys UI)
|
|
15
|
+
API_KEY=change-me-secret-key
|
|
16
|
+
|
|
17
|
+
# Storage paths (relative to project root or absolute)
|
|
18
|
+
DATA_DIR=./data # users.json, settings.json, role-config.json, api-keys.json
|
|
19
|
+
LOG_BASE_DIR=./logs # Ingested log files
|
|
20
|
+
|
|
21
|
+
# Log retention
|
|
22
|
+
RETENTION_DAYS=7 # Days to keep log files
|
|
23
|
+
|
|
24
|
+
# Features
|
|
25
|
+
ENABLE_STREAM=true # Enable SSE real-time stream
|
|
26
|
+
|
|
27
|
+
# CORS (comma-separated allowed origins)
|
|
28
|
+
CORS_ORIGINS=http://localhost:9900
|
|
29
|
+
|
|
30
|
+
# Optional: Webhook URL for error alerts
|
|
31
|
+
WEBHOOK_URL=
|
|
32
|
+
|
|
33
|
+
# File names (relative to DATA_DIR — change if needed)
|
|
34
|
+
# USERS_FILE=users.json
|
|
35
|
+
# SETTINGS_FILE=settings.json
|
|
36
|
+
# ROLES_FILE=role-config.json
|
|
37
|
+
# API_KEYS_FILE=api-keys.json
|
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# @logboard/cli
|
|
2
|
+
|
|
3
|
+
> **Production-grade log aggregator** — real-time dashboard, RBAC, multi-org, alerts, audit trail, and API analytics. One-command install on macOS, Linux & Windows.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@logboard/cli)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @logboard/cli
|
|
15
|
+
# or install globally
|
|
16
|
+
npm install -g @logboard/cli
|
|
17
|
+
logboard
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Open **http://localhost:9900** — first-run setup wizard runs automatically.
|
|
21
|
+
|
|
22
|
+
Default credentials (change immediately):
|
|
23
|
+
| Field | Value |
|
|
24
|
+
|-------|-------|
|
|
25
|
+
| Username | `admin` |
|
|
26
|
+
| Password | set during first-run setup |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
| Category | What you get |
|
|
33
|
+
|----------|-------------|
|
|
34
|
+
| **Log Ingestion** | HTTP push endpoint — works with any language/framework |
|
|
35
|
+
| **Real-time Stream** | SSE-based live log tail in the browser |
|
|
36
|
+
| **RBAC** | Super-admin → Admin → Viewer roles, fully configurable |
|
|
37
|
+
| **Multi-org** | Isolated organisations with per-org settings and API keys |
|
|
38
|
+
| **Alerts** | Rule-based alerts via Webhook, Email, Slack, Discord |
|
|
39
|
+
| **API Analytics** | Per-endpoint latency, error rate, traffic graphs |
|
|
40
|
+
| **Audit Trail** | Every admin action logged with actor + timestamp |
|
|
41
|
+
| **Archiving** | Automatic log rotation and compressed archive downloads |
|
|
42
|
+
| **Health Monitor** | Process + host health dashboard |
|
|
43
|
+
| **Auth** | JWT sessions, 2FA (TOTP), Google & GitHub OAuth |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Installation Options
|
|
48
|
+
|
|
49
|
+
### Global (recommended for production servers)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install -g @logboard/cli
|
|
53
|
+
logboard
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Docker
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
docker run -p 9900:9900 -v $(pwd)/data:/app/data logboard/cli
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Manual clone
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/logboards/logboard-cli.git
|
|
66
|
+
cd logboard-cli
|
|
67
|
+
npm install
|
|
68
|
+
npm run setup # first-run only
|
|
69
|
+
npm start
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
All config lives in `.env` (auto-generated on first run from `.env.example`):
|
|
77
|
+
|
|
78
|
+
```env
|
|
79
|
+
PORT=9900
|
|
80
|
+
NODE_ENV=production
|
|
81
|
+
|
|
82
|
+
JWT_SECRET=<random-32-char-string>
|
|
83
|
+
JWT_EXPIRES_IN=24h
|
|
84
|
+
|
|
85
|
+
DATA_DIR=./data
|
|
86
|
+
LOG_BASE_DIR=./logs
|
|
87
|
+
RETENTION_DAYS=7
|
|
88
|
+
|
|
89
|
+
CORS_ORIGINS=https://your-domain.com
|
|
90
|
+
WEBHOOK_URL= # optional: Slack/Discord/custom webhook
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Generate a strong secret:
|
|
94
|
+
```bash
|
|
95
|
+
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Sending Logs
|
|
101
|
+
|
|
102
|
+
Use the companion SDK **[@logboard/logger](https://www.npmjs.com/package/@logboard/logger)** or push raw NDJSON:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Raw HTTP push
|
|
106
|
+
curl -X POST http://localhost:9900/api/logs \
|
|
107
|
+
-H "x-api-key: YOUR_API_KEY" \
|
|
108
|
+
-H "Content-Type: application/json" \
|
|
109
|
+
-d '{"level":"info","message":"Server started","service":"api","timestamp":"2026-01-01T00:00:00Z"}'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
// With @logboard/logger SDK
|
|
114
|
+
const { createLogger } = require('@logboard/logger');
|
|
115
|
+
|
|
116
|
+
const logger = createLogger({
|
|
117
|
+
serviceName: 'my-api',
|
|
118
|
+
transports: [{
|
|
119
|
+
type: 'logboard',
|
|
120
|
+
url: 'http://localhost:9900',
|
|
121
|
+
apiKey: process.env.LOGBOARD_API_KEY,
|
|
122
|
+
}],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
logger.info('Server started', { port: 3000 });
|
|
126
|
+
logger.error('DB connection failed', { err: error.message });
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## API Reference
|
|
132
|
+
|
|
133
|
+
All API routes are prefixed `/api/` and require an `x-api-key` header (manage keys in Settings → API Keys).
|
|
134
|
+
|
|
135
|
+
| Method | Path | Description |
|
|
136
|
+
|--------|------|-------------|
|
|
137
|
+
| `POST` | `/api/logs` | Ingest one or more log entries |
|
|
138
|
+
| `GET` | `/api/logs` | Query logs (filter, search, paginate) |
|
|
139
|
+
| `GET` | `/api/logs/stream` | SSE real-time stream |
|
|
140
|
+
| `GET` | `/api/analytics` | Log volume and error-rate stats |
|
|
141
|
+
| `GET` | `/api/health` | Server health status |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Production Deployment
|
|
146
|
+
|
|
147
|
+
### PM2
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm install -g pm2
|
|
151
|
+
pm2 start server.js --name logboard
|
|
152
|
+
pm2 save && pm2 startup
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### systemd
|
|
156
|
+
|
|
157
|
+
```ini
|
|
158
|
+
[Unit]
|
|
159
|
+
Description=LogBoard
|
|
160
|
+
After=network.target
|
|
161
|
+
|
|
162
|
+
[Service]
|
|
163
|
+
WorkingDirectory=/opt/logboard
|
|
164
|
+
ExecStart=/usr/bin/node server.js
|
|
165
|
+
Restart=always
|
|
166
|
+
EnvironmentFile=/opt/logboard/.env
|
|
167
|
+
|
|
168
|
+
[Install]
|
|
169
|
+
WantedBy=multi-user.target
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Nginx reverse proxy
|
|
173
|
+
|
|
174
|
+
```nginx
|
|
175
|
+
location / {
|
|
176
|
+
proxy_pass http://127.0.0.1:9900;
|
|
177
|
+
proxy_http_version 1.1;
|
|
178
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
179
|
+
proxy_set_header Connection 'upgrade';
|
|
180
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
181
|
+
proxy_cache_bypass $http_upgrade;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Security
|
|
188
|
+
|
|
189
|
+
- All passwords are bcrypt-hashed (cost factor 12).
|
|
190
|
+
- JWT tokens expire in `JWT_EXPIRES_IN` (default 24 h).
|
|
191
|
+
- IP whitelist middleware available — configure in Settings.
|
|
192
|
+
- Rate limiting enabled on all routes.
|
|
193
|
+
- Helmet.js security headers included.
|
|
194
|
+
- **Change the default credentials immediately after first run.**
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
MIT © LogBoard Team
|