CloudWatch RUM for all insights
Tags: aws, monitoring, javascript, cloudwatch
Published: 2022-01-16 12:03:15

[CloudWatch RUM](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM.html) was recently launched during re:Invent 2021 which provides insights to your web-application about certain metrics based on user-actions and errors for debugging.
You can read about the [announcement](https://aws.amazon.com/about-aws/whats-new/2021/11/amazon-cloudwatch-rum-applications-client-side-performance/).
{%twitter 1465384891869138946 %}

### Key takeways from the blog 
+ [Understanding CloudWatch RUM ](#understanding-rum)
+ [Setting-up RUM](#setting-up-rum)
+ [Different telemetry data](#data)

### Understanding CloudWatch RUM <a name="understanding-rum"></a>
**CloudWatch Real-User Monitoring (RUM)** is a monitoring functionality facilitated by CloudWatch which has always been the monitoring tool on AWS. RUM enables developers and DevOps engineers to understand the issues/errors encountered on the web-app and also insights such as which *device* or *browser* or *location* had the error. Additionally, there is performance insights and the time taken for a file to load on the client side along with the geographically information. 
As [Jeff Barr](https://twitter.com/jeffbarr) quotes it, it's that simple to implement on the client side.
> You simply register your application, add a snippet of JavaScript to the header of each page, and deploy.

The **CloudWatch RUM** consolidated and provides dashboard which gives you a detailed insights such as - *page load speed*, *geographic info*, *devices*, *browsers*, *average load during the time*, *user journey*. All this with just a snippet of JS to page.

### Setting-up RUM <a name="setting-up-rum"></a>
**CloudWatch Real-User Monitoring (RUM)** setup can be summarized with the 3 steps - 
+ [Add app monitor](#add-app)
+ [Adding the JS snippet to your web app](#snippet)
+ [Monitor the web-app from CloudWatch console](#monitoring)
![Setting-up RUM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lql0okoyaqdf86l7bvc8.png)

#### Add app monitor <a name="add-app"></a>
While adding a new app monitor, you would have to specify details such as - *app monitor name*, *app domain* and an option to include the sub-domains of the *app domain*. 
You can choose what all data is been collected and stored as telemetry data for the dashboards.
![Configs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oon6wubl4x5t70o9qoqu.png)
The telemetry data is stored only for *30 days*, so if you would wish to store the logs, you can create a CloudWatch log event which captures and stores all these datas.
![Data storage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dh7h9f43fng40mpiy8aa.png)
CloudWatch RUM needs authorization to access AWS resources, for which Amazon Cognito Identity Pools are used.
![Authorization](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5njjdh4waldl06jxn6pj.png)
The telemetry data of the web-pages can also be fine grained to the choice of *all pages*, *specific pages only* or *exclude certain pages*.
![Configure pages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ga51iqhbfl9utkez5ba.png)

#### Adding the JS snippet to your web app <a name="snippet"></a>
Once you save the configurations and add the app monitor, you would be presented with a JavaScript snippet. 
![JS snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s05rdacka8aka413x1sv.png)
As simple as it is, this just needs to be added to the `<head>` of your web-page which is sending telemetry data using the `<script>` tag. 
 
#### Monitor the web-app from CloudWatch console <a name="monitoring"></a>
Once set-up and moved your web-page to the server, you can navigate to your CloudWatch console to view the dashboard. 
![Overview dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1ugnlipbnfe0pjqlayl.png)

### Different telemetry data <a name="data"></a>
From your CloudWatch console, you can view different types of insights. The previous section shows the overview of your app monitor.

Page load speed data for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Page load speed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3v9jgnej3m3uzy7tg8f.png)
Different web vitals for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Different web vitals](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rcd8xted81f9krtcrn4l.png)
Different web browsers used for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Different web browsers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykmjrrnaj651j5qhcolg.png)
Different devices used for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Different devices](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hf0ik17vhdpzxeodi2s.png)
Different locations with page load time for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Different locations with page load time](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ehh8rd83xdm1tsrax91.png)
<!--![all positive](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpamnpq82klcizb5q864.png)-->
Different locations with sessions for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Different locations with sessions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/prhlfazix06zmnyx7stg.png)
You can view the details at a country filter of sessions for 1 month (Dec 17th 2021 - Jan 16th 2022)
![Country filter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b14ay7wgb7e06idwzkud.png)
For multiple pages, you can even get the user-journey.
![User-journey](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ly2lw177be3ot8fdmf22.png)
For the sessions with errors, you can view what the error was and also the data time of occurrence along with device details. 
![Error session](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9kwdetpfoh59m0u33m63.png) 
![Error sessions details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/le9t1kezqyamnw8z7p7n.png)

### Pricing
The free trial has 1 million RUM events which is across the account. And this is only for the first time when RUM is used. Post which, $1 per 100k RUM events.
You can view the detailed [pricing details](https://aws.amazon.com/cloudwatch/pricing/).

### Wrap-up
**CloudWatch RUM** has provided a simplistic approach to web-app insights. The above sample logs and telemetry data are of my personal landing page https://zachjonesnoel.com which has been up and running from Dec 01 2021 and this dashboard has facilitated me to understand what and how is the performance.
Jeff Barr writes about the [New – Real-User Monitoring for Amazon CloudWatch](https://aws.amazon.com/blogs/aws/cloudwatch-rum/).