This worker will allow you to use Logpush with Logtail. Logpush gzips the request body for the HTTP destination and Logtail does not accept gzipped content, this worker will decompress and send to in.logtail.com. More info in this post.
- Cloudflare
wrangler
installed (npm i -g wrangler
) - Your Cloudflare email address
- Your Cloudflare API Key
- Your Cloudflare Account ID
- Your Cloudflare
worker.dev
Subdomain - Your Logtail SOURCE_TOKEN for HTTP
- Enable Logpush in one of your Cloudflare workers
- Clone this repo
- Deploy this worker via
wrangler publish
- Create your logpush job:
curl -s -X POST 'https://api.cloudflare.com/client/v4/accounts/<your-cloudflare-account-id>/logpush/jobs' -X POST -d '
{
"name": "cf-logpush-to-logtail",
"output_options": {
"field_names": ["Event", "EventTimestampMs", "Outcome", "Exceptions", "Logs", "ScriptName"],
"timestamp_format": "rfc3339"
},
"destination_conf": "https://cf-logpush-to-logtail.<your-worker-subdomain>.workers.dev?header_Authorization=Bearer%20<your-logtail-token>&header_Content-Type=application/json",
"max_upload_bytes": 5000000,
"max_upload_records": 1000,
"dataset": "workers_trace_events",
"enabled": true
}' -H "X-Auth-Email: <your-cloudflare-email>" -H "X-Auth-Key: <your-cloudflare-api-key>"
Modified from the gist by @stefandanaita