OpenTelemetry Collector to S3
Writes logs, metrics, and traces to S3 as gzipped OTLP JSON, one prefix per signal, with disk-backed queues.
Everything the collector receives goes to one S3 bucket, with an awss3 exporter and prefix per signal (logs/, metrics/, traces/), so one signal's backlog does not hold up the others and a lifecycle rule or reader can target one signal.
Keys follow logs/year=YYYY/month=MM/day=DD/hour=HH/minute=mm/logs_<random number>.json.gz in UTC, likewise for metrics and traces. Each exporter queues batches on disk and retries every S3 error forever (max_elapsed_time: 0), so queued batches survive restarts and S3 outages delay data instead of dropping it, until the queue fills (1,000 batches by default) and new data for its signal is dropped.
Run it as a gateway and point SDKs and agents at port 4317 (gRPC) or 4318 (HTTP).
Set S3_REGION and S3_BUCKET to the bucket's region and name. The config holds no credentials. The AWS SDK's default chain checks, in order, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, a web identity token (like the one EKS IAM roles for service accounts mount), shared credentials and config files, an ECS task role, and an EC2 instance role.
For an S3-compatible store, set S3_ENDPOINT to its URL and S3_FORCE_PATH_STYLE to true. Without path style, the SDK sends requests for a hostname endpoint to <bucket>.<endpoint host>, which fails unless the store and its DNS are set up for virtual-hosted style. On AWS, leave both unset and ignore the harmless Configuration references unset environment variable startup warning.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::<bucket>/*"
}
]
}Collector config (YAML)ShowHide
# Ship OTel data to S3
# Writes logs, metrics, and traces to one S3 bucket as gzipped OTLP JSON,
# one prefix per signal, partitioned by minute in UTC. Each exporter keeps
# its queue on disk, so queued data survives a restart and waits out an S3 outage.
# otelcol-contrib v0.159.0.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # the default binds to localhost
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 512
spike_limit_mib: 128
batch:
send_batch_size: 8192
timeout: 60s # each flush is one S3 object, so a long timeout means fewer, larger objects
exporters:
awss3/logs:
marshaler: otlp_json # the default, written out; otlp_proto writes .binpb.gz objects instead
s3uploader:
region: ${env:S3_REGION}
s3_bucket: ${env:S3_BUCKET}
s3_prefix: logs # one prefix per signal
s3_partition_timezone: UTC # the default is the collector's local time zone
compression: gzip # keys end in .json.gz
endpoint: ${env:S3_ENDPOINT} # leave unset for AWS; set for an S3-compatible store
s3_force_path_style: ${env:S3_FORCE_PATH_STYLE} # true for stores that want the bucket in the path
timeout: 30s # the default is 5s
retry_on_failure:
enabled: true
max_elapsed_time: 0 # keep retrying; the disk queue holds the backlog
sending_queue:
enabled: true # off by default on this exporter
storage: file_storage
awss3/metrics:
marshaler: otlp_json
s3uploader:
region: ${env:S3_REGION}
s3_bucket: ${env:S3_BUCKET}
s3_prefix: metrics
s3_partition_timezone: UTC
compression: gzip
endpoint: ${env:S3_ENDPOINT}
s3_force_path_style: ${env:S3_FORCE_PATH_STYLE}
timeout: 30s
retry_on_failure:
enabled: true
max_elapsed_time: 0
sending_queue:
enabled: true
storage: file_storage
awss3/traces:
marshaler: otlp_json
s3uploader:
region: ${env:S3_REGION}
s3_bucket: ${env:S3_BUCKET}
s3_prefix: traces
s3_partition_timezone: UTC
compression: gzip
endpoint: ${env:S3_ENDPOINT}
s3_force_path_style: ${env:S3_FORCE_PATH_STYLE}
timeout: 30s
retry_on_failure:
enabled: true
max_elapsed_time: 0
sending_queue:
enabled: true
storage: file_storage
extensions:
health_check:
endpoint: 0.0.0.0:13133
file_storage:
directory: /var/lib/otelcol/file_storage
create_directory: true # the default expects the directory to exist
service:
extensions: [health_check, file_storage]
pipelines:
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [awss3/logs]
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [awss3/metrics]
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [awss3/traces]Use this flow
Open the config in Telflo and it becomes a working pipeline on the canvas: adapt what's specific to you, test it against recorded traffic, and push it to your fleet. Free account, no card.
Components
What's in it, and why
Binds to 0.0.0.0 so other hosts can reach it.
Checks memory every second and refuses data once usage passes 384 MiB (512 MiB limit minus 128 MiB spike allowance), so senders back off and retry before the collector runs out of memory. Scale both with the host.
Flushes at 8,192 items or after 60 seconds, and each flush becomes one S3 object, about 1,440 per signal per day for a gateway that gets data every minute. A shorter timeout means more objects and PUT requests.
Writes logs under `logs/`.
Writes metrics under `metrics/`.
Writes spans under `traces/`.
Answers liveness checks on port 13133 from the container runtime or load balancer.
Holds the exporter queues in `/var/lib/otelcol/file_storage`, created if missing. Keep it on a persistent volume so they survive restarts.
Notes
Gotchas
- 1
Key partitions use upload time, not record time, so data queued through an outage lands under the minute it was written.
- 2
The batch processor holds up to 60 seconds of data in memory before the disk queue, so a crash or
kill -9loses it. - 3
A bucket policy that denies writes keeps batches retrying while the queue fills. Watch
otelcol_exporter_queue_size,otelcol_exporter_enqueue_failed_log_recordsand its metric and span twins, and the log forExporting failed. - 4
A timed-out upload that still landed is retried under a new random key, so readers should tolerate occasional duplicates.
- 5
Objects hold gzip bytes and carry
Content-Encoding: gzip. Decompress a download withgunzipbefore reading it. - 6
S3 keeps objects until deleted. A lifecycle rule can expire them by age.
- 7
Replay is a separate collector with the
awss3receiver in time-range mode (starttime,endtime) on one signal's prefix. Like any reader that builds keys from a time range, it needss3_partition_timezone: UTCto match the exporters, which override their local-time default. Setmarshaler: otlp_protoon all three exporters to write.binpb.gzinstead of.json.gz. The receiver reads both.
Sources and references (24)ShowHide
Everything consulted while researching and fact-checking this flow, including the README of every component it uses.
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/README.md
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/factory.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/config.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/exporter.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/marshaler.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/s3_writer.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/internal/upload/partition.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/exporter/awss3exporter/internal/upload/writer.go
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/receiver/awss3receiver/README.md
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/receiver/awss3receiver/receiver.go
- github.com/open-telemetry/opentelemetry-collector/blob/v0.159.0/receiver/otlpreceiver/README.md
- github.com/open-telemetry/opentelemetry-collector/blob/v0.159.0/processor/memorylimiterprocessor/README.md
- github.com/open-telemetry/opentelemetry-collector/blob/v0.159.0/processor/batchprocessor/README.md
- github.com/open-telemetry/opentelemetry-collector/blob/v0.159.0/exporter/exporterhelper/README.md
- github.com/open-telemetry/opentelemetry-collector/blob/v0.159.0/exporter/exporterhelper/internal/retry_sender.go
- github.com/open-telemetry/opentelemetry-collector/blob/v0.159.0/exporter/exporterhelper/metadata.yaml
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/extension/storage/filestorage/README.md
- github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.159.0/extension/healthcheckextension/README.md
- docs.aws.amazon.com/sdk-for-go/v2/developer-guide/configure-gosdk.html
- docs.aws.amazon.com/eks/latest/userguide/pod-configuration.html
- docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
- docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
- docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html
- docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html
More flows
Related flows
Replace vendor agents on your VM fleet
Scrapes CPU, memory, load, disk, filesystem, and network metrics plus system and application logs on every VM.
Ship OTel data to ClickHouse
The ClickStack (HyperDX) ingestion collector as upstream ships it: parses JSON log bodies into attributes, infers severity from level fields or the body text, and routes browser session-replay events to their own ClickHouse table.
Collect per-node telemetry with a DaemonSet
Per-node DaemonSet that scrapes kubelet and host metrics, tails pod logs with the container parser and file_storage checkpoints, enriches everything with k8sattributes, and forwards to the in-cluster gateway.
Test it before your fleet runs it
Free account, no card. Open this flow in the editor, adapt it, and see what it does to real data before anything ships.