**Real-time Linux log monitoring and semantic search **
Kernolog streams live system logs from journalctl, deduplicates repeated entries using the Drain3 log template miner, embeds them with a SentenceTransformer model, and stores them in a hybrid SQLite + binary vector store for fast semantic similarity search.
- Live log ingestion via
journalctlin JSON mode, capturing message, priority, and unit - Log normalization & deduplication using Drain3 — repeated log lines are collapsed into templates (e.g.
"User <*> logged in") - Parameter extraction — variables like usernames, device names, and IPs are stored separately and highlighted in results
- AI embeddings using
all-MiniLM-L6-v2(viasentence-transformers) - Three-tier classification — logs are bucketed into
error(priority ≤ 3),warning(priority 4), anddebug(priority ≥ 5) - Two-phase semantic search — a fast broad pass over template vectors, followed by live re-ranking with hydrated (parameter-restored) sentences
- Recency-biased search — use keywords like
now,latest, orrecentto surface the most recent relevant logs - Desktop alerts via
notify-sendfor critical errors - Interactive shell for querying logs in real time
journalctl (JSON)
│
▼
[Collector] collector/core.py
│ raw log dicts
▼
[Normalizer] normalizer/core.py
│ template + params + priority
▼
[Engine] engine.py
│ batched embedding + storage
▼
[Storage] storage.py
├── {category}.sqlite (templates, occurrences, parameters)
└── {category}.bin (float32 embedding vectors)
│
▼
[Shell] shell.py
└── semantic search CLI
- Python 3.8+
- Linux with
systemd(forjournalctl) notify-send(optional, for desktop alerts on critical errors)
git clone https://github.com/iririthik/Kernolog.git
cd Kernologpython3 -m venv venv
source venv/bin/activatepip install sentence-transformers drain3 colorama numpyNote: The first run will download the
all-MiniLM-L6-v2model (~90 MB) from HuggingFace automatically.
# Debian/Ubuntu
sudo apt install libnotify-bin
# Arch
sudo apt install libnotifyKernolog reads from journalctl. If you get a permissions error, add your user to the systemd-journal group:
sudo usermod -aG systemd-journal $USER
# Log out and back in for this to take effectpython boot.pyThis starts the engine in the background and opens the search shell in a new terminal window. Indexed data is written to ./gen_data/.
Terminal 1 — start the engine:
python engine.pyTerminal 2 — open the search shell:
python shell.pyKernolog> search <category> <query>
Categories: error, warning, debug
| Example command | What it does |
|---|---|
search error disk failure |
Semantic search for disk-related errors |
search warning latest |
Most recent warnings |
search error usb device now |
Recent USB errors, time-prioritized |
search debug network |
Debug logs related to networking |
Tips:
- Use
now,latest,recent,last,today, orcurrentto sort results by time instead of relevance score - Type
clearto clear the screen - Type
exitorquitto close the shell
Example output:
--- ERROR Results ---
[Score:0.87] 14:23:01.042 | kernel: usb disconnect, device number 3
[Score:0.74] 14:19:55.118 | kernel: EXT4-fs error on sda1
--------------------------------------------------
Matched parameters are highlighted in yellow.
All indexed data lives in ./gen_data/:
| File | Contents |
|---|---|
error.sqlite |
Templates, occurrences, and extracted parameters for errors |
error.bin |
Raw float32 embedding vectors (384-dim) |
warning.sqlite / warning.bin |
Same for warnings |
debug.sqlite / debug.bin |
Same for debug/info logs |
Watch live logs with a custom callback:
from collector import watch
def my_handler(log):
print(log['priority'], log['message'])
watch(my_handler)Run the full normalized pipeline:
from normalizer import process_stream
def my_handler(log_line):
print(log_line)
process_stream(my_handler)AGPL-3.0 — if you run a modified version as a network service, you must make your source code available.
Contributions are welcome. See the repository's contributing guidelines.
Built with Drain3, sentence-transformers, and NumPy.