logpipe is one Python process, or a fast-path process plus N learning workers when the queue is Kafka. It is built from components that each have a single owner and a narrow interface. The rule behind the layout: the hot path never waits on anything slow (a model, a person, a network round-trip). Everything slow happens beside it and publishes its result as a new, immutable registry version.
| Component | Code | Owns | Interface |
|---|---|---|---|
| Sources | logpipe/sources/, server/otlp.py, agent/ |
turning files, OTLP and agent batches into LogEvents |
LogEvent(device_id, source, line, service, tags, time) |
| Frozen parser | parsing/frozen_parser.py |
line → template_id, payload, FINAL/PENDING |
ParserHandle.parse(), .swap(snapshot) |
| Schema registry | registry.py |
template ids (monotonic, never reused), aliases, masks, key names | immutable RegistrySnapshot, SchemaRegistry.publish() |
| Store | storage/ |
rows (versioned upserts), alerts | LogStore protocol |
| Unresolved queue | unresolved/ |
PENDING rows on their way to the learner | UnresolvedQueue protocol (memory, Kafka) |
| Enrichment worker | enrich/worker.py |
learning templates online, back-filling rows | run_cycle() -> CycleReport |
| LLM adapter | enrich/llm.py |
masks, key names, alias confirmation, structured answers | LLMAdapter protocol |
| Detector | anomaly/detector.py, scorer.py |
windows → LogBERT scores → alerts | Scorer protocol |
| Server | server/ |
intake, control plane, lifecycle jobs, UI API, metrics, MCP | FastAPI app |
| Ask / RCA | ask/ |
question → approved reads → cited report | AskService |
| Store adapters | server/stores/ |
UI reads and the query compiler per backend | StoreReads, Compiler |
sequenceDiagram
autonumber
participant Src as Source (agent / OTLP / file)
participant P as Pipeline.process
participant FP as FrozenParser (vN)
participant St as LogStore
participant Q as UnresolvedQueue
participant D as Detector
participant W as EnrichmentWorker
Src->>P: LogEvent
P->>P: event_time() from the line (else agent time)
P->>FP: parse(line)
alt template matches (rules first, then Drain)
FP-->>P: template_id, payload, FINAL
P->>St: insert row (version = vN)
P->>D: (device, time, template_id)
D->>D: reorder buffer → window every 5 → LogBERT batch
D-->>St: AnomalyAlert (when over threshold)
else no match
FP-->>P: UNK, PENDING
P->>St: insert row PENDING (version = vN)
P->>Q: publish(row)
end
Note over W: every N lines (in process) or continuously (Kafka worker)
W->>Q: consume(batch)
W->>W: shadow Drain → validate → name keys → alias check
W->>FP: publish registry vN+1 + hot-swap
W->>St: re-parse batch → insert FINAL rows (version = vN+1)
W->>Q: re-queue / dead-letter the rest, then commit
The ReplacingMergeTree trick ties it together. A PENDING row and its later FINAL back-fill have
the same log_id and sort key, and the back-fill carries a higher version, so reading with
FINAL (ClickHouse) or “latest version per log_id” (memory, Mongo) always sees the best parse.
That is also why a redelivered Kafka batch changes nothing.
=== “Single process (default)”
```mermaid
flowchart LR
S[sources] --> P[parse] --> ST[(store)]
P --> Q[[memory queue]] --> W[worker<br/>every enrich_every lines] --> P
P --> D[detector]
```
=== “Fast path + Kafka workers”
```mermaid
flowchart LR
S[sources] --> P["logpipe run --no-enrich"] --> ST[(ClickHouse)]
P -->|produce, never blocks| K[[Kafka topic<br/>keyed by line shape]]
K --> W1[logpipe worker]
K --> W2[logpipe worker]
W1 & W2 -->|back-fill| ST
W1 & W2 --> R[(registry.json)]
```
A fast-path process doesn't reload a registry another process wrote. Templates learned by a
separate worker reach it on restart (see [Kafka](/Log_parser/kafka.html#known-gaps)).
=== “Server”
```mermaid
flowchart LR
AG[agents / OTLP] --> I[intake buffer] --> P[pipeline] --> ST[(store)]
P --> J[jobs: draft, apply, retrain,<br/>reextract, ask rounds]
J --> R[(registry + per-stream models<br/>in --data-dir)]
UI[React UI] & MCP["/mcp"] --> API["/api/*"] --> P & ST & J
```
offline is a complete backend, never a degraded one.Deep dives: Parsing · Online learning · LogBERT · Server lifecycle · Ask & RCA · MCP · Storage