Logs Implementation Guide
By Nicolas Narbais
Build a dependable log path with deliberate collection ownership, parsing, infrastructure context, and trace correlation.
Move a service from uncollected log lines to searchable, parsed, trace-correlated logs in Tsuga across five progressive levels.
| Level | Goal | What it proves |
|---|---|---|
| 1 | Collect one source once | Searchable test record with stable identity, zero duplicates |
| 2 | Standardize JSON & routes | One route/owner per source, intact multiline stack traces |
| 3 | Add Grok for legacy formats | Legacy lines parsed fail-open; new services stay JSON |
| 4 | Pair runtime infra metrics | Scoped log pivots work from Kubernetes, Hosts, or Services |
| 5 | Correlate logs with traces | Bidirectional trace_id/span_id pivot (sync + async) |
Deploy the Collector through your host or cluster path first. Level 5 assumes traces already reach Tsuga, so complete APM Level 1 before adding trace correlation.
Before starting
- Scope: agree on services, environments, log sources, and named owners.
- Single collection boundary: assign one owner per source (node agent for K8s stdout, host Collector for VM files/journald, or local/sidecar OTLP). Never ingest the same source twice.
- Suppress sensitive data at source: scrub secrets and PII in the application first; treat Collector redaction as a safety net.
- Lock identity: standardize
service.name,deployment.environment.name, and (where used)service.namespaceandservice.version.
Level 1 - Prove single-path log collection
Start with one source, one service, and one environment. Match the receiver to the runtime:
- Kubernetes containers: node-agent
filelogpreserving cluster, namespace, pod, container, node, and workload identity. - VMs: host Collector reading files or
journald(not both ifjournaldmirrors the file). - Direct OTLP logs: send to a local or sidecar Collector (never expose a public OTLP port just for logs).
- Existing forwarders: receive Fluent Bit, FireLens, or cloud streams in a gateway Collector when that is the platform standard.
Enrich source context first, then filter/redact, then batch near the exporter. Emit one unique harmless log line after confirming Collector health, and search for that exact string in Tsuga.
Exit criteria: The unique test record arrives once within expected latency carrying the agreed context.service.name, environment, and source metadata.
Level 2 - Standardize JSON output and route ownership
Keep the existing logging library unless switching solves a concrete problem, and emit one JSON object per line containing a timezone-aware timestamp, severity/level, stable message text, bounded diagnostic fields, and trace_id/span_id once Level 5 is enabled.
Separate routes for application JSON, access logs, system logs, and multiline exceptions using stable metadata (file path, container, namespace, source tag, or fixed JSON field), never fragile message text:
- Collector processing: assemble multiline stack traces into one event, drop noise, and redact sensitive values before leaving your network.
- Tsuga log routes: team-owned ingest rules running in rank order (later routes see earlier mutations, so review rank before adding rules to shared sources).
Initialize OpenTelemetry before the logger and framework when tracing is active, and verify worker threads, cron jobs, and queue consumers separately.
Exit criteria: Every source has one owner, documented schema, retention/redaction policy, and working multiline assembly; application JSON is cleanly separated from platform logs.
Level 3 - Use Grok only for legacy text formats
Restrict Grok parsing to legacy apps, infrastructure logs, access logs, or vendor tools that cannot emit JSON. New services must emit structured JSON.
Collect sanitized samples (normal, error, multiline, optional, malformed) before writing patterns, and extract only fields investigators query (timestamp, severity, message, bounded attributes). Never index raw URLs, IDs, user input, or payload bodies. Run parsing in either a Tsuga log route (team-owned ingest parsing) or the Collector (when reshaping/redacting pre-egress), never both.
Grok operational rules: Parsing fails open (unmatched lines stay searchable and increment parse-failure metrics; never drop unmatched errors). Validate with Preview and test valid, malformed, and multiline inputs after saving; route edits apply only to newly ingested logs.
Exit criteria: Legacy formats have documented owners and patterns, valid lines parse cleanly, unmatched lines remain searchable with visible parse-failure tracking, and new services default to JSON.
Level 4 - Pair runtime infrastructure metrics for log pivots
Logs alone never populate Tsuga’s Kubernetes or Hosts inventories. Add the matching infrastructure metrics and verify scoped pivots:
| Runtime | Required metrics / events | Target Tsuga view |
|---|---|---|
| Kubernetes | Node host/kubelet metrics + cluster metrics & object events (k8s.cluster.name) | Kubernetes inventory → scoped logs |
| VMs / nodes | Host metrics with usable host identifier on CPU metric | Hosts inventory → View logs |
| AWS Lambda / serverless | Function metrics + traces (not in Hosts/K8s inventory) | Services, Logs, Traces (and Cloud Resources if connected) |
Verify on one workload per runtime that the inventory view lists the expected identity, metric and log resource attributes match, and the logs pivot stays tightly scoped without duplicates.
Exit criteria: Runtime infrastructure metrics populate the target inventory view and its logs pivot opens only that resource’s records.
Level 5 - Correlate logs with traces
Enable only once traces reach Tsuga. The application must emit active trace_id and span_id alongside matching service.name. Collectors preserve those fields but cannot invent missing context (never infer trace context from request IDs or log text):
- Java: enable agent/logger integration and include MDC or Log4j2 trace fields in structured output.
- Python: initialize logging instrumentation before configuring handlers or framework logging.
- Node.js: initialize OpenTelemetry before logger and framework; test worker threads separately.
- Go: pass
context.Contextinto logging calls and extract the active span context. - .NET: export
ILoggerthrough OpenTelemetry whileActivity.Currentis active.
For asynchronous work, propagate W3C trace context across the queue/job boundary and restore it before emitting consumer logs.
Exit criteria: Request logs and traces share identical service.name and link bidirectionally across both synchronous requests and in-scope background jobs/consumers.
Make it operational
Add alerts only after collection, parsing, and identity are stable:
- Failure shapes over volume: use a new-error-pattern monitor to surface novel release regressions without pre-written queries, plus threshold monitors with a minimum floor for known errors.
- Collector health: alert the Collector-owning team on export errors, queue pressure, or drops.
- Team dashboard: error counts by service, top patterns, parse failures, and volume by source (built from validated Analytics queries).
- Retention & access: treat retention as a data-handling policy per source, not just a cost knob, and review parse failures after every release.
Troubleshooting path
Validate in source order: emission → Collector → Tsuga record.
| Symptom | Check first | Fix |
|---|---|---|
| No logs appear in Tsuga | Collector health, receiver path/permissions, export errors | Fix the first failing hop before touching app code |
| Duplicate identical logs | Overlapping collection routes (e.g., file + journald, or two forwarders) | Keep exactly one collection path per source |
| Wrong or missing parsed fields | Raw logger output and Tsuga route rank order | Fix structured JSON or route rank before editing Grok |
| Inventory logs pivot empty | Runtime metrics + matching resource identity (k8s.cluster.name, host.name) | Deploy/fix metrics collection rather than adding log fields |
| Logs do not link to traces | Active trace_id/span_id in log record + matching service.name | Fix logger init order or async W3C context propagation |
Completion criterion and CLI validation
Every in-scope source has one owner, route, documented format, retention/redaction policy, and tested alerts; a known log arrives once with parsed fields, stable identity, and a working trace_id pivot.
# 1. Confirm the test log arrived once with parsed fields and trace_id
tsuga logs search \
--query "context.service.name:<service> <unique-log-token>" \
--from -15m \
--to now \
--max-results 10
# 2. Confirm the matching trace shares the exact service.name
tsuga traces search \
--query "context.service.name:<service>" \
--from -15m \
--to now \
--max-results 10
Two identical rows from command 1 indicate duplicate collection; an empty trace_id points to logger initialization or context propagation.
References
Written by
Nicolas Narbais
Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.
Olatuak Editorial Philosophy
Better signal, not more telemetry.
Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.
