cflokiworker
is a Cloudflare Tail Worker for pushing logs and unhandled exceptions to Grafana Loki from your Cloudflare workers.
The worker is being used on production for collecting logs from the ScreenshotOne API Gateway which is implemented as a Cloudflare worker.
You can clone the repository and use it directly for your needs without any modifications.
git clone git@github.com:screenshotone/cflokiworker.git
npm install
npm run deploy
Or you can fork it, modify, and deploy your version of the worker. If you feel it can be shared with everybody, don't hesitate to contribute back by creating a pull request.
Once deployed to Cloudflare, you need to update your wrangler.toml
for workers you want to stream logs from:
tail_consumers = [{ service = "logger" }]
When using with GitHub Actions, you need to have 2 secrets available:
- `LOKI_PUSH_URL`` is an HTTP URL of the Loki instance.
LOKI_CREDENTIALS
is a base64-encoded username:password for accessing the Loki instance.
You can learn more about Cloudflare Tail Workers at:
- Cloudflare Tail Workers official documentation.
- A guide on pushing logs to Grafana Loki from Cloudflare Workers with Tail Workers.
cflokiworker
is released under the MIT license.