log-lens-cli 1.0.0__tar.gz
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.
- log_lens_cli-1.0.0/.gitignore +27 -0
- log_lens_cli-1.0.0/LICENSE +21 -0
- log_lens_cli-1.0.0/PKG-INFO +335 -0
- log_lens_cli-1.0.0/README.md +303 -0
- log_lens_cli-1.0.0/log_lens/__init__.py +3 -0
- log_lens_cli-1.0.0/log_lens/__main__.py +6 -0
- log_lens_cli-1.0.0/log_lens/analyzers/__init__.py +0 -0
- log_lens_cli-1.0.0/log_lens/analyzers/anomaly.py +107 -0
- log_lens_cli-1.0.0/log_lens/analyzers/core.py +73 -0
- log_lens_cli-1.0.0/log_lens/analyzers/errors.py +96 -0
- log_lens_cli-1.0.0/log_lens/analyzers/http.py +66 -0
- log_lens_cli-1.0.0/log_lens/cli.py +249 -0
- log_lens_cli-1.0.0/log_lens/demo.py +180 -0
- log_lens_cli-1.0.0/log_lens/models.py +360 -0
- log_lens_cli-1.0.0/log_lens/output/__init__.py +0 -0
- log_lens_cli-1.0.0/log_lens/output/console.py +258 -0
- log_lens_cli-1.0.0/log_lens/output/html_report.py +287 -0
- log_lens_cli-1.0.0/log_lens/parsers/__init__.py +0 -0
- log_lens_cli-1.0.0/log_lens/parsers/apache.py +118 -0
- log_lens_cli-1.0.0/log_lens/parsers/auto.py +157 -0
- log_lens_cli-1.0.0/log_lens/parsers/common.py +127 -0
- log_lens_cli-1.0.0/log_lens/parsers/json_parser.py +135 -0
- log_lens_cli-1.0.0/log_lens/parsers/syslog_parser.py +100 -0
- log_lens_cli-1.0.0/log_lens/renderers/__init__.py +0 -0
- log_lens_cli-1.0.0/log_lens/renderers/charts.py +93 -0
- log_lens_cli-1.0.0/pyproject.toml +64 -0
- log_lens_cli-1.0.0/tests/__init__.py +0 -0
- log_lens_cli-1.0.0/tests/test_anomaly.py +128 -0
- log_lens_cli-1.0.0/tests/test_apache_parser.py +93 -0
- log_lens_cli-1.0.0/tests/test_auto_detect.py +147 -0
- log_lens_cli-1.0.0/tests/test_charts.py +57 -0
- log_lens_cli-1.0.0/tests/test_cli.py +112 -0
- log_lens_cli-1.0.0/tests/test_common_parser.py +102 -0
- log_lens_cli-1.0.0/tests/test_console.py +120 -0
- log_lens_cli-1.0.0/tests/test_core_analyzer.py +106 -0
- log_lens_cli-1.0.0/tests/test_demo.py +82 -0
- log_lens_cli-1.0.0/tests/test_errors.py +116 -0
- log_lens_cli-1.0.0/tests/test_html_report.py +130 -0
- log_lens_cli-1.0.0/tests/test_http.py +125 -0
- log_lens_cli-1.0.0/tests/test_json_parser.py +102 -0
- log_lens_cli-1.0.0/tests/test_models.py +256 -0
- log_lens_cli-1.0.0/tests/test_syslog_parser.py +65 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.eggs/
|
|
10
|
+
*.whl
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
.env
|
|
15
|
+
*.log
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
.ruff_cache/
|
|
18
|
+
.mypy_cache/
|
|
19
|
+
htmlcov/
|
|
20
|
+
.coverage
|
|
21
|
+
*.html
|
|
22
|
+
!log_lens/output/html_report.py
|
|
23
|
+
.DS_Store
|
|
24
|
+
Thumbs.db
|
|
25
|
+
*.swp
|
|
26
|
+
*.swo
|
|
27
|
+
*~
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sanjay Sundar Murthy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: log-lens-cli
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Parse, analyze, and visualize application logs — detect error patterns, frequency spikes, latency issues, and generate HTML dashboards
|
|
5
|
+
Project-URL: Homepage, https://github.com/SanjaySundarMurthy/log-lens
|
|
6
|
+
Project-URL: Repository, https://github.com/SanjaySundarMurthy/log-lens
|
|
7
|
+
Project-URL: Issues, https://github.com/SanjaySundarMurthy/log-lens/issues
|
|
8
|
+
Author-email: Sanjay S <sanjaysundarmurthy@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: analyzer,cli,dashboard,devops,errors,latency,log,monitoring,observability,parser
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: System :: Logging
|
|
23
|
+
Classifier: Topic :: System :: Monitoring
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: click>=8.0
|
|
26
|
+
Requires-Dist: rich>=13.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# log-lens
|
|
34
|
+
|
|
35
|
+
**Smart CLI log analyzer with auto-format detection, error clustering, anomaly detection, and health scoring.**
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/log-lens-cli/)
|
|
38
|
+
[](https://www.python.org/downloads/)
|
|
39
|
+
[](LICENSE)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Why log-lens?
|
|
44
|
+
|
|
45
|
+
Analyzing application logs is tedious. You grep for errors, scroll through thousands of lines, and try to spot patterns manually. **log-lens** automates the entire process:
|
|
46
|
+
|
|
47
|
+
- **Auto-detects** log format (JSON, Apache/Nginx, Syslog, generic text)
|
|
48
|
+
- **Clusters errors** by normalized pattern (groups similar messages together)
|
|
49
|
+
- **Detects anomalies** using statistical analysis (z-score based spike detection)
|
|
50
|
+
- **Scores health** from A+ to F with a 0–100 point system
|
|
51
|
+
- **Analyzes HTTP** traffic (status codes, latency percentiles, top endpoints)
|
|
52
|
+
- **Generates reports** — rich terminal output or dark-themed HTML dashboards
|
|
53
|
+
- **Zero config** — just point it at a log file or directory
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install log-lens-cli
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Analyze a log file
|
|
69
|
+
log-lens analyze /var/log/app.log
|
|
70
|
+
|
|
71
|
+
# Analyze an entire directory
|
|
72
|
+
log-lens analyze /var/log/myapp/
|
|
73
|
+
|
|
74
|
+
# Focus on errors only
|
|
75
|
+
log-lens errors /var/log/app.log
|
|
76
|
+
|
|
77
|
+
# View event timeline with spike detection
|
|
78
|
+
log-lens timeline /var/log/app.log
|
|
79
|
+
|
|
80
|
+
# HTTP traffic analysis
|
|
81
|
+
log-lens http /var/log/nginx/access.log
|
|
82
|
+
|
|
83
|
+
# Generate HTML dashboard
|
|
84
|
+
log-lens analyze /var/log/app.log --html report.html
|
|
85
|
+
|
|
86
|
+
# Try the demo
|
|
87
|
+
log-lens demo
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Commands
|
|
93
|
+
|
|
94
|
+
### `analyze` — Full Analysis
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
log-lens analyze PATH [OPTIONS]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| Option | Description |
|
|
101
|
+
|--------|-------------|
|
|
102
|
+
| `--format`, `-f` | Force log format: `json`, `apache`, `syslog`, `common` |
|
|
103
|
+
| `--html PATH` | Export HTML dashboard report |
|
|
104
|
+
| `--top-errors N` | Number of top error patterns to show (default: 10) |
|
|
105
|
+
|
|
106
|
+
**Output includes:**
|
|
107
|
+
- Health score (A+ to F) with color-coded grade
|
|
108
|
+
- Log level distribution with visual bars
|
|
109
|
+
- Top error patterns with occurrence counts
|
|
110
|
+
- Event timeline with ASCII sparkline
|
|
111
|
+
- HTTP status codes, latency percentiles, top endpoints
|
|
112
|
+
- Detected anomalies with severity ratings
|
|
113
|
+
|
|
114
|
+
### `errors` — Error Analysis
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
log-lens errors PATH [OPTIONS]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Focuses exclusively on error and fatal entries. Groups similar errors by normalized pattern (replaces UUIDs, IPs, numbers, paths, timestamps with placeholders).
|
|
121
|
+
|
|
122
|
+
### `timeline` — Event Timeline
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
log-lens timeline PATH
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Shows events-per-hour distribution with ASCII visualization and highlights time windows with unusual activity.
|
|
129
|
+
|
|
130
|
+
### `http` — HTTP Traffic Analysis
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
log-lens http PATH
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Extracts HTTP metrics from access logs:
|
|
137
|
+
- Status code distribution (2xx/3xx/4xx/5xx)
|
|
138
|
+
- Latency percentiles (avg, p50, p95, p99)
|
|
139
|
+
- Top endpoints by request volume
|
|
140
|
+
- Success/error rates
|
|
141
|
+
|
|
142
|
+
### `demo` — Interactive Demo
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
log-lens demo [OPTIONS]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Option | Description |
|
|
149
|
+
|--------|-------------|
|
|
150
|
+
| `--type TYPE` | Demo log type: `json`, `apache`, `syslog`, `common` |
|
|
151
|
+
| `--html PATH` | Export demo HTML report |
|
|
152
|
+
|
|
153
|
+
Generates realistic sample logs and runs full analysis — perfect for exploring all features.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Supported Log Formats
|
|
158
|
+
|
|
159
|
+
### JSON Logs
|
|
160
|
+
```json
|
|
161
|
+
{"timestamp": "2024-01-15T10:30:00Z", "level": "ERROR", "message": "Connection refused", "service": "api"}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Apache / Nginx Access Logs
|
|
165
|
+
```
|
|
166
|
+
192.168.1.1 - - [15/Jan/2024:10:30:00 +0000] "GET /api/users HTTP/1.1" 200 1234 "-" "Mozilla/5.0"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Syslog (BSD Format)
|
|
170
|
+
```
|
|
171
|
+
Jan 15 10:30:00 hostname app[1234]: ERROR Connection refused to database
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Common Text Logs
|
|
175
|
+
```
|
|
176
|
+
2024-01-15 10:30:00.000 ERROR [main] Connection refused to database
|
|
177
|
+
[2024-01-15 10:30:00] ERROR: Connection refused
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Health Scoring
|
|
183
|
+
|
|
184
|
+
log-lens calculates a health score (0–100) based on:
|
|
185
|
+
|
|
186
|
+
| Factor | Impact |
|
|
187
|
+
|--------|--------|
|
|
188
|
+
| Error rate > 25% | -60 points |
|
|
189
|
+
| Error rate 10–25% | -40 points |
|
|
190
|
+
| Error rate 5–10% | -25 points |
|
|
191
|
+
| Error rate 1–5% | -10 points |
|
|
192
|
+
| Fatal entries > 5 | -20 points |
|
|
193
|
+
| Fatal entries 1–5 | -10 points |
|
|
194
|
+
| Anomalies > 3 | -15 points |
|
|
195
|
+
| Anomalies 1–3 | -5 points |
|
|
196
|
+
| Parse failures > 20% | -10 points |
|
|
197
|
+
|
|
198
|
+
| Grade | Score Range |
|
|
199
|
+
|-------|-------------|
|
|
200
|
+
| A+ | 95–100 |
|
|
201
|
+
| A | 90–94 |
|
|
202
|
+
| B | 80–89 |
|
|
203
|
+
| C | 70–79 |
|
|
204
|
+
| D | 60–69 |
|
|
205
|
+
| F | < 60 |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Error Clustering
|
|
210
|
+
|
|
211
|
+
Similar error messages are automatically grouped by normalizing:
|
|
212
|
+
|
|
213
|
+
| Pattern | Replacement |
|
|
214
|
+
|---------|-------------|
|
|
215
|
+
| UUIDs | `<UUID>` |
|
|
216
|
+
| IP addresses | `<IP>` |
|
|
217
|
+
| Numbers | `<N>` |
|
|
218
|
+
| Hex hashes | `<HASH>` |
|
|
219
|
+
| File paths | `<PATH>` |
|
|
220
|
+
| Timestamps | `<TS>` |
|
|
221
|
+
|
|
222
|
+
**Example:**
|
|
223
|
+
```
|
|
224
|
+
"Connection timeout to 10.0.0.5 after 30000ms" →
|
|
225
|
+
"Connection timeout to <IP> after <N>ms"
|
|
226
|
+
|
|
227
|
+
"User 550e8400-e29b-41d4-a716-446655440000 not found" →
|
|
228
|
+
"User <UUID> not found"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Anomaly Detection
|
|
234
|
+
|
|
235
|
+
Uses z-score statistical analysis to detect:
|
|
236
|
+
|
|
237
|
+
- **Volume spikes** — hours with unusually high log volume
|
|
238
|
+
- **Error rate spikes** — hours with unusually high error percentages
|
|
239
|
+
|
|
240
|
+
Anomalies are rated by severity: `low`, `medium`, `high`, `critical`
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## HTML Dashboard
|
|
245
|
+
|
|
246
|
+
Generate a dark-themed HTML report with:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
log-lens analyze /var/log/app.log --html dashboard.html
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The dashboard includes:
|
|
253
|
+
- Health grade card with color-coded badge
|
|
254
|
+
- Summary metrics (parsed lines, errors, warnings, events/sec)
|
|
255
|
+
- Level distribution bar chart
|
|
256
|
+
- Event timeline visualization
|
|
257
|
+
- Error cluster table with first/last seen and occurrence counts
|
|
258
|
+
- HTTP analysis section (status codes, latency, top endpoints)
|
|
259
|
+
- Anomaly alerts
|
|
260
|
+
|
|
261
|
+
The HTML file is self-contained — no external dependencies, share it with anyone.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Multi-File Support
|
|
266
|
+
|
|
267
|
+
Analyze an entire directory of log files:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
log-lens analyze /var/log/myapp/
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
log-lens automatically discovers files with extensions: `.log`, `.txt`, `.json`, `.jsonl`, `.out`, `.err`
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Examples
|
|
278
|
+
|
|
279
|
+
### Analyze a JSON Application Log
|
|
280
|
+
```bash
|
|
281
|
+
$ log-lens analyze app.log
|
|
282
|
+
|
|
283
|
+
╔══════════════════════════════════════════════╗
|
|
284
|
+
║ 🔍 LOG-LENS ANALYSIS ║
|
|
285
|
+
╚══════════════════════════════════════════════╝
|
|
286
|
+
|
|
287
|
+
Health: A (92/100) Format: JSON
|
|
288
|
+
Lines: 1,247 parsed Duration: 4h 23m
|
|
289
|
+
Errors: 23 (1.8%) Warnings: 45 (3.6%)
|
|
290
|
+
|
|
291
|
+
── Level Distribution ──────────────────────
|
|
292
|
+
INFO ████████████████████████████░░ 78.4%
|
|
293
|
+
WARN ██░░░░░░░░░░░░░░░░░░░░░░░░░░ 3.6%
|
|
294
|
+
ERROR █░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1.8%
|
|
295
|
+
DEBUG ████░░░░░░░░░░░░░░░░░░░░░░░░ 16.2%
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Quick Error Triage
|
|
299
|
+
```bash
|
|
300
|
+
$ log-lens errors /var/log/nginx/error.log
|
|
301
|
+
|
|
302
|
+
Top Error Patterns:
|
|
303
|
+
┌────┬──────────────────────────────────┬───────┐
|
|
304
|
+
│ # │ Pattern │ Count │
|
|
305
|
+
├────┼──────────────────────────────────┼───────┤
|
|
306
|
+
│ 1 │ Connection refused to upstream │ 47 │
|
|
307
|
+
│ 2 │ SSL handshake failed │ 12 │
|
|
308
|
+
│ 3 │ client closed connection │ 8 │
|
|
309
|
+
└────┴──────────────────────────────────┴───────┘
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Development
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
git clone https://github.com/SanjaySundarMurthy/log-lens.git
|
|
318
|
+
cd log-lens
|
|
319
|
+
pip install -e ".[dev]"
|
|
320
|
+
pytest tests/ -v
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Author
|
|
326
|
+
|
|
327
|
+
**Sanjay Sundar Murthy**
|
|
328
|
+
- GitHub: [@SanjaySundarMurthy](https://github.com/SanjaySundarMurthy)
|
|
329
|
+
- Email: sanjaysundarmurthy@gmail.com
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# log-lens
|
|
2
|
+
|
|
3
|
+
**Smart CLI log analyzer with auto-format detection, error clustering, anomaly detection, and health scoring.**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/log-lens-cli/)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why log-lens?
|
|
12
|
+
|
|
13
|
+
Analyzing application logs is tedious. You grep for errors, scroll through thousands of lines, and try to spot patterns manually. **log-lens** automates the entire process:
|
|
14
|
+
|
|
15
|
+
- **Auto-detects** log format (JSON, Apache/Nginx, Syslog, generic text)
|
|
16
|
+
- **Clusters errors** by normalized pattern (groups similar messages together)
|
|
17
|
+
- **Detects anomalies** using statistical analysis (z-score based spike detection)
|
|
18
|
+
- **Scores health** from A+ to F with a 0–100 point system
|
|
19
|
+
- **Analyzes HTTP** traffic (status codes, latency percentiles, top endpoints)
|
|
20
|
+
- **Generates reports** — rich terminal output or dark-themed HTML dashboards
|
|
21
|
+
- **Zero config** — just point it at a log file or directory
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install log-lens-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Analyze a log file
|
|
37
|
+
log-lens analyze /var/log/app.log
|
|
38
|
+
|
|
39
|
+
# Analyze an entire directory
|
|
40
|
+
log-lens analyze /var/log/myapp/
|
|
41
|
+
|
|
42
|
+
# Focus on errors only
|
|
43
|
+
log-lens errors /var/log/app.log
|
|
44
|
+
|
|
45
|
+
# View event timeline with spike detection
|
|
46
|
+
log-lens timeline /var/log/app.log
|
|
47
|
+
|
|
48
|
+
# HTTP traffic analysis
|
|
49
|
+
log-lens http /var/log/nginx/access.log
|
|
50
|
+
|
|
51
|
+
# Generate HTML dashboard
|
|
52
|
+
log-lens analyze /var/log/app.log --html report.html
|
|
53
|
+
|
|
54
|
+
# Try the demo
|
|
55
|
+
log-lens demo
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
### `analyze` — Full Analysis
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
log-lens analyze PATH [OPTIONS]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Option | Description |
|
|
69
|
+
|--------|-------------|
|
|
70
|
+
| `--format`, `-f` | Force log format: `json`, `apache`, `syslog`, `common` |
|
|
71
|
+
| `--html PATH` | Export HTML dashboard report |
|
|
72
|
+
| `--top-errors N` | Number of top error patterns to show (default: 10) |
|
|
73
|
+
|
|
74
|
+
**Output includes:**
|
|
75
|
+
- Health score (A+ to F) with color-coded grade
|
|
76
|
+
- Log level distribution with visual bars
|
|
77
|
+
- Top error patterns with occurrence counts
|
|
78
|
+
- Event timeline with ASCII sparkline
|
|
79
|
+
- HTTP status codes, latency percentiles, top endpoints
|
|
80
|
+
- Detected anomalies with severity ratings
|
|
81
|
+
|
|
82
|
+
### `errors` — Error Analysis
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
log-lens errors PATH [OPTIONS]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Focuses exclusively on error and fatal entries. Groups similar errors by normalized pattern (replaces UUIDs, IPs, numbers, paths, timestamps with placeholders).
|
|
89
|
+
|
|
90
|
+
### `timeline` — Event Timeline
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
log-lens timeline PATH
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Shows events-per-hour distribution with ASCII visualization and highlights time windows with unusual activity.
|
|
97
|
+
|
|
98
|
+
### `http` — HTTP Traffic Analysis
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
log-lens http PATH
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Extracts HTTP metrics from access logs:
|
|
105
|
+
- Status code distribution (2xx/3xx/4xx/5xx)
|
|
106
|
+
- Latency percentiles (avg, p50, p95, p99)
|
|
107
|
+
- Top endpoints by request volume
|
|
108
|
+
- Success/error rates
|
|
109
|
+
|
|
110
|
+
### `demo` — Interactive Demo
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
log-lens demo [OPTIONS]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Option | Description |
|
|
117
|
+
|--------|-------------|
|
|
118
|
+
| `--type TYPE` | Demo log type: `json`, `apache`, `syslog`, `common` |
|
|
119
|
+
| `--html PATH` | Export demo HTML report |
|
|
120
|
+
|
|
121
|
+
Generates realistic sample logs and runs full analysis — perfect for exploring all features.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Supported Log Formats
|
|
126
|
+
|
|
127
|
+
### JSON Logs
|
|
128
|
+
```json
|
|
129
|
+
{"timestamp": "2024-01-15T10:30:00Z", "level": "ERROR", "message": "Connection refused", "service": "api"}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Apache / Nginx Access Logs
|
|
133
|
+
```
|
|
134
|
+
192.168.1.1 - - [15/Jan/2024:10:30:00 +0000] "GET /api/users HTTP/1.1" 200 1234 "-" "Mozilla/5.0"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Syslog (BSD Format)
|
|
138
|
+
```
|
|
139
|
+
Jan 15 10:30:00 hostname app[1234]: ERROR Connection refused to database
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Common Text Logs
|
|
143
|
+
```
|
|
144
|
+
2024-01-15 10:30:00.000 ERROR [main] Connection refused to database
|
|
145
|
+
[2024-01-15 10:30:00] ERROR: Connection refused
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Health Scoring
|
|
151
|
+
|
|
152
|
+
log-lens calculates a health score (0–100) based on:
|
|
153
|
+
|
|
154
|
+
| Factor | Impact |
|
|
155
|
+
|--------|--------|
|
|
156
|
+
| Error rate > 25% | -60 points |
|
|
157
|
+
| Error rate 10–25% | -40 points |
|
|
158
|
+
| Error rate 5–10% | -25 points |
|
|
159
|
+
| Error rate 1–5% | -10 points |
|
|
160
|
+
| Fatal entries > 5 | -20 points |
|
|
161
|
+
| Fatal entries 1–5 | -10 points |
|
|
162
|
+
| Anomalies > 3 | -15 points |
|
|
163
|
+
| Anomalies 1–3 | -5 points |
|
|
164
|
+
| Parse failures > 20% | -10 points |
|
|
165
|
+
|
|
166
|
+
| Grade | Score Range |
|
|
167
|
+
|-------|-------------|
|
|
168
|
+
| A+ | 95–100 |
|
|
169
|
+
| A | 90–94 |
|
|
170
|
+
| B | 80–89 |
|
|
171
|
+
| C | 70–79 |
|
|
172
|
+
| D | 60–69 |
|
|
173
|
+
| F | < 60 |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Error Clustering
|
|
178
|
+
|
|
179
|
+
Similar error messages are automatically grouped by normalizing:
|
|
180
|
+
|
|
181
|
+
| Pattern | Replacement |
|
|
182
|
+
|---------|-------------|
|
|
183
|
+
| UUIDs | `<UUID>` |
|
|
184
|
+
| IP addresses | `<IP>` |
|
|
185
|
+
| Numbers | `<N>` |
|
|
186
|
+
| Hex hashes | `<HASH>` |
|
|
187
|
+
| File paths | `<PATH>` |
|
|
188
|
+
| Timestamps | `<TS>` |
|
|
189
|
+
|
|
190
|
+
**Example:**
|
|
191
|
+
```
|
|
192
|
+
"Connection timeout to 10.0.0.5 after 30000ms" →
|
|
193
|
+
"Connection timeout to <IP> after <N>ms"
|
|
194
|
+
|
|
195
|
+
"User 550e8400-e29b-41d4-a716-446655440000 not found" →
|
|
196
|
+
"User <UUID> not found"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Anomaly Detection
|
|
202
|
+
|
|
203
|
+
Uses z-score statistical analysis to detect:
|
|
204
|
+
|
|
205
|
+
- **Volume spikes** — hours with unusually high log volume
|
|
206
|
+
- **Error rate spikes** — hours with unusually high error percentages
|
|
207
|
+
|
|
208
|
+
Anomalies are rated by severity: `low`, `medium`, `high`, `critical`
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## HTML Dashboard
|
|
213
|
+
|
|
214
|
+
Generate a dark-themed HTML report with:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
log-lens analyze /var/log/app.log --html dashboard.html
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The dashboard includes:
|
|
221
|
+
- Health grade card with color-coded badge
|
|
222
|
+
- Summary metrics (parsed lines, errors, warnings, events/sec)
|
|
223
|
+
- Level distribution bar chart
|
|
224
|
+
- Event timeline visualization
|
|
225
|
+
- Error cluster table with first/last seen and occurrence counts
|
|
226
|
+
- HTTP analysis section (status codes, latency, top endpoints)
|
|
227
|
+
- Anomaly alerts
|
|
228
|
+
|
|
229
|
+
The HTML file is self-contained — no external dependencies, share it with anyone.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Multi-File Support
|
|
234
|
+
|
|
235
|
+
Analyze an entire directory of log files:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
log-lens analyze /var/log/myapp/
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
log-lens automatically discovers files with extensions: `.log`, `.txt`, `.json`, `.jsonl`, `.out`, `.err`
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Examples
|
|
246
|
+
|
|
247
|
+
### Analyze a JSON Application Log
|
|
248
|
+
```bash
|
|
249
|
+
$ log-lens analyze app.log
|
|
250
|
+
|
|
251
|
+
╔══════════════════════════════════════════════╗
|
|
252
|
+
║ 🔍 LOG-LENS ANALYSIS ║
|
|
253
|
+
╚══════════════════════════════════════════════╝
|
|
254
|
+
|
|
255
|
+
Health: A (92/100) Format: JSON
|
|
256
|
+
Lines: 1,247 parsed Duration: 4h 23m
|
|
257
|
+
Errors: 23 (1.8%) Warnings: 45 (3.6%)
|
|
258
|
+
|
|
259
|
+
── Level Distribution ──────────────────────
|
|
260
|
+
INFO ████████████████████████████░░ 78.4%
|
|
261
|
+
WARN ██░░░░░░░░░░░░░░░░░░░░░░░░░░ 3.6%
|
|
262
|
+
ERROR █░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1.8%
|
|
263
|
+
DEBUG ████░░░░░░░░░░░░░░░░░░░░░░░░ 16.2%
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Quick Error Triage
|
|
267
|
+
```bash
|
|
268
|
+
$ log-lens errors /var/log/nginx/error.log
|
|
269
|
+
|
|
270
|
+
Top Error Patterns:
|
|
271
|
+
┌────┬──────────────────────────────────┬───────┐
|
|
272
|
+
│ # │ Pattern │ Count │
|
|
273
|
+
├────┼──────────────────────────────────┼───────┤
|
|
274
|
+
│ 1 │ Connection refused to upstream │ 47 │
|
|
275
|
+
│ 2 │ SSL handshake failed │ 12 │
|
|
276
|
+
│ 3 │ client closed connection │ 8 │
|
|
277
|
+
└────┴──────────────────────────────────┴───────┘
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Development
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
git clone https://github.com/SanjaySundarMurthy/log-lens.git
|
|
286
|
+
cd log-lens
|
|
287
|
+
pip install -e ".[dev]"
|
|
288
|
+
pytest tests/ -v
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Author
|
|
294
|
+
|
|
295
|
+
**Sanjay Sundar Murthy**
|
|
296
|
+
- GitHub: [@SanjaySundarMurthy](https://github.com/SanjaySundarMurthy)
|
|
297
|
+
- Email: sanjaysundarmurthy@gmail.com
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## License
|
|
302
|
+
|
|
303
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
File without changes
|