Skip to content

Conversation

@takeokunn
Copy link

Summary

  • Add log format support for OpenTelemetry Collector file exporter
  • Implement converter script to flatten batched JSON log records

Motivation

relative issue: #1600

The OpenTelemetry Collector's file exporter writes log records in batched JSON Lines format, where each line contains multiple log records nested under resourceLogs.
This makes it difficult to analyze with lnav without preprocessing.

Changes

  • src/formats/otel_collector_log.json: Log format definition with field mappings for OTEL log records (timestamp, severity, trace_id, span_id, service.name, etc.)
  • src/scripts/otel_collector_log-converter.sh: Converter script using jq to flatten batched records into one-per-line format
  • test/logfile_otel_collector.jsonl: Test data covering various scenarios (multiple services, all severity levels, edge cases)

Test plan

  • make check passes
  • Manual verification with lnav -n test/logfile_otel_collector.jsonl
  • Verify correct field extraction and log level coloring
  • Test with real OpenTelemetry Collector output (if available)

Dependencies

Requires jq to be installed for the converter to work.

- Add otel_collector_log.json format definition for OpenTelemetry Collector
- Add otel_collector_log-converter.sh script for flattening OTEL logs
- Register new format and script in build system
- Add test log file and update test Makefile for OTEL Collector logs
- Improve error handling and argument validation in pcap_log-converter.sh
@takeokunn takeokunn marked this pull request as ready for review January 3, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant