Send application events and OpenTelemetry to Cloudflare R2
Send JSON events over HTTP or export telemetry over OTLP to Send2Bucket. It writes gzip NDJSON objects to your Cloudflare R2 bucket through the S3 API, partitioned by date and hour. You’ll need an R2 bucket and an API token.
Logpush or Send2Bucket?
Search for "send logs to R2" and you find Cloudflare Logpush. Logpush exports logs that Cloudflare produces about your traffic, such as HTTP requests, firewall events and Workers trace events, and R2 is one of its destinations. It does not accept records from your own code.
| You want in R2 | Use |
|---|---|
| Cloudflare's request, firewall or Workers trace logs | Logpush |
Your application's events, such as order.paid or signup, as JSON | Send2Bucket POST /v1/events |
| Logs, traces and metrics from OpenTelemetry SDKs or a Collector | Send2Bucket's OTLP endpoint |
Both can write to the same bucket under different prefixes.
How it works
curl, SDK or Collector ──HTTPS──▶ api.send2bucket.com ──S3 API──▶ <account_id>.r2.cloudflarestorage.com/<bucket>/<prefix>/s2b/…
- A
204for JSON, or a200or gRPCOKfor OTLP, means the batch is stored durably and will be delivered at least once. See Delivery semantics. - Send2Bucket writes an object when a delivery batch reaches 16 MiB, or after 10 seconds on Free and 60 seconds on the other plans, whichever comes first.
- Objects sit under
date=YYYY-MM-DD/hour=HH/folders, so a query for one day reads only that day's objects. Delivery format has the full layout.
1. Create the bucket and an API token
Create the bucket in the Cloudflare dashboard, or with Wrangler as Create buckets shows:
wrangler r2 bucket create <bucket>
Then create an API token, following R2 authentication:
- On the R2 object storage page, open Overview and select Manage next to API Tokens.
- Select Create Account API token. An account token keeps working if the person who made it leaves the account.
- Under Permissions, choose Object Read & Write and scope the token to the bucket.
- Create the token and copy the Access Key ID and Secret Access Key. Cloudflare shows the secret only once.
Your account ID is in the dashboard too. The S3 endpoint is https://<account_id>.r2.cloudflarestorage.com; a bucket created in a jurisdiction uses that jurisdiction's endpoint, such as https://<account_id>.eu.r2.cloudflarestorage.com.
2. Add R2 as a destination
Create an ingestion stream in the dashboard and add an S3-compatible destination:
| Field | Value for R2 |
|---|---|
bucket | <bucket> |
endpoint | https://<account_id>.r2.cloudflarestorage.com |
region | auto. R2's S3 API also treats an empty value and us-east-1 as auto. |
prefix | raw, or any folder name |
addressing | path, the default. R2 accepts both styles; Cloudflare's presigned URL examples show each. |
access_key_id, secret_access_key | The token's Access Key ID and Secret Access Key |
Select Verify. Send2Bucket writes a test object under raw/s2b/_verify/ and reads it back, and the destination becomes active. Copy the stream's API key when the dashboard shows it:
export S2B_API_KEY=s2b_ingest_...
3. Send JSON events
POST /v1/events takes one JSON object or an array of objects. Each object is stored unchanged as one line:
curl -sS -w '%{http_code}\n' https://api.send2bucket.com/v1/events \
-H "Authorization: Bearer $S2B_API_KEY" \
-H 'Content-Type: application/json' \
-d '[{"event":"order.paid","order_id":"ord_20931","cents":4200},
{"event":"signup","user_id":"usr_0042","plan":"free"}]'
204
A 204 with an empty body means stored. The whole request is accepted or rejected; one invalid item rejects all of it. A request can be up to 8 MiB decompressed. The API reference lists every error code.
4. Send OpenTelemetry
OpenTelemetry SDKs read the standard exporter variables, so a service that already exports OTLP needs no code change:
export OTEL_SERVICE_NAME=checkout
export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.send2bucket.com
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer%20$S2B_API_KEY"
The SDK appends /v1/traces, /v1/logs and /v1/metrics. http/protobuf and http/json both work. gRPC works too, at the endpoint in the API reference.
If services already export to a Collector, add an otlphttp exporter and list it in each pipeline:
receivers:
otlp:
protocols:
grpc:
http:
exporters:
otlphttp/s2b:
endpoint: https://api.send2bucket.com
headers:
authorization: Bearer ${env:S2B_API_KEY}
compression: gzip
service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlphttp/s2b]
logs:
receivers: [otlp]
exporters: [otlphttp/s2b]
metrics:
receivers: [otlp]
exporters: [otlphttp/s2b]
Collector 0.165.0 logs a warning that the otlphttp name is deprecated in favour of otlp_http; both work there. OpenTelemetry to Amazon S3 covers the same setup in more detail, and its queries run unchanged on R2 once the DuckDB secret below is in place.
5. Check the objects arrived
Cloudflare documents the AWS CLI with R2: run aws configure with the token's keys and region auto, then pass the R2 endpoint on each command. Use a token with Object Read to list, not the one Send2Bucket writes with:
aws s3 ls s3://<bucket>/raw/s2b/ --recursive --endpoint-url https://<account_id>.r2.cloudflarestorage.com | tail -3
2026-11-23 00:38:12 276 raw/s2b/stream=<stream_id>/date=2026-11-23/hour=00/dlv_00361pmf1hu4r6dbj9j71npsqc4h0.ndjson.gz
2026-11-23 00:38:27 935 raw/s2b/stream=<stream_id>/date=2026-11-23/hour=00/dlv_00361pmfu5f3ea8tfudlpeub1mghe.ndjson.gz
2026-11-23 00:38:51 601 raw/s2b/stream=<stream_id>/date=2026-11-23/hour=00/dlv_00361pmhbu9uvan78vnlp74qs926s.ndjson.gz
For rclone, Cloudflare's rclone example has the remote configuration; with a bucket-scoped token, add no_check_bucket = true as it says. If nothing arrives, open the stream in the dashboard: it shows the destination's status and last error. A token that R2 refuses turns the destination blocked; batches are kept, and delivery resumes after you verify again (Delivery semantics).
6. Query the objects
DuckDB reads R2 with an S3 secret that carries the endpoint. Use a read-only token here as well:
INSTALL httpfs; LOAD httpfs;
CREATE SECRET s2b_bucket (
TYPE s3, KEY_ID '<access_key_id>', SECRET '<secret_access_key>',
REGION 'auto', ENDPOINT '<account_id>.r2.cloudflarestorage.com');
CREATE VIEW records AS
SELECT * FROM read_json(
's3://<bucket>/raw/s2b/stream=*/date=*/hour=*/*.ndjson.gz',
format = 'newline_delimited',
hive_partitioning = true,
columns = {v: 'INTEGER', delivery_batch_id: 'VARCHAR', batch_id: 'VARCHAR',
received_at: 'TIMESTAMPTZ', signal: 'VARCHAR',
resource: 'JSON', scope: 'JSON', data: 'JSON'});
CREATE MACRO service(resource) AS (
SELECT a->>'$.value.stringValue'
FROM unnest(json_extract(resource, '$.attributes[*]')) AS t(a)
WHERE a->>'$.key' = 'service.name');
Events by name today, with revenue from cents:
SELECT data->>'$.event' AS event, count(*) AS events,
sum((data->>'$.cents')::BIGINT) / 100 AS revenue
FROM records
WHERE signal = 'event' AND date = current_date
GROUP BY ALL
ORDER BY events DESC;
OpenTelemetry records per service and signal:
SELECT service(resource) AS service, signal, count(*) AS records
FROM records
WHERE signal IN ('log', 'span', 'metric') AND date = current_date
GROUP BY ALL
ORDER BY service, signal;
Everything one trace recorded, spans and logs together:
SELECT signal,
make_timestamp_ns(coalesce(data->>'$.startTimeUnixNano', data->>'$.timeUnixNano')::BIGINT) AS ts,
coalesce(data->>'$.name', data->>'$.body.stringValue') AS what,
data->>'$.severityText' AS severity
FROM records
WHERE data->>'$.traceId' = '<trace_id>'
ORDER BY ts;
┌─────────┬───────────────────────────────┬────────────────┬──────────┐
│ signal │ ts │ what │ severity │
├─────────┼───────────────────────────────┼────────────────┼──────────┤
│ span │ 2026-11-23 00:38:23.743983134 │ POST /orders │ NULL │
│ log │ 2026-11-23 00:38:23.744024064 │ order received │ INFO │
│ span │ 2026-11-23 00:38:23.74442215 │ charge card │ NULL │
│ log │ 2026-11-23 00:38:23.794593024 │ card declined │ ERROR │
└─────────┴───────────────────────────────┴────────────────┴──────────┘
These guides also show the R2 settings for their engine: ClickHouse, Apache Spark, StarRocks, Dremio, Databricks and Python. Each record's envelope is described in Delivery format.
Limits and costs
- Send2Bucket. A request can be up to 8 MiB decompressed. Send2Bucket bills the stored JSON of each record it accepts; see Plans and billing. It does not deduplicate retried requests (Retries).
- R2 operations. Each object is one
PutObject, a Class A operation; verification and retries addHeadObject, a Class B operation. A busy stream on a 60-second timer writes about 1,440 objects a day, roughly 45,000 a month. - R2 price. From R2 pricing for Standard storage: $0.015 per GB-month, $4.50 per million Class A and $0.36 per million Class B operations, with 10 GB-month, 1 million Class A and 10 million Class B free each month. Data read through the S3 API has no egress charge, so an engine outside Cloudflare pays R2 only for the requests.
- R2 limits. R2 limits allow 5 GiB per single upload and 1,024-byte keys; Send2Bucket's objects are at most 16 MiB before compression, with keys well under that.
- Retention. Send2Bucket never deletes objects. Add an object lifecycle rule on
raw/s2b/to delete them, or move them to Infrequent Access, after a number of days. Infrequent Access bills at least 30 days per object.
Other ways to get data into R2
- Cloudflare Pipelines: much cheaper per GB when the data can stay in R2, and adds SQL transforms, but has no OTLP endpoint.
- Cloudflare Logpush: for Cloudflare's own logs, as above.
- Write your own producer with an S3 SDK and the R2 endpoint: you handle batching, retries and object naming.