Skip to content

Commit 0f119e6

Browse files
authored
WO-250 add invocation logs docs (#18032)
* WO-250 add invocation logs docs * WO-250 copy --------- Co-authored-by: Thomas Ankcorn <[email protected]>
1 parent db0c6f1 commit 0f119e6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/content/docs/workers/observability/logs/workers-logs.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You must add the observability setting for your Worker to write logs to Workers
3535
head_sampling_rate = 1 # optional. default = 1.
3636
```
3737

38-
[Head-based sampling](/workers/observability/logs/workers-logs/#head-based-sampling) allows you set the percentage of Workers requests that are logged.
38+
[Head-based sampling](/workers/observability/logs/workers-logs/#head-based-sampling) allows you set the percentage of Workers requests that are logged.
3939

4040
### Enabling with environments
4141

@@ -66,13 +66,13 @@ Access logs for your Worker from the [Cloudflare dashboard](https://dash.cloudfl
6666

6767
To get the most out of Workers Logs, it is recommended you log in JSON format. Workers Logs automatically extracts the fields and indexes them intelligently in the database. The benefit of this structured logging technique is in how it allows you to easily segment data across any dimension for fields with unlimited cardinality. Consider the following scenarios:
6868

69-
| Scenario | Logging Code | Event Log (Partial) |
69+
| Scenario | Logging Code | Event Log (Partial) |
7070
| -------- | ---------------------------------------------------------- | --------------------------------------------- |
7171
| 1 | `console.log("user_id: " + 123)` | `{message: "user_id: 123"}` |
7272
| 2 | `console.log({user_id: 123})` | `{user_id: 123}` |
7373
| 3 | `console.log({user_id: 123, user_email: "[email protected]"})` | `{user_id: 123, user_email: "[email protected]"}` |
7474

75-
The difference between these examples is in how you index your logs to enable faster queries. In scenario 1, the `user_id` is embedded within a message. To find all logs relating to a particular user_id, you would have to run a text match. In scenarios 2 and 3, your logs can be filtered against the keys `user_id` and `user_email`.
75+
The difference between these examples is in how you index your logs to enable faster queries. In scenario 1, the `user_id` is embedded within a message. To find all logs relating to a particular user_id, you would have to run a text match. In scenarios 2 and 3, your logs can be filtered against the keys `user_id` and `user_email`.
7676

7777
## Features
7878

@@ -82,6 +82,13 @@ Each Workers invocation returns a single invocation log that contains details su
8282

8383
In the Workers Logs UI, logs are presented with a localized timestamp and a message. The message is dependent on the invocation handler. For example, Fetch requests will have a message describing the request method and the request URL, while cron events will be listed as cron. Below is a list of invocation handlers along with their invocation message.
8484

85+
Invocation logs can be disabled in wrangler by adding the `invocation_logs = false` configuration.
86+
87+
```toml
88+
[observability.logs]
89+
invocation_logs = false
90+
```
91+
8592
| Invocation Handler | Invocation Message |
8693
| --------------------------------------------------------------- | -------------------------- |
8794
| [Alarm](/durable-objects/api/alarms/) | \<Scheduled Time\> |
@@ -158,7 +165,7 @@ head_sampling_rate = 0.01 # 1% sampling rate
158165
## Limits
159166

160167
| Description | Retention |
161-
| ------------------------------------------------------------------ | ---------- |
168+
| ------------------------------------------------------------------ | ---------- |
162169
| Maximum log retention period | 7 Days |
163170
| Maximum logs per account per day<sup>1</sup> | 5 Billion |
164171
| Maximum log size<sup>2</sup> | 128 KB |
@@ -181,7 +188,7 @@ Workers Logs billing will begin on November 1, 2024.
181188
A Worker serves 15 million requests per month. Each request emits 1 invocation log and 1 `console.log`. `head_sampling_rate` is configured to 1.
182189

183190
| | Monthly Costs | Formula |
184-
| ---------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
191+
| ---------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
185192
| **Logs** | $6.00 | ((15,000,000 requests per month \* 2 logs per request \* 100% sample) - 20,000,000 included logs) / 1,000,000 \* $0.60 |
186193
| **Total** | $6.00 | |
187194

@@ -190,6 +197,6 @@ A Worker serves 15 million requests per month. Each request emits 1 invocation l
190197
A Worker serves 1 billion requests per month. Each request emits 1 invocation log and 1 `console.log`. `head_sampling_rate` is configured to 0.1.
191198

192199
| | Monthly Costs | Formula |
193-
| ---------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
200+
| ---------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
194201
| **Logs** | $108.00 | ((1,000,000,000 requests per month \* 2 logs per request \* 10% sample) - 20,000,000 included logs) / 1,000,000 \* $0.60 |
195202
| **Total** | $108.00 | |

0 commit comments

Comments
 (0)