Skip to content

LogpushJob

Source: src/Cloudflare/Logpush/Job.ts

A Cloudflare Logpush job that pushes batches of logs (HTTP requests, Workers trace events, audit logs, Zero Trust datasets, …) to a destination such as R2, S3, GCS, or an HTTP endpoint.

Jobs can be account-scoped (default) or zone-scoped (pass zoneId). The dataset, kind, and scope are fixed at creation — changing any of them triggers a replacement; everything else updates in place.

The R2 destination authenticates with S3-compatible credentials embedded in the destination URI, so no ownership challenge is required.

const bucket = yield* Cloudflare.R2Bucket("logs", {});
const job = yield* Cloudflare.LogpushJob("worker-logs", {
dataset: "workers_trace_events",
destinationConf: Output.interpolate`r2://${bucket.bucketName}/{DATE}?account-id=${accountId}&access-key-id=${r2AccessKeyId}&secret-access-key=${r2SecretAccessKey}`,
enabled: true,
});
const job = yield* Cloudflare.LogpushJob("http-logs", {
zoneId: zone.zoneId,
dataset: "http_requests",
destinationConf: "s3://my-bucket/logs?region=us-east-1",
ownershipChallenge: "00000000000000000000",
});
const job = yield* Cloudflare.LogpushJob("worker-logs", {
dataset: "workers_trace_events",
destinationConf,
outputOptions: {
fieldNames: ["EventTimestampMs", "Outcome", "ScriptName"],
outputType: "ndjson",
timestampFormat: "rfc3339",
},
maxUploadIntervalSeconds: 60,
});