MORTIMERDEV LABS / AWS / CLOUDWATCH RUM FREE · BETA
Set up CloudWatch RUM.
See what real users see.
Choose your domains, sample rate and what to record, and get everything in one place: CDK in TypeScript and Python for the app monitor and its Cognito identity pool, the web client snippet or npm code, the CSP lines it needs, a rough monthly event count, and the pitfalls to avoid.
Set up an app monitor
YOUR APP MONITOR
Check these
1. Deploy with CDK
The app monitor, a Cognito identity pool for guest credentials, and a guest role that can only send events. Deploy, then copy the outputs into the web client.
TypeScript
Python
2. Add the web client
3. Allow it in your Content-Security-Policy
| Directive | Source | Why |
|---|
Merge these into your existing policy, then check it with the CSP Explainer.
4. Alarm on it and set an SLO
Use the alarm builder’s RUM presets for JavaScript errors and LCP, or the SLO builder’s “RUM p75 LCP” example.
See it in AWS
Once it’s deployed and your site has had some visits: where to find the data, how to check events are arriving, and what to do when they aren’t.
In the console
From the CLI
Uses the names you entered above. Run with credentials for the right account and region.
What is CloudWatch RUM?
CloudWatch RUM (real user monitoring) records what
visitors actually experience: how fast pages load on their devices, the
JavaScript errors they hit and the requests that fail. A small script on
your pages, the web client, sends events to an
app monitor in your AWS account, which turns them into
dashboards and AWS/RUM metrics you can alarm on.
- In the browser
- Records errors, performance and requests
- Guest credentials
- Lets the browser sign what it sends
- In your account
- Receives and stores events for 30 days
- To act on
- Alarms, dashboards and SLOs
Where you’ll use it
- Core Web Vitals from real visitors, not just a lab test.
- Front-end errors with stack traces, by page and browser.
- End-to-end traces from a click to your back end with X-Ray.
Easy to confuse
- The CDN is always us-east-1: the client loads from there, but events go to your app monitor’s region.
- Guest credentials are public: anyone can get them, so the guest role should only send events.
- Sampling is per session: 10% means one session in ten, each recorded in full.
Read more: AWS: CloudWatch RUMCloudFormation: AWS::RUM::AppMonitorWeb client configurationCDK: rum.CfnAppMonitor
TEST YOURSELF
How well do you know CloudWatch RUM?
Ten questions on app monitors, telemetries, Cognito, CSP, cookies and cost, with an explanation and a link to the reference after each one. Three are worked out by the helper.
CLOUDWATCH RUM REFERENCE
CloudWatch RUM, in plain English.
Basics
Real user monitoringMeasures what real visitors experience in their browsers: load times, errors and failed requests.
Synthetic tests check a page from a few locations; RUM records actual sessions on real devices and networks, so it catches the slow phone on hotel Wi-Fi and the error that only happens in one browser.
App monitorThe CloudWatch RUM resource for one application: its domains, sample rate, telemetries and authorisation.
In CDK it’s rum.CfnAppMonitor. It needs a name and a domain (or up to 5 in domainList). Its ID, from attrId, goes into the web client.
TelemetriesWhat to record: errors (JavaScript errors), performance (page loads and Web Vitals) and http (failed requests).
By default the http telemetry records only failed requests. recordAllRequests records every one, which adds events and cost.
Session sample rateThe share of sessions recorded, from 0 to 1. If you leave the app monitor configuration out, it’s 0.1.
Sampling is per session, so a recorded session is recorded in full. 0.1–0.25 is plenty for trends on a busy site; small sites can record everything.
Setup
Web clientThe open-source aws-rum-web script that runs on your pages, either from AWS’s CDN as a snippet or bundled from npm.
The CDN snippet queues commands until cwr.js loads. Pin an exact version (3.0.0) for change control, or a major version (3.x) to get fixes automatically. The npm package suits single-page apps and avoids a third-party script host.
Cognito identity poolGives each browser a guest identity and short-lived credentials, so it can sign the events it sends to RUM.
The pool must allow unauthenticated identities and be in the same region as the app monitor. Its guest role allows only rum:PutRumEvents on the app monitor (and xray:PutTraceSegments if X-Ray is on).
Enhanced and classic flowsGive the client only identityPoolId for the enhanced flow (recommended); add guestRoleArn for the classic flow.
The classic flow takes a token from Cognito and swaps it for credentials with STS, so it needs one more host in your CSP.
Resource-based policiesAn alternative to Cognito: a policy on the app monitor that says who can call PutRumEvents.
AWS added this in 2025 for high-volume sites that hit Cognito quotas. A policy can allow everyone, block IP addresses, or require a rum:alias that the web client sends.
Privacy and security
Content-Security-PolicyAllow the client’s hosts: script-src for the CDN, and connect-src for the RUM dataplane and Cognito (plus STS for the classic flow).
The snippet is an inline script, so allow it with a hash or nonce, or move it to a file on your own domain, instead of adding 'unsafe-inline'. Test your policy in the CSP Explainer.
X-Ray tracingenableXRay records client-side traces for requests, so you can follow one from the browser through your back end.
It needs the http telemetry. addXRayTraceIdHeader adds X-Amzn-Trace-Id to requests, which cross-origin APIs must allow in their CORS headers or the requests fail.
Using the data
RUM metricsPublished to AWS/RUM with an application_name dimension: JsErrorCount, Http5xxCount, PageViewCount, WebVitalsLargestContentfulPaint and more.
Alarm on them like any other metric, or use them as an SLO’s indicator: p75 LCP per period, or JavaScript errors per page view.
Retention and logsRUM keeps events for 30 days. cwLogEnabled copies them to CloudWatch Logs to keep them longer, at Logs prices.
Logs Insights can then query events, such as every JavaScript error on one page in one browser.
CostRUM charges per event collected (page views, errors, requests, performance entries). The sample rate is the main lever.
New accounts get a free trial of events. Check the CloudWatch pricing page for your region before raising the sample rate.
Built from AWS’s own docs.
Property names and limits come from the CloudFormation reference and the open-source web client’s configuration docs, both linked above. The event estimate is a rough guide, not a quote.
Nothing leaves this page.
Everything is worked out in your browser and nothing is saved. We count anonymous page views and button use, never what you enter.
Beta feedback helps shape Labs. Tell Andy what would help
Learn Step 3 of 4 in Observability on AWS: set up, watch, act
