Bridge
The Bridge is a Python-based service that provides the core log processing pipeline. It consumes raw OTLP JSON from Kafka, normalizes it into flat documents, detects anomalies, correlates traces, and indexes everything into OpenSearch.Architecture
The Bridge runs 4 concurrent threads, each handling a distinct stage of the pipeline:OTLP ETL (Thread 1)
The ETL thread consumes OTLP JSON messages from theraw-logs Kafka topic and flattens them into canonical log documents.
OTLP unwrapping path:
| OTLP Field | Output Field | Description |
|---|---|---|
resource.attributes["service.name"] | service | Service name |
logRecord.body.stringValue | message | Log message |
logRecord.severityText | level | Log level (INFO, WARN, ERROR) |
logRecord.timeUnixNano | timestamp | ISO-8601 timestamp |
logRecord.traceId | trace_id | Distributed trace ID |
logRecord.spanId | span_id | Span ID |
resource.attributes["host.name"] | host | Hostname |
resource.attributes["tenant_id"] | tenant_id | Tenant identifier |
logRecord.attributes[*] | (flattened) | Custom attributes as top-level fields |
Anomaly Detection (Thread 2)
Uses a sliding-window Z-score algorithm to detect anomalous error rate spikes per service. Configuration:| Parameter | Env Var | Default | Description |
|---|---|---|---|
| Threshold | ANOMALY_THRESHOLD | 2.5 | Z-score threshold for anomaly flagging |
| Window Size | WINDOW_SIZE | 50 | Number of data points in sliding window |
anomaly_score— the computed Z-scoreis_anomaly— boolean flag- Written to the anomalies topic for the Ticketing Agent
Request Lifecycle Engine (Thread 4)
The lifecycle engine performs 5-layer trace correlation to group related log entries into request timelines:- Trace ID grouping — group logs sharing the same
trace_id - Temporal proximity — cluster logs within a time window
- Service dependency mapping — map caller→callee relationships
- Error propagation tracking — trace error cascades across services
- Blast radius computation — determine affected services and endpoints
Prometheus Metrics
The Bridge exposes Prometheus-format metrics atGET /metrics:
| Metric | Type | Description |
|---|---|---|
logclaw_bridge_etl_consumed_total | Counter | Kafka messages (batches) consumed from raw-logs |
logclaw_bridge_etl_records_received_total | Counter | Individual OTLP log records flattened |
logclaw_bridge_etl_produced_total | Counter | Enriched documents written to enriched-logs |
logclaw_bridge_anomalies_detected_total | Counter | Anomalies detected |
logclaw_bridge_opensearch_indexed_total | Counter | Documents indexed into OpenSearch |
logclaw_bridge_opensearch_errors_total | Counter | OpenSearch indexing errors |
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
KAFKA_BROKERS | Yes | — | Kafka bootstrap servers |
KAFKA_TOPIC_RAW | No | raw-logs | Topic to consume raw OTLP JSON |
KAFKA_TOPIC_ENRICHED | No | enriched-logs | Topic to produce enriched documents |
OPENSEARCH_ENDPOINT | Yes | — | OpenSearch cluster URL |
OPENSEARCH_USERNAME | No | — | OpenSearch Basic Auth username |
OPENSEARCH_PASSWORD | No | — | OpenSearch Basic Auth password |
ANOMALY_THRESHOLD | No | 2.5 | Z-score threshold |
WINDOW_SIZE | No | 50 | Sliding window size |
PORT | No | 8080 | HTTP server port |
Runtime Configuration
The Bridge supports dynamic runtime configuration via the/config endpoint: