Tail a log file
The oldest job in observability: an application writes to a file, you need it in your backend, and you need that to survive a collector restart without duplicating or losing lines. The example parses JSON lines with a ts field; change include and the parser to match your files.
Also searched as: filelog, filelog receiver
- Signals
- Logs
- Category
- CollectionParsingReliability
- Source
- Log files
- Components
- filelogbatchmemory_limiterotlphttp
- Destination
- OTLP/HTTP endpoint
OpenTelemetry Collector
extensions:
file_storage:
directory: /var/lib/otelcol/storage
create_directory: true
receivers:
filelog:
include: [/var/log/myapp/*.log]
start_at: end
storage: file_storage
operators:
- type: json_parser
timestamp:
parse_from: attributes.ts
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80
batch: {}
exporters:
otlphttp:
endpoint: https://your-backend:4318
service:
extensions: [file_storage]
pipelines:
logs:
receivers: [filelog]
processors: [memory_limiter, batch]
exporters: [otlphttp]
LinkMesh
Library › Sources › File Tail
- Include Paths
- ["/var/log/myapp/*.log"]
- Exclude Paths
- []
- Resume After Restart
- true
- Start Reading At
- end
What LinkMesh then pushes to the collector, under receivers:
filelog/input_src_00000501:
exclude: []
include:
- /var/log/myapp/*.log
start_at: end
storage: file_storage/input_src_00000501
# extensions:
file_storage/input_src_00000501:
create_directory: true
directory: /var/lib/otelcol-supervisor/filelog-storage/input_src_00000501
The same, as an API call (see automation recipes):
curl -X POST "$LINKMESH/sources" \
-H "Authorization: Bearer $LMSAT" \
-H "Content-Type: application/json" \
-d '{
"defaultConfig": {
"checkpoint": true,
"exclude": [],
"include": [
"/var/log/myapp/*.log"
],
"start_at": "end"
},
"name": "File Tail",
"receiverType": "filelog"
}'The rest of the collector config above (memory_limiter, batch, otlphttp) is not part of this template: in LinkMesh those are separate sources, processors and destinations on the route.
Generated from LinkMesh's template catalogue by linkmesh-server snippet-render 1.470.5, not written by hand.
Download config.yamlValidated with otelcol-contrib v0.165.0 on 2026-11-30
Complete config files, each checked with the collector's own validate command (otelcol-contrib v0.165.0). Replace https://your-backend:4318 with your own OTLP endpoint before you run it.
Before and after
Example telemetry in, and what this exact config sent out when we ran it in otelcol-contrib v0.165.0. CI re-runs it on every change and fails if the output differs. Changed values are highlighted.
2 log records in, 2 log records out
Before
- body
- {"ts":"2026-10-22T08:15:02.120Z","level":"info","msg":"user signed in","user":"u-4711"}
After
- body
- {"ts":"2026-10-22T08:15:02.120Z","level":"info","msg":"user signed in","user":"u-4711"}
- timestamp
- 2026-10-22T08:15:02.120Z
- attributes.level
- info
- attributes.msg
- user signed in
- attributes.user
- u-4711
- attributes.log.file.name
- input.log
- attributes.ts
- 2026-10-22T08:15:02.120Z
Before
- body
- {"ts":"2026-10-22T08:15:03.884Z","level":"error","msg":"payment provider timeout","order":"1002"}
After
- body
- {"ts":"2026-10-22T08:15:03.884Z","level":"error","msg":"payment provider timeout","order":"1002"}
- timestamp
- 2026-10-22T08:15:03.884Z
- attributes.msg
- payment provider timeout
- attributes.order
- 1002
- attributes.log.file.name
- input.log
- attributes.ts
- 2026-10-22T08:15:03.884Z
- attributes.level
- error
The gotcha
Without a file_storage extension the collector forgets its read position and starts over from start_at after every restart. And file_storage refuses to start when its directory does not exist, which is why create_directory: true is in this config.
Used in these pipelines
Skip the YAML on every host
LinkMesh has this job built in as the File Tail source template: activate it on a collector from the control plane instead of editing config files host by host. The first 25 Collectors are free after a no-card registration in the OpenSight Customer Portal (5 without one).
Doing this in LinkMesh: Sources
Related snippets
- Parse Apache access logs into semantic conventionsTurn Apache combined-format access log lines into semantic-convention attributes, with typed status codes and sizes.
- Parse JSON log lines into attributesTurn each JSON log line into attributes you can filter and group by, keeping the original line as the body.
- Parse key=value log linesTurn logfmt-style key=value lines into attributes, quoted values with spaces included.
- Parse nginx access logs into semantic conventionsTurn nginx combined-format access log lines into OpenTelemetry semantic-convention attributes, with typed status codes.