WebSocket Analytics Logpush, Connection Close Events, and Session Measurement
How edge WebSocket connections are counted in analytics, what the websocket_analytics Logpush dataset fields mean, and how to verify bytes and duration.
This page summarises Cloudflare documentation on WebSocket traffic at the edge: how a single connection counts as one HTTP request, how bandwidth and session duration appear in analytics and HTTP request logs, the Enterprise websocket_analytics Logpush dataset (per-connection close events and byte counts), Zero Trust Gateway limits on WebSocket inspection, Workers message size limits, and live log streaming via Instant Logs.
WebSocket requests and bandwidth: how the edge counts usage
Section titled “WebSocket requests and bandwidth: how the edge counts usage”WebSocket usage at Cloudflare is measured differently from ordinary HTTP page loads.Requests: only the initial upgrade handshake counts as one HTTP request for the whole long-lived connection—even when many messages flow in both directions afterward.
Given the nature of WebSocket connections, you may notice they differ from typical HTTP traffic in terms of requests and bandwidth usage. If you are an Enterprise customer, it is important to consider how Cloudflare measures requests and bandwidth to accurately estimate your usage.
Cloudflare measures a single WebSocket connection in the following way:
Requests: Cloudflare recognizes only the initial upgrade request per WebSocket connection as an HTTP request. Even though you can send a bidirectional message stream through the established WebSocket connection, it will be counted as a single long-lived HTTP request.
Bandwidth: Cloudflare measures data transfer sent from Cloudflare to the client. This typically means that messages from the WebSocket server behind Cloudflare to the WebSocket client are counted towards bandwidth usage.
Once a WebSocket connection is closed, you can view your aggregated WebSocket usage through Traffic Analytics, the GraphQL Analytics API, and HTTP requests logs.
— Cloudflare, WebSockets — Requests and Bandwidth measurement
Bandwidth toward billing and dashboards is oriented from Cloudflare toward the client (server-origin messages through the edge to the client). After the connection closes, rollups appear in Traffic Analytics, the GraphQL Analytics API, and HTTP Requests (or zone HTTP Requests) Logpush datasets.
Why WebSocket connections drop during deployments
Section titled “Why WebSocket connections drop during deployments”Edge code releases can restart servers and terminate open WebSockets, which is expected behaviour rather than an application bug.
When Cloudflare releases new code to its global network, we may restart servers, which terminates WebSockets connections.
— Cloudflare, WebSockets — Technical note
HTTP Traffic Analytics and HTTP request logs: full session bytes and duration
Section titled “HTTP Traffic Analytics and HTTP request logs: full session bytes and duration”Dashboard Data Transfer, EdgeResponseBytes in analytics, and session duration in HTTP request logs now reflect the full WebSocket session, not only the 101 Switching Protocols handshake.During an earlier reporting period, some connections logged only handshake bytes and duration; a fix restored correct accounting without changing how connections behave or implying a traffic spike.
Cloudflare has fixed an issue affecting WebSocket data transfer and session duration reporting. HTTP Traffic Analytics and HTTP request logs now correctly report data transferred throughout a WebSocket connection and the duration of the full session. During the affected period, reporting captured only the bytes and duration of the initial 101 Switching Protocols handshake for some WebSocket connections.
Customers with WebSocket traffic will see the correct Data Transfer in the dashboard and EdgeResponseBytes in analytics and HTTP request logs. Reported session duration now reflects the full WebSocket session rather than only the handshake. These changes restore the accounting of existing WebSocket traffic and duration. They do not indicate an increase in traffic or alter WebSocket connection behavior.
The separate WebSocket Analytics Logpush dataset continues to provide per-connection directional byte counts, timestamps, and close details.
— Cloudflare, WebSocket reporting now includes full connection data transfer and duration
For per-connection detail (directional bytes, close reason, timestamps), use the dedicated WebSocket Analytics Logpush dataset described below—not only aggregated HTTP analytics.
EdgeStartTimestamp and EdgeStopTimestamp in HTTP request logs
Section titled “EdgeStartTimestamp and EdgeStopTimestamp in HTTP request logs”In HTTP request logs, EdgeStartTimestamp and EdgeStopTimestamp span the WebSocket connection lifetime, not merely the initial TCP/HTTP setup before the upgrade.
The EdgeStartTimestamp and EdgeStopTimestamp fields in HTTP requests logs represent the duration of the WebSocket connection (they do not represent the initial HTTP connection).
— Cloudflare, WebSockets — Troubleshooting
Reproducing issues with a minimal client (for example wscat) on one URL is the documented first step before correlating timestamps in logs.
websocket_analytics Logpush: per-connection close events and fields
Section titled “websocket_analytics Logpush: per-connection close events and fields”Enterprise customers can push one log record per WebSocket connection when it closes using the websocket_analytics dataset to any Logpush destination. Field definitions live under WebSocket Analytics (account) and WebSocket Analytics (zone).
Enterprise customers can now push per-connection WebSocket analytics to any Logpush destination using the new websocket_analytics dataset. Each log record is emitted when a WebSocket connection closes and includes fields that were previously only available to Cloudflare engineers via internal tooling.
— Cloudflare, New WebSocket Analytics Logpush dataset
ConnectionCloseReason, ConnectionCloseSource, and RayID
Section titled “ConnectionCloseReason, ConnectionCloseSource, and RayID”Close diagnostics and HTTP correlation are first-class fields on each record:
Key fields include:
ConnectionCloseReason — why the connection ended: peerReset, peerNoError, timedOut, upstreamReset, protocolViolation, unspecifiedError, or none. ConnectionCloseSource — which side initiated the close: upstream, downstream, me, or both. ConnectionTransportCloseCode — the TLS alert code or TCP-level close code for additional precision. RayID — correlate WebSocket connection events with your existing HTTP Request logs.
— Cloudflare, New WebSocket Analytics Logpush dataset
RayID ties a closed WebSocket event to the upgrade request in HTTP Requests logs. ConnectionCloseReason supports alert rules—for example spikes in peerReset grouped by host and colo—as noted in the same changelog entry.
Directional byte counts and request metadata
Section titled “Directional byte counts and request metadata”Each close event carries directional byte counts, timestamps, client IP, colo, and upgrade request metadata:
| Field group | Examples (from changelog) |
|---|---|
| Bytes (client ↔ origin) | BytesSentClient, BytesReceivedClient, BytesSentOrigin, BytesReceivedOrigin |
| Connection identity | ConnectionID, RayID, ConnectionCloseReason, ConnectionCloseSource, ConnectionTransportCloseCode |
| Time and edge | EdgeStartTimestamp, EdgeEndTimestamp, ColoCode |
| Client and HTTP upgrade | ClientIP, ClientASN, ClientRequestHost, ClientRequestPath, ClientRequestUserAgent |
WebSocket Analytics: A new dataset with fields including BytesReceivedClient, BytesReceivedOrigin, BytesSentClient, BytesSentOrigin, ClientASN, ClientIP, ClientRequestHost, ClientRequestPath, ClientRequestUserAgent, ColoCode, ConnectionCloseReason, ConnectionCloseSource, ConnectionID, ConnectionTransportCloseCode, EdgeEndTimestamp, EdgeStartTimestamp, and RayID.
— Cloudflare, New WebSocket Analytics Logpush dataset and updated fields — New datasets
The Logs changelog repeats the same dataset announcement for operators who track Logpush product changes.
Zero Trust Gateway: WebSocket traffic and HTTP 101 policies
Section titled “Zero Trust Gateway: WebSocket traffic and HTTP 101 policies”Gateway does not inspect or log the WebSocket frame stream; it logs the HTTP upgrade and network session context instead. To allow or shape WebSocket upgrades in HTTP policies, match response status 101 SWITCHING PROTOCOLS.
Gateway does not inspect or log WebSocket ↗︎ traffic. Instead, Gateway will only log the HTTP details used to make the WebSocket connection, as well as network session information. To filter your WebSocket traffic, create a policy with the 101 HTTP response code.
— Cloudflare, Common policies — Filter WebSocket traffic
| Selector | Operator | Value | Action |
|---|---|---|---|
| HTTP Response | is | 101 SWITCHING PROTOCOLS |
Allow |
The same page documents creating a rule via the Gateway rules API with traffic set to http.response.status_code == 101. Per-connection close analytics still come from websocket_analytics or HTTP logs at the zone, not from deep Gateway WebSocket inspection.
Workers and Durable Objects: WebSocket message size limit
Section titled “Workers and Durable Objects: WebSocket message size limit”The maximum WebSocket message size on Workers-related runtimes was raised from 1 MiB to 32 MiB, affecting large binary or JSON payloads over a single message.
The maximum WebSocket message size limit has been increased from 1 MiB to 32 MiB.
— Cloudflare, Workers platform changelog — 2025-10-25
The same limit appears in Durable Objects release notes. Edge bandwidth measurement still follows client-bound transfer rules on the WebSockets page; message size limits are separate from Logpush close records.
Instant Logs: live WebSocket stream for ad hoc analysis
Section titled “Instant Logs: live WebSocket stream for ad hoc analysis”Instant Logs delivers a live JSON log stream over WebSocket to your client session. The Instant Logs docs show piping the stream through Angle Grinder (agrind) for aggregation—for example summing sampleInterval by ClientCountry:
websocat wss://logs.cloudflare.com/instant-logs/ws/sessions/<SESSION_ID> | agrind '* | json | sum(sampleInterval) by ClientCountry'That path is for exploratory slicing on a session, not a replacement for Logpush websocket_analytics retention and alerting.
Logpull fields parameter (HTTP log APIs)
Section titled “Logpull fields parameter (HTTP log APIs)”When pulling logs via APIs that accept a fields query parameter, explicit field lists are frozen; omitted fields use defaults that may change over time:
Regarding the inclusion of the fields parameter:
When fields are explicitly included in the request URL, the fields returned will not change. When not specified in the URL, the default fields are returned. The default fields may change at any time.
— Cloudflare, Logpull — Additional details
Pin fields in automation if you rely on specific timestamp or byte columns after WebSocket reporting updates.
Common mistakes when reading WebSocket metrics
Section titled “Common mistakes when reading WebSocket metrics”- Treating every WebSocket message as an HTTP request — only the upgrade counts (WebSockets).
- Expecting Gateway HTTP logs to show frame-level WebSocket data — only upgrade HTTP details and network session info (Filter WebSocket traffic).
- Interpreting a sudden rise in bytes after a platform fix as new traffic — reporting may have under-counted handshake-only bytes before the fix (WebSocket reporting changelog).
- Using handshake timestamps for session length in HTTP logs — use
EdgeStartTimestamp/EdgeStopTimestampfor connection duration (Troubleshooting). - Alerting on closes without
RayIDjoin to HTTP Requests — correlate upgrade and close in SIEM queries (websocket_analytics changelog).
How to check this on your site
Section titled “How to check this on your site”-
Confirm measurement rules: one request per connection and client-bound bandwidth in WebSockets — Requests and Bandwidth measurement.
-
In Traffic Analytics and HTTP request logs, check that Data Transfer, EdgeResponseBytes, and duration match a test connection that stays open after the
101response (reporting fix). -
If you are on Enterprise Logpush, enable the websocket_analytics dataset and verify a closed connection emits
ConnectionCloseReason, directional byte fields, and aRayIDmatching HTTP Requests (dataset announcement). -
For Gateway paths, confirm policy matches
http.response.status_code == 101when you intend to allow upgrades (Common policies). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.