Skip to content

Commit 31a3046

Browse files
[Rules, Log Explorer] Add Log Explorer and Trace usage guidance (#28802)
* Add Log Explorer and Trace usage guidance (SPM-2171) --------- Co-authored-by: Pedro Sousa <680496+pedrosousa@users.noreply.github.com>
1 parent eaaa83a commit 31a3046

4 files changed

Lines changed: 83 additions & 36 deletions

File tree

src/content/docs/log-explorer/log-search.mdx

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import { TabItem, Tabs, Render, DashButton } from "~/components";
99

1010
Log Explorer enables you to store and explore your Cloudflare logs directly within the Cloudflare dashboard or API, giving you visibility into your logs without the need to forward them to third-party services. Logs are stored on Cloudflare's global network using the R2 object storage platform and can be queried via the dashboard or SQL API.
1111

12+
## When to use Log Explorer
13+
14+
<Render file="log-explorer-use-cases" product="rules" />
15+
16+
<Render file="trace-use-cases" product="rules" params={{ addLink: true }} />
17+
18+
The key difference is that Log Explorer shows actual traffic, while Trace shows simulated "what-if" scenarios.
19+
1220
## Use Log Explorer
1321

1422
You can filter and view your logs via the Cloudflare dashboard or the API.
@@ -27,33 +35,32 @@ You can filter and view your logs via the Cloudflare dashboard or the API.
2735
For example, to find an HTTP request with a specific [Ray ID](/fundamentals/reference/cloudflare-ray-id/), go to **Custom SQL**, and enter the following SQL query:
2836

2937
```sql
30-
SELECT
31-
clientRequestScheme,
32-
clientRequestHost,
33-
clientRequestMethod,
34-
edgeResponseStatus,
35-
clientRequestUserAgent
36-
FROM http_requests
37-
WHERE RayID = '806c30a3cec56817'
38+
SELECT
39+
clientRequestScheme,
40+
clientRequestHost,
41+
clientRequestMethod,
42+
edgeResponseStatus,
43+
clientRequestUserAgent
44+
FROM http_requests
45+
WHERE RayID = '806c30a3cec56817'
3846
LIMIT 1
3947
```
4048

41-
4249
As another example, to find Cloudflare Access requests with selected columns from a specific timeframe you could perform the following SQL query:
4350

4451
```sql
45-
SELECT
46-
CreatedAt,
47-
AppDomain,
48-
AppUUID,
49-
Action,
50-
Allowed,
51-
Country,
52-
RayID,
53-
Email,
54-
IPAddress,
55-
UserUID
56-
FROM access_requests
52+
SELECT
53+
CreatedAt,
54+
AppDomain,
55+
AppUUID,
56+
Action,
57+
Allowed,
58+
Country,
59+
RayID,
60+
Email,
61+
IPAddress,
62+
UserUID
63+
FROM access_requests
5764
WHERE Date >= '2025-02-06' AND Date <= '2025-02-06' AND CreatedAt >= '2025-02-06T12:28:39Z' AND CreatedAt <= '2025-02-06T12:58:39Z'
5865
```
5966

@@ -92,26 +99,26 @@ All the tables supported by Log Explorer contain a special column called `date`,
9299

93100
```sql
94101
SELECT
95-
clientip,
96-
clientrequesthost,
97-
clientrequestmethod,
98-
clientrequesturi,
99-
edgeendtimestamp,
100-
edgeresponsestatus,
101-
originresponsestatus,
102-
edgestarttimestamp,
103-
rayid,
104-
clientcountry,
105-
clientrequestpath,
102+
clientip,
103+
clientrequesthost,
104+
clientrequestmethod,
105+
clientrequesturi,
106+
edgeendtimestamp,
107+
edgeresponsestatus,
108+
originresponsestatus,
109+
edgestarttimestamp,
110+
rayid,
111+
clientcountry,
112+
clientrequestpath,
106113
date
107-
FROM
114+
FROM
108115
http_requests
109-
WHERE
116+
WHERE
110117
date = '2023-10-12' LIMIT 500
111118
```
112119

113120
### Additional query optimization tips
114121

115122
- Narrow your query time frame. Focus on a smaller time window to reduce the volume of data processed. This helps avoid querying excessive amounts of data and speeds up response times.
116123
- Omit `ORDER BY` and `LIMIT` clauses. These clauses can slow down queries, especially when dealing with large datasets. For queries that return a large number of records, reduce the time frame instead of limiting to the newest `N` records from a broader time frame.
117-
- Select only necessary columns. For example, replace `SELECT *` with the list of specific columns you need. You can also use `SELECT RayId` as a first iteration and follow up with a query that filters by the Ray IDs to retrieve additional columns. Additionally, you can use `SELECT COUNT(*)` to probe for time frames with matching records without retrieving the full dataset.
124+
- Select only necessary columns. For example, replace `SELECT *` with the list of specific columns you need. You can also use `SELECT RayId` as a first iteration and follow up with a query that filters by the Ray IDs to retrieve additional columns. Additionally, you can use `SELECT COUNT(*)` to probe for time frames with matching records without retrieving the full dataset.

src/content/docs/rules/trace-request/index.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ head:
88
content: Trace a request with Cloudflare Trace
99
---
1010

11-
import { DirectoryListing, Plan, ProductAvailabilityText } from "~/components";
11+
import {
12+
DirectoryListing,
13+
Plan,
14+
ProductAvailabilityText,
15+
Render,
16+
} from "~/components";
1217

1318
<Plan type="all" />
1419

@@ -18,6 +23,18 @@ You can define specific request properties to simulate different conditions for
1823

1924
Cloudflare Trace is available to users with an Administrator or Super Administrator role.
2025

26+
## When to use Trace
27+
28+
<Render file="trace-use-cases" product="rules" />
29+
30+
<Render
31+
file="log-explorer-use-cases"
32+
product="rules"
33+
params={{ addLink: true }}
34+
/>
35+
36+
The key difference is that Trace simulates "what-if" scenarios, while Log Explorer shows actual historical traffic.
37+
2138
## Resources
2239

2340
<DirectoryListing />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
params:
3+
- addLink?
4+
---
5+
6+
Use { props.addLink ? <a href="/log-explorer/">Log Explorer</a> : "Log Explorer" } when you need to investigate what actually happened with real production traffic:
7+
8+
- Analyzing historical data and trends
9+
- Investigating security incidents after they occur
10+
- Searching for patterns across thousands of requests
11+
- Monitoring application performance over time
12+
- Providing forensic evidence to support teams
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
params:
3+
- addLink?
4+
---
5+
6+
Use { props.addLink ? <a href="/rules/trace-request/">Trace</a> : "Trace" } when you need to test what would happen with a simulated request:
7+
8+
- Understanding why a rule did not trigger as expected
9+
- Testing how your rules handle different request scenarios
10+
- Seeing the evaluation order of your rules
11+
- Simulating requests from different geolocations or conditions

0 commit comments

Comments
 (0)