BuildImplementation guide6 min read

Logs Implementation Guide

By Nicolas Narbais

Build a dependable log path with deliberate collection ownership, parsing, infrastructure context, and trace correlation.

Last updated on

Move a service from uncollected log lines to searchable, parsed, trace-correlated logs in Tsuga across five progressive levels.

LevelGoalWhat it proves
1Collect one source onceSearchable test record with stable identity, zero duplicates
2Standardize JSON & routesOne route/owner per source, intact multiline stack traces
3Add Grok for legacy formatsLegacy lines parsed fail-open; new services stay JSON
4Pair runtime infra metricsScoped log pivots work from Kubernetes, Hosts, or Services
5Correlate logs with tracesBidirectional trace_id/span_id pivot (sync + async)
flowchart LR SRC["App stdout / file / journald"] --> COL["OpenTelemetry Collector"] COL --> TL["Tsuga Logs: search, patterns, routes"] CTX["Active trace context (trace_id + span_id)"] -->|"Injected by app logger"| SRC TL <-->|"Bidirectional pivot"| TT["Tsuga Traces"]

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.namespace and service.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 filelog preserving cluster, namespace, pod, container, node, and workload identity.
  • VMs: host Collector reading files or journald (not both if journald mirrors 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.

Note

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:

RuntimeRequired metrics / eventsTarget Tsuga view
KubernetesNode host/kubelet metrics + cluster metrics & object events (k8s.cluster.name)Kubernetes inventory → scoped logs
VMs / nodesHost metrics with usable host identifier on CPU metricHosts inventory → View logs
AWS Lambda / serverlessFunction 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.Context into logging calls and extract the active span context.
  • .NET: export ILogger through OpenTelemetry while Activity.Current is 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.

SymptomCheck firstFix
No logs appear in TsugaCollector health, receiver path/permissions, export errorsFix the first failing hop before touching app code
Duplicate identical logsOverlapping collection routes (e.g., file + journald, or two forwarders)Keep exactly one collection path per source
Wrong or missing parsed fieldsRaw logger output and Tsuga route rank orderFix structured JSON or route rank before editing Grok
Inventory logs pivot emptyRuntime metrics + matching resource identity (k8s.cluster.name, host.name)Deploy/fix metrics collection rather than adding log fields
Logs do not link to tracesActive trace_id/span_id in log record + matching service.nameFix 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.

Scroll to zoom · Drag to pan · Double-click to reset