Send Cloudflare Workers logs to a destination of your choice with Workers Trace Events Logpush

Tanushree Sharma
4 min readintermediate
--
View Original

Overview

The article discusses the introduction of Workers Trace Events Logpush by Cloudflare, which allows developers to send Workers logs to various destinations for better observability and debugging. It highlights the ease of setup, pricing details, and the benefits of using this feature to enhance application monitoring.

What You'll Learn

1

How to set up Workers Trace Events Logpush to send logs to an object storage destination

2

Why using Workers Logpush enhances application observability and debugging

3

When to utilize filters and sampling rates in Logpush for optimized log management

Key Questions Answered

How can I send Cloudflare Workers logs to a destination of my choice?
You can send Cloudflare Workers logs by setting up a Logpush job that specifies the destination, such as an object storage service like R2. This involves making a POST request to the Cloudflare API with the necessary configuration details, including your account ID and destination path.
What are the pricing details for Workers Logpush?
Workers Logpush is priced at $0.05 per million requests, and users are charged only for requests that result in logs delivered to the end destination after filtering or sampling. Additionally, there is an included usage of 10 million requests each month.
What kind of data does Workers Logpush include in the logs?
Workers Logpush includes metadata about requests, console.log() messages, and any uncaught exceptions. This data helps developers monitor application performance and troubleshoot issues effectively.
How do I configure Workers Logpush for my Workers script?
To configure Workers Logpush, you need to create a Logpush job via the Cloudflare API and enable logging in your Workers script by adding a property to your wrangler.toml file. This setup allows the logs to be automatically picked up by the Logpush job.

Key Statistics & Figures

Cost of Workers Logpush
$0.05 per million requests
This pricing applies only to requests that result in logs delivered to an end destination after filtering or sampling.
Included usage
10 million requests each month
This allows users to utilize the service without immediate charges, facilitating initial testing and integration.

Technologies & Tools

Backend
Cloudflare Workers
Used for deploying serverless applications and handling requests.
Storage
R2
Used as a destination for storing logs sent via Workers Logpush.

Key Actionable Insights

1
Implementing Workers Logpush can significantly enhance your application's debugging capabilities by providing a historical record of logs.
This is particularly useful for monitoring services and troubleshooting issues that only occur in production environments, allowing for quicker resolutions.
2
Utilize filters and sampling rates in Logpush to manage log volume effectively.
By configuring these options, you can focus on critical logs, such as those resulting in exceptions, which helps in reducing noise and improving the efficiency of your monitoring setup.
3
Take advantage of the included 10 million requests each month to experiment with Workers Logpush without incurring additional costs.
This allows developers to familiarize themselves with the feature and assess its benefits before scaling up their usage.

Common Pitfalls

1
Failing to configure the logpull options correctly can lead to missing critical log data.
Ensure that the fields specified in the logpull options are comprehensive enough to capture all necessary information for debugging and monitoring.
2
Not utilizing the included 10 million requests can lead to unnecessary costs when starting with Logpush.
Take advantage of this allowance to explore the feature fully before scaling up your usage.

Related Concepts

Cloudflare API
Serverless Architecture
Observability Tools