Extract correlation IDs from your logs. Automatically.
What is it? • Features • Quick Start • How it Works • Contributing
"Our microservices generate thousands of log lines per minute. When something breaks, I spend more time correlating logs across services than actually fixing the problem."
Sound familiar? CID Tracker solves this by automatically extracting correlation IDs (CIDs) from your application logs and outputting them as structured data — ready for your observability pipeline.
Deploy it as a sidecar container. It watches your log files, extracts UUIDs used as correlation IDs, validates them, and streams structured output to stdout. No code changes required in your application.
# Scattered across multiple log files, multiple services...
2024-01-15 10:30:00 INFO [auth] CID:550e8400-e29b-51d4-a716-446655440000 User login
2024-01-15 10:30:01 INFO [orders] CID:550e8400-e29b-51d4-a716-446655440000 Fetching cart
2024-01-15 10:30:02 ERROR [payments] CID:550e8400-e29b-51d4-a716-446655440000 Payment failed
# Good luck finding these manually...
{"cid":"550e8400-e29b-51d4-a716-446655440000","log_file":"auth.log","timestamp":"2024-01-15T10:30:00Z",...}
{"cid":"550e8400-e29b-51d4-a716-446655440000","log_file":"orders.log","timestamp":"2024-01-15T10:30:01Z",...}
{"cid":"550e8400-e29b-51d4-a716-446655440000","log_file":"payments.log","timestamp":"2024-01-15T10:30:02Z",...}Pipe this to Elasticsearch, Loki, or any log aggregator — now you can filter by CID instantly.
|
|
git clone https://github.com/psenger/cidtracker.git
cd cidtracker/examples
docker compose up --buildWatch the output:
sample-app | 2024-01-15 10:30:00 INFO [auth-service] CID:550e8400-e29b-51d4-a716-446655440000 Processing user request
cidtracker | {"cid":"550e8400-e29b-51d4-a716-446655440000","uuid":"550e8400-e29b-51d4-a716-446655440000","timestamp":"2024-01-15T10:30:00Z","log_file":"application.log",...}
The sample app generates logs with CIDs. CID Tracker extracts them in real-time.
Press Ctrl+C to stop, then docker compose down -v to clean up.
From Source:
go install github.com/psenger/cidtracker@latestBuild Locally:
git clone https://github.com/psenger/cidtracker.git
cd cidtracker
go build -o cidtracker .Docker:
docker build -t cidtracker:latest .# Monitor a directory, output JSON
./cidtracker -log-path=/var/log/app -output=json
# With verbose logging
./cidtracker -log-path=/var/log/app -output=json -verbose┌─────────────────────────────────────────────────────────────────┐
│ Your Application │
│ │
│ logger.info("CID:{} Processing order", correlationId) │
│ │ │
│ ▼ │
│ /var/log/app/app.log │
└─────────────────────────────────────────────────────────────────┘
│
│ (shared volume)
▼
┌─────────────────────────────────────────────────────────────────┐
│ CID Tracker │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ LogMonitor │───▶│ Extractor │───▶│ Validator │ │
│ │ (fsnotify) │ │ (regex) │ │ (UUID v5) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ │
│ │ stdout │ │
│ │ (JSON) │ │
│ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
Log Aggregator / SIEM
(Elasticsearch, Loki, Splunk, etc.)
- LogMonitor watches for new
.logfiles and tails existing ones - Extractor applies regex patterns to find
CID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - Validator confirms it's a valid UUID (optionally version 5 only)
- Output streams structured JSON to stdout for your pipeline
"I'm a platform engineer building a Kubernetes logging stack. I need to enrich logs with correlation metadata before they hit Elasticsearch."
Deploy CID Tracker as a sidecar. Mount the log volume read-only. Pipe stdout to Fluentd/Fluent Bit.
"I'm a developer debugging a distributed system. I need to trace a request across 5 microservices."
Add CID Tracker to your docker-compose. Filter aggregated logs by the extracted CID.
"I'm an SRE setting up alerting. I need to detect when the same correlation ID appears in error logs across multiple services."
Feed CID Tracker output to your SIEM. Create correlation rules based on CID frequency in error streams.
version: '3.8'
services:
your-app:
image: your-app:latest
volumes:
- logs:/var/log/app
cidtracker:
image: cidtracker:latest
volumes:
- logs:/var/log/app:ro
command: ["-log-path=/var/log/app", "-output=json"]
volumes:
logs:spec:
containers:
- name: app
image: your-app:latest
volumeMounts:
- name: logs
mountPath: /var/log/app
- name: cidtracker
image: cidtracker:latest
args: ["-log-path=/var/log/app", "-output=json"]
volumeMounts:
- name: logs
mountPath: /var/log/app
readOnly: true
resources:
limits:
memory: "64Mi"
cpu: "50m"
volumes:
- name: logs
emptyDir: {}See Deployment Guide for complete examples.
| Flag | Environment Variable | Default | Description |
|---|---|---|---|
-log-path |
CIDTRACKER_LOG_DIR |
/var/log/app |
Directory to monitor |
-output |
CIDTRACKER_OUTPUT_FORMAT |
json |
Output format (json / structured) |
-verbose |
CIDTRACKER_LOG_LEVEL=debug |
false |
Enable debug logging |
Alpha — Core functionality works. Not yet recommended for production.
- File monitoring with fsnotify
- CID extraction via regex
- UUID validation (all versions)
- JSON and structured output
- Graceful shutdown
- Docker deployment
- HTTP server with
/healthand/metrics - Configurable CID patterns via file
- Log rotation handling
- Multi-file correlation
- Custom output destinations
- UUID version 7 support
| Document | Description |
|---|---|
| API Reference | HTTP endpoints (when enabled) |
| Deployment Guide | Docker, Kubernetes, and configuration |
| Examples | Working docker-compose demo |
| Contributing | How to contribute |
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
The short version:
- Open an issue first — Let's discuss before you code
- Fork → Branch → Code → Test
- Ensure 75% test coverage minimum
- Submit PR referencing the issue
# Run tests
go test ./...
# Check coverage
go test -cover ./...MIT License — see LICENSE for details.
Built with:
- fsnotify — File system notifications
- google/uuid — UUID parsing
- logrus — Structured logging
Built with Go. Made for observability.