

# Information collected by the CloudWatch RUM web client
<a name="CloudWatch-RUM-datacollected"></a>

This section documents the **PutRumEvents** schema, which defines the structure of the data that you can collect from user sessions using CloudWatch RUM.

A **PutRumEvents** request sends a data structure with the following fields to CloudWatch RUM.
+ The ID of this batch of RUM events
+ App monitor details, which includes the following:
  + App monitor ID
  + Monitored application version
+ User details, which includes the following.** This is collected only if the app monitor has cookies enabled.**
  + A user ID generated by the web client
  + Session ID
+ The array of [RUM events](#CloudWatch-RUM-datacollected-event) in this batch.

## RUM event schema
<a name="CloudWatch-RUM-datacollected-event"></a>

The structure of each RUM event includes the following fields.
+ The ID of the event
+ A timestamp
+ The event type
+ The user agent
+ [Metadata](#CloudWatch-RUM-datacollected-metadata)
+ [RUM event details](#CloudWatch-RUM-datacollected-eventDetails)

## RUM event metadata
<a name="CloudWatch-RUM-datacollected-metadata"></a>

The metadata includes page metadata, user agent metadata, geolocation metadata, and domain metadata.

### Page metadata
<a name="CloudWatch-RUM-datacollected-metadata-page"></a>

The page metadata includes the following:
+ Page ID
+ Page title
+ Parent page ID. – **This is collected only if the app monitor has cookies enabled.**
+ Interaction depth – **This is collected only if the app monitor has cookies enabled.**
+ Page tags – You can add tags to page events to group pages together. For more information, see [Use page groups](CloudWatch-RUM-page-groups.md).

### User agent metadata
<a name="CloudWatch-RUM-datacollected-metadata-useragent"></a>

The user agent metadata includes the following:
+ Browser language
+ Browser name
+ Browser version
+ Operating system name
+ Operating system version
+ Device type
+ Platform type

### Geolocation metadata
<a name="CloudWatch-RUM-datacollected-metadata-geolocation"></a>

The geolocation metadata includes the following:
+ Country code
+ Subdivision code

### Domain metadata
<a name="CloudWatch-RUM-datacollected-metadata-domain"></a>

The domain metadata includes the URL domain.

## RUM event details
<a name="CloudWatch-RUM-datacollected-eventDetails"></a>

The details of an event follow one of the following type of schemas, depending on the event type.

### Session start event
<a name="CloudWatch-RUM-datacollected-sessionstart"></a>

This event contains no fields. **This is collected only if the app monitor has cookies enabled.**

### Page view schema
<a name="CloudWatch-RUM-datacollected-pageview"></a>

A **Page view** event contains the following properties. You can deactivate page view collection by configuring the web client. For more information, see the [ CloudWatch RUM web client documentation](https://github.com/aws-observability/aws-rum-web/blob/main/docs/cdn_installation.md).


| Name | Type | Description | 
| --- | --- | --- | 
|  **Page ID** |  String  |  An ID that uniquely represents this page within the application. By default, this is the URL path.  | 
|  **Parent page ID** |  String  |  The ID of the page that the user was on when they navigated to the current page. **This is collected only if the app monitor has cookies enabled.**   | 
|  **Interaction depth** |  String  |  **This is collected only if the app monitor has cookies enabled.**   | 

### JavaScript error schema
<a name="CloudWatch-RUM-datacollected-JavaScriptError"></a>

JavaScript error events generated by the agent contain the following properties. The web client collects these events only if you selected to collect the errors telemetry.


| Name | Type | Description | 
| --- | --- | --- | 
|  **Error type** |  String  |  The error's name, if one exists. For more information, see [Error.prototype.name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name). Some browsers might not support error types.  | 
|  **Error message** |  String  |  The error's message. For more information, see [Error.prototype.message](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message). If the error field does not exist, this is the message of the error event. For more information, see [ErrorEvent](https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent).  Error messages might not be consistent across different browsers.  | 
|  **Stack trace** |  String  |  The error's stack trace, if one exists, truncated to 150 characters. For more information, see [Error.prototype.stack](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack).  Some browsers might not support stack traces.  | 

### DOM event schema
<a name="CloudWatch-RUM-datacollected-DOMEvent"></a>

Document object model (DOM) events generated by the agent contain the following properties. These events are not collected by default. They are collected only if you activate the interactions telemetry. For more information, see the [ CloudWatch RUM web client documentation](https://github.com/aws-observability/aws-rum-web/blob/main/docs/cdn_installation.md).


| Name | Type | Description | 
| --- | --- | --- | 
|  **Event** |  String  |  The type of DOM event, such as click, scroll, or hover. For more information, see [Event reference](https://developer.mozilla.org/en-US/docs/Web/Events).  | 
|  **Element** |  String  |  The DOM element type  | 
|  **Element ID** |  String  |  If the element that generated the event has an ID, this property stores that ID. For more information, see [Element.id](https://developer.mozilla.org/en-US/docs/Web/API/Element/id).  | 
|  **CSSLocator** |  String  |  The CSS locator used to identify the DOM element.  | 
|  **InteractionId** |  String  |  A unique ID for the interaction between the user and the UI.  | 

### Navigation event schema
<a name="CloudWatch-RUM-datacollected-NavigationEvent"></a>

Navigation events are collected only if the app monitor has performance telemetry activated.

Navigation events use [Navigation timing Level 1](https://www.w3.org/TR/navigation-timing/#performancetiming) and [Navigation timing Level 2](https://w3c.github.io/navigation-timing) APIs. Level 2 APIs are not supported on all browsers, so these newer fields are optional.

**Note**  
Timestamp metrics are based on [DOMHighResTimestamp](https://www.w3.org/TR/hr-time-2/#sec-domhighrestimestamp). With Level 2 APIs, all timings are by default relative to the `startTime`. But for Level 1, the `navigationStart` metric is subtracted from timestamp metrics to obtain relative values. All timestamp values are in milliseconds.

Navigation events contain the following properties.


| Name | Type | Description | Notes | 
| --- | --- | --- | --- | 
|  **initiatorType** |  String  |  Represents the type of resource that initiated the performance event.  |  **Value:** "navigation" **Level 1:** "navigation" **Level 2:** entryData.initiatorType | 
|  **navigationType** |  String  |  Represents the type of navigation. This attribute is not required. |  **Value:** The value must be one of the following: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM-datacollected.html) | 
|  **startTime** |  Number  |  Indicates when the event is triggered.  |  **Value:** 0 **Level 1:** entryData.navigationStart - entryData.navigationStart  **Level 2:** entryData.startTime | 
|  **unloadEventStart** |  Number  |  Indicates the time when the previous document in the window began to unload after the `unload` event was thrown.  |  **Value:** If there is no previous document or if the previous document or one of the needed redirects is not of the same origin, the value returned is 0. **Level 1:** <pre>entryData.unloadEventStart > 0<br />  ? entryData.unloadEventStart - entryData.navigationStart<br />  : 0<br /></pre> **Level 2:** entryData.unloadEventStart | 
|  **promptForUnload** |  Number  |  The time taken to unload the document. In other words, the time between `unloadEventStart` and `unloadEventEnd`. `UnloadEventEnd` represents the moment in milliseconds when the unload event handler finishes.  |  **Value:** If there is no previous document or if the previous document or one of the needed redirects is not of the same origin, the value returned is 0. **Level 1:** entryData.unloadEventEnd - entryData.unloadEventStart **Level 2:** entryData.unloadEventEnd - entryData.unloadEventStart | 
|  **redirectCount** |  Number  |  A number representing the number of redirects since the last non-redirect navigation under the current browsing context.  This attribute is not required. |  **Value:** If there is no redirect or if there is any redirect that is not of the same origin as the destination document, the value returned is 0. **Level 1:** Not available **Level 2:** entryData.redirectCount | 
|  **redirectStart** |  Number  |  The time when the first HTTP redirect starts.   |  **Value:** If there is no redirect or if there is any redirect that is not of the same origin as the destination document, the value returned is 0. **Level 1:** <pre>entryData.redirectStart > 0<br />  ? entryData.redirectStart - entryData.navigationStart<br />  : 0</pre> **Level 2:** entryData.redirectStart | 
|  **redirectTime** |  Number  |  The time taken for the HTTP redirect. This is the difference between `redirectStart` and `redirectEnd`.   |  **Level 1:** : entryData.redirectEnd - entryData.redirectStart **Level 2:** : entryData.redirectEnd - entryData.redirectStart | 
|  **workerStart** |  Number  |  This is a property of the `PerformanceResourceTiming` interface. It marks the beginning of worker thread operation. This attribute is not required. |  **Value:** If a Service Worker thread is already running, or immediately before starting the Service Worker thread, this property returns the time immediately before dispatching `FetchEvent`. It returns 0 if the resource is not intercepted by a Service Worker. **Level 1:** Not available **Level 2:** entryData.workerStart | 
|  **workerTime** |  Number  |  If the resource is intercepted by a Service Worker, this returns the time required for worker thread operation. This attribute is not required. |  **Level 1:** Not available  **Level 2:** <pre>entryData.workerStart > 0<br />   ? entryData.fetchStart - entryData.workerStart<br />   : 0</pre>  | 
|  **fetchStart** |  Number  |  The time when the browser is ready to fetch the document using an HTTP request. This is before checking any application cache. |  **Level 1:**  <pre>: entryData.fetchStart > 0<br />  ? entryData.fetchStart - entryData.navigationStart<br />  : 0</pre> **Level 2:** entryData.fetchStart | 
|  **domainLookupStart** |  Number  |  The time when the domain lookup starts. |  **Value:** If a persistent connection is used or if the information is stored in a cache or local resource, the value will be the same as `fetchStart`. **Level 1:** <pre>entryData.domainLookupStart > 0<br />  ? entryData.domainLookupStart - entryData.navigationStart<br />  : 0</pre> **Level 2:** entryData.domainLookupStart | 
|  **dns** |  Number  |  The time required for domain lookup. |  **Value:** If the resources and DNS records are cached, the expected value is 0. **Level 1:** entryData.domainLookupEnd - entryData.domainLookupStart **Level 2:** entryData.domainLookupEnd - entryData.domainLookupStart | 
|  **nextHopProtocol** |  String  |  A string representing the network protocol used to fetch the resource. This attribute is not required. |  **Level 1:** Not available **Level 2:** entryData.nextHopProtocol | 
|  **connectStart** |  Number  |  The time immediately before the user agent starts establishing the connection to the server to retrieve the document. |  **Value:** If an RFC2616 persistent connection is used, or if the current document is retrieved from relevant application caches or local resources, this attribute returns the value of `domainLookupEnd`. **Level 1:** <pre>entryData.connectStart > 0<br />  ? entryData.connectStart - entryData.navigationStart<br />  : 0</pre> **Level 2:** entryData.connectStart  | 
|  **connect** |  Number  |  Measures the time required to establish the transport connections or to perform SSL authentication. It also includes the blocked time that is taken when there are too many concurrent requests issued by the browser.  |  **Level 1:** entryData.connectEnd - entryData.connectStart **Level 2:** entryData.connectEnd - entryData.connectStart | 
|  **secureConnectionStart** |  Number  |  If the URL scheme of the current page is "https", this attribute returns the time immediately before the user agent starts the handshake process to secure the current connection. It returns 0 if HTTPS is not used. For more information about URL schemes, see [URL representation](https://url.spec.whatwg.org/#concept-url-scheme).  |  **Formula:** entryData.secureConnectionStart | 
|  **tlsTime** |  Number  |  The time taken to complete an SSL handshake.  |  **Level 1:** <pre>entryData.secureConnectionStart > 0<br />   ? entryData.connectEnd - entryData.secureConnectionStart<br />   : 0</pre> **Level 2:** <pre>entryData.secureConnectionStart > 0<br />   ? entryData.connectEnd - entryData.secureConnectionStart<br />   : 0</pre>  | 
|  **requestStart** |  Number  |  The time immediately before the user agent starts requesting the resource from the server, or from relevant application caches, or from local resources.   | **Level 1:** <pre>: entryData.requestStart > 0<br />  ? entryData.requestStart - entryData.navigationStart<br />  : 0<br /></pre> **Level 2:** entryData.requestStart | 
|  **timeToFirstByte** |  Number  |  The time taken to receive the first byte of information after a request is made. This time is relative to the `startTime`.   | **Level 1:** entryData.responseStart - entryData.requestStart **Level 2:** entryData.responseStart - entryData.requestStart | 
|  **responseStart** |  Number  |  The time immediately after the user agent's HTTP parser receives the first byte of the response from the relevant application caches, or from local resources, or from the server.   | **Level 1:** <pre>entryData.responseStart > 0<br />   ? entryData.responseStart - entryData.navigationStart<br />   : 0</pre> **Level 2:** entryData.responseStart   | 
|  **responseTime** |  String  |  The time taken to receive a complete response in the form of bytes from the relevant application caches, or from local resources, or from the server.   | **Level 1:** <pre>entryData.responseStart > 0<br />  ? entryData.responseEnd - entryData.responseStart<br />  : 0</pre> **Level 2:** <pre>entryData.responseStart > 0<br />  ? entryData.responseEnd - entryData.responseStart<br />  : 0</pre>  | 
|  **domInteractive** |  Number  |  The time when the parser finished its work on the main document, and the HTML DOM is constructed. At this time, its `Document.readyState` changes to "interactive" and the corresponding `readystatechange` event is thrown.  | **Level 1:** <pre>entryData.domInteractive > 0<br />  ? entryData.domInteractive - entryData.navigationStart<br />  : 0</pre> **Level 2:** entryData.domInteractive  | 
|  **domContentLoadedEventStart** |  Number  |  Represents the time value equal to the time immediately before the user agent fires the DOMContentLoaded event at the current document. TheDOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed. At this time, the main HTML document has finished parsing, the browser begins constructing the render tree, and subresources still have to be loaded. This does not wait for style sheets, images, and subframes to finish loading.  | **Level 1:** <pre>entryData.domContentLoadedEventStart > 0<br />  ? entryData.domContentLoadedEventStart - entryData.navigationStart<br />  : 0<br /></pre> **Level 2:** entryData.domContentLoadedEventStart  | 
|  **domContentLoaded** |  Number  |  This start and end time of render tree construction is marked by the `domContentLoadedEventStart` and `domContentLoadedEventEnd`. It lets CloudWatch RUM track execution. This property is the difference between `domContentLoadedStart` and `domContentLoadedEnd`. During this time, DOM and CSSOM are ready. This property waits on script execution, except for asynchronous and dynamically created scripts. If the scripts depend on style sheets, `domContentLoaded` waits on the style sheets, too. It does not wait on images.   The actual values of `domContentLoadedStart` and `domContentLoadedEnd` approximate to `domContentLoaded` in Google Chrome's Network panel. It indicates HTML DOM \$1 CSSOM render tree construction time from the beginning of the page loading process. In the case of navigation metrics, the `domContentLoaded` value represents the difference between start and end values, which is the time required for downloading subresources and render-tree construction only.    | **Level 2:** entryData.domContentLoadedEventEnd - entryData.domContentLoadedEventStart  **Level 2:** entryData.domContentLoadedEventEnd - entryData.domContentLoadedEventStart  | 
|  **domComplete** |  Number  |  The time immediately before the browser sets the current document readiness of the current document to complete. At this point, the loading of subresources, such as images, is complete. This includes the time taken for downloading blocking content such as CSS and synchronous JavaScript. This approximates to `loadTime` in Google Chrome’s Network panel.   | **Level 1:** <pre>entryData.domComplete > 0<br />  ? entryData.domComplete - entryData.navigationStart<br />  : 0<br /></pre> **Level 2:** entryData.domComplete  | 
|  **domProcessingTime** |  Number  |  The total time between the response and the load event start.  | **Level 1:** entryData.loadEventStart - entryData.responseEnd **Level 2:** entryData.loadEventStart - entryData.responseEnd  | 
|  **loadEventStart** |  Number  |  The time immediately before the `load` event of the current document is fired.  |  **Level 1:** <pre>entryData.loadEventStart > 0<br />  ? entryData.loadEventStart - entryData.navigationStart<br />  : 0<br /></pre> **Level 2:** entryData.loadEventStart | 
|  **loadEventTime** |  Number  |  The difference between `loadEventStart` and `loadEventEnd`. Additional functions or logic waiting for this load event will be fired during this time. |  **Level 1:** entryData.loadEventEnd - entryData.loadEventStart **Level 2:** entryData.loadEventEnd - entryData.loadEventStart | 
|  **duration** |  String  |  Duration is the total page load time. It records the timing for downloading the main page and all of its synchronous subresources, and also for rendering the page. Asynchronous resources such as scripts continue to download later. This is the difference between the `loadEventEnd` and `startTime` properties.  | **Level 1:** entryData.loadEventEnd - entryData.navigationStart **Level 2:** entryData.duration | 
|  **headerSize** |  Number  |  Returns the difference between `transferSize` and `encodedBodySize`. This attribute is not required.  | **Level 1:** Not available **Level 2:** entryData.transferSize - entryData.encodedBodySize **Level 2:** entryData.transferSize - entryData.encodedBodySize | 
|  **compressionRatio** |  Number  |  The ratio of `encodedBodySize` and `decodedBodySize`. The value of `encodedBodySize` is the compressed size of the resource excluding the HTTP headers. The value of `decodedBodySize` is the decompressed size of the resource excluding the HTTP headers. This attribute is not required.  | **Level 1:** Not available. **Level 2:**<pre>entryData.encodedBodySize > 0<br />  ? entryData.decodedBodySize / entryData.encodedBodySize<br />  : 0</pre>  | 
|  **navigationTimingLevel** |  Number  |  The navigation timing API version.  | **Value:** 1 or 2  | 

### Resource event schema
<a name="CloudWatch-RUM-datacollected-ResourceEvent"></a>

Resource events are collected only if the app monitor has performance telemetry activated.

Timestamp metrics are based on [The DOMHighResTimeStamp typedef](https://www.w3.org/TR/hr-time-2/#sec-domhighrestimestamp). With Level 2 APIs, by default all timings are relative to the `startTime`. But for Level 1 APIs, the `navigationStart` metric is subtracted from timestamp metrics to obtain relative values. All timestamp values are in milliseconds.

Resource events generated by the agent contain the following properties.


| Name | Type | Description | Notes | 
| --- | --- | --- | --- | 
|  **targetUrl** |  String  |  Returns the resource's URL.  |  **Formula:** [entryData.name](http://entrydata.name/) | 
|  **initiatorType** |  String  |  Represents the type of resource that initiated the performance resource event.  |  **Value:** "resource" **Formula:** entryData.initiatorType | 
|  **duration** |  String  |  Returns the difference between the `responseEnd` and `startTime` properties.This attribute is not required.  | **Formula:** entryData.duration | 
|  **transferSize** |  Number  |  Returns the size (in octets) of the fetched resource, including the response header fields and the response payload body.This attribute is not required.  | **Formula:** entryData.transferSize | 
|  **fileType** |  String  |  Extensions derived from the target URL pattern.  |   | 

### Largest contentful paint event schema
<a name="CloudWatch-RUM-datacollected-LargestPaintEvent"></a>

Largest contentful paint events contain the following properties.

These events are collected only if the app monitor has performance telemetry activated.


| Name | Description | 
| --- | --- | 
|  **Value** |  For more information, see [Web Vitals](https://web.dev/vitals/).  | 

### First input delay event
<a name="CloudWatch-RUM-datacollected-FirstInputDelayEvent"></a>

First input delay events contain the following properties.

These events are collected only if the app monitor has performance telemetry activated.


| Name | Description | 
| --- | --- | 
|  **Value** |  For more information, see [Web Vitals](https://web.dev/vitals/).  | 

### Cumulative layout shift event
<a name="CloudWatch-RUM-datacollected-CumulativeShift"></a>

Cumulative layout shift events contain the following properties.

These events are collected only if the app monitor has performance telemetry activated.


| Name | Description | 
| --- | --- | 
|  **Value** |  For more information, see [Web Vitals](https://web.dev/vitals/).  | 

### HTTP event
<a name="CloudWatch-RUM-datacollected-HTTP"></a>

HTTP events can contain the following properties. It will contain either a `Response` field or an `Error` field, but not both.

These events are collected only if the app monitor has HTTP telemetry activated.


| Name | Description | 
| --- | --- | 
|  **Request** |  The request field includes the following: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM-datacollected.html)  | 
|  **Response** |  The response field includes the following: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM-datacollected.html)  | 
|  **Error** |  The error field includes the following: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM-datacollected.html)  | 

### X-Ray trace event schema
<a name="CloudWatch-RUM-datacollected-xraytraceEvent"></a>

These events are collected only if the app monitor has X-Ray tracing activated.

For information about X-Ray trace event schemas, see [AWS X-Ray segment documents](https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html).

# Route change timing for single-page applications
<a name="CloudWatch-RUM-route-change-timing"></a>

In a traditional multi-page application, when a user requests for new content to be loaded, the user is actually requesting a new HTML page from the server. As a result, the CloudWatch RUM web client captures the load times using the regular performance API metrics.

However, single-page web applications use JavaScript and Ajax to update the interface without loading a new page from the server. Single-page updates are not recorded by the browser timing API, but instead use route change timing.

CloudWatch RUM supports the monitoring of both full page loads from the server and single-page updates, with the following differences:
+ For route change timing, there are no browser-provided metrics such as `tlsTime`, `timeToFirstByte`, and so on.
+ For route change timing, the `initiatorType` field will be `route_change`. 

The CloudWatch RUM web client listens to user interactions that may lead to a route change, and when such a user interaction is recorded, the web client records a timestamp. Then route change timing will begin if both of the following are true:
+ A browser history API (except browser forward and back buttons) was used to perform the route change.
+ The difference between the time of route change detection and latest user interaction timestamp is less than 1000 ms. This avoids data skew.

Then, once route change timing begins, that timing completes if there are no ongoing AJAX requests and DOM mutations. Then the timestamp of the latest completed activity will be used as the completion timestamp.

Route change timing will time out if there are ongoing AJAX requests or DOM mutations for more than 10 seconds (by default). In this case, the CloudWatch RUM web client will no longer record timing for this route change.

As a result, the duration of a route change event is calculated as the following:

```
(time of latest completed activity) - (latest user interaction timestamp)
```