Skip to content

Decompresses Logpush's gzip encoded requests for Logtail support

Notifications You must be signed in to change notification settings

rhino88/cf-logpush-to-logtail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare Logpush to Logtail Worker

Why?

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.

Prerequisites

  1. Cloudflare wrangler installed (npm i -g wrangler)
  2. Your Cloudflare email address
  3. Your Cloudflare API Key
  4. Your Cloudflare Account ID
  5. Your Cloudflare worker.dev Subdomain
  6. Your Logtail SOURCE_TOKEN for HTTP

Setup

  1. Enable Logpush in one of your Cloudflare workers
  2. Clone this repo
  3. Deploy this worker via wrangler publish
  4. 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>"

Credits

Modified from the gist by @stefandanaita

About

Decompresses Logpush's gzip encoded requests for Logtail support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published