lduck 0.0.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/LICENSE.md +19 -0
- package/README.md +120 -0
- package/dist/index.js +1131 -0
- package/dist/static/client.js +9 -0
- package/package.json +71 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2026-present [syumai](https://github.com/syumai/)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
8
|
+
subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# lduck
|
|
2
|
+
|
|
3
|
+
Pipe-friendly JSON log viewer powered by DuckDB. Reads JSON lines from stdin or HTTP, stores them in DuckDB, and serves a real-time search UI.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g lduck
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Pipe any JSON-lines output into lduck:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
kubectl logs -f deploy/api | lduck
|
|
17
|
+
cat app.log | lduck --port 9090
|
|
18
|
+
docker logs -f myapp | lduck --db ./logs.duckdb
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then open http://localhost:8080 in your browser.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Full-text search across all log fields
|
|
26
|
+
- Filter by level, service, host, source, and time range
|
|
27
|
+
- Faceted navigation with custom facet support
|
|
28
|
+
- Live tail via WebSocket (with polling fallback)
|
|
29
|
+
- Raw SQL queries against DuckDB
|
|
30
|
+
- CSV / JSON export
|
|
31
|
+
- HTTP ingestion endpoint for batch log submission
|
|
32
|
+
- In-memory by default, optional file-based persistence
|
|
33
|
+
|
|
34
|
+
## CLI Options
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Usage: <command> | lduck [options]
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
-p, --port <port> Server port (default: 8080)
|
|
41
|
+
-m, --max-rows <n> Maximum rows to keep (default: 100000)
|
|
42
|
+
--batch-size <n> Batch INSERT size (default: 5000)
|
|
43
|
+
--db <path> DuckDB persistence path (default: :memory:)
|
|
44
|
+
--no-ui Disable Web UI, API server only
|
|
45
|
+
-h, --help Show this help message
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## JSON Format
|
|
49
|
+
|
|
50
|
+
Each line should be a JSON object. lduck normalizes common field names automatically:
|
|
51
|
+
|
|
52
|
+
| Field | Aliases |
|
|
53
|
+
|-------|---------|
|
|
54
|
+
| `timestamp` | `ts`, `time`, `@timestamp`, `datetime` |
|
|
55
|
+
| `level` | `severity`, `loglevel`, `lvl`, `priority` |
|
|
56
|
+
| `message` | `msg`, `body`, `text` |
|
|
57
|
+
| `service` | `svc`, `app`, `component`, `logger` |
|
|
58
|
+
| `trace_id` | `traceId`, `request_id`, `correlation_id` |
|
|
59
|
+
| `host` | |
|
|
60
|
+
| `duration_ms` | |
|
|
61
|
+
| `source` | |
|
|
62
|
+
|
|
63
|
+
Unrecognized fields are preserved in `_raw` and searchable via raw SQL.
|
|
64
|
+
|
|
65
|
+
## HTTP Ingestion
|
|
66
|
+
|
|
67
|
+
You can also send logs via HTTP instead of stdin:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Single log
|
|
71
|
+
curl -X POST http://localhost:8080/api/ingest \
|
|
72
|
+
-H 'Content-Type: application/json' \
|
|
73
|
+
-d '{"level":"INFO","message":"hello from curl","service":"my-app"}'
|
|
74
|
+
|
|
75
|
+
# Batch
|
|
76
|
+
curl -X POST http://localhost:8080/api/ingest \
|
|
77
|
+
-H 'Content-Type: application/json' \
|
|
78
|
+
-d '[{"level":"INFO","message":"log 1"},{"level":"ERROR","message":"log 2"}]'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API
|
|
82
|
+
|
|
83
|
+
| Method | Endpoint | Description |
|
|
84
|
+
|--------|----------|-------------|
|
|
85
|
+
| `GET` | `/api/health` | Health check with uptime |
|
|
86
|
+
| `GET` | `/api/logs` | Query logs (supports `search`, `level`, `service`, `source`, `startTime`, `endTime`, `limit`, `offset`, `order`) |
|
|
87
|
+
| `GET` | `/api/stats` | Log statistics by level |
|
|
88
|
+
| `GET` | `/api/facets` | Facet value distribution |
|
|
89
|
+
| `GET` | `/api/schema` | Database schema |
|
|
90
|
+
| `POST` | `/api/ingest` | Ingest JSON logs (single object or array) |
|
|
91
|
+
| `POST` | `/api/query` | Execute raw SQL |
|
|
92
|
+
| `POST` | `/api/export` | Export logs as CSV or JSON |
|
|
93
|
+
| `WS` | `/api/ws/tail` | Live tail WebSocket |
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
git clone https://github.com/syumai/lduck.git
|
|
99
|
+
cd lduck
|
|
100
|
+
pnpm install
|
|
101
|
+
pnpm dev # Start Vite dev server
|
|
102
|
+
pnpm test # Run tests
|
|
103
|
+
pnpm lint # Lint + type check
|
|
104
|
+
pnpm build # Build for production
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Test Log Generation
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# stdout (pipe to lduck)
|
|
111
|
+
pnpm generate-logs | lduck
|
|
112
|
+
|
|
113
|
+
# HTTP (send to running lduck instance)
|
|
114
|
+
pnpm generate-logs:http
|
|
115
|
+
pnpm generate-logs:http -- --count 500 --url http://localhost:8080/api/ingest
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT
|