Step 2: Create an app monitor - Amazon CloudWatch
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Step 2: Create an app monitor

To start using CloudWatch RUM with your application, you create an app monitor. When the app monitor is created, RUM generates a JavaScript snippet for you to paste into your application. The snippet pulls in the RUM web client code. The RUM web client captures data from a percentage of your application's user sessions and sends it to RUM.

To create an app monitor
  1. Open the CloudWatch console at

  2. In the navigation pane, choose Application monitoring, RUM.

  3. Choose Add app monitor.

  4. Enter the information and settings for your application:

    • For App monitor name, enter a name to be used to identify this app monitor within the CloudWatch RUM console.

    • For Application domain, enter the top-level domain name where your application has administrative authority. This must be in a URL domain format.

      Choose Include sub domains to have the app monitor also collect data from all subdomains under the top-level domain.

  5. For Configure RUM data collection, specify whether you want the app monitor to collect each of the following:

    • Performance telemetry – Collects information about page load and resource load times

    • JavaScript errors – Collects information about unhandled JavaScript errors raised by your application

    • HTTP errors – Collects information about HTTP errors thrown by your application

    Selecting these options provides more information about your application, but also generates more CloudWatch RUM events and thus incurs more charges.

    If you don't select any of these, the app monitor still collects session start events and page IDs so that you can see how many users are using your application, including breakdowns by operating system type and version, browser type and version, device type, and location.

  6. Select Check this option to allow the CloudWatch RUM Web Client to set cookies if you want to be able to collect user IDs and session IDs from sampled user sessions. The user IDs are randomly generated by RUM. For more information, see CloudWatch RUM web client cookies.

  7. For Session samples, enter the percentage of user sessions that will be used to gather RUM data. The default is 100%. Reducing this number gives you less data, but reduces your charges. For more information about RUM pricing, see RUM pricing.

  8. End user data that you collect for CloudWatch RUM is retained for 30 days and then deleted. If you want to keep copies of RUM events in CloudWatch Logs and configure how long to retain these copies, choose Check this option to store your application telemetry data in your CloudWatch Logs account under Data storage. By default, the CloudWatch Logs log group retains the data for 30 days. You can adjust the retention period in the CloudWatch Logs console.

  9. For Authorization, specify whether to use a new or existing Amazon Cognito identity pool or use a different identity provider. Creating a new identity pool is the simplest option that requires no other setup steps. For more information, see Step 1: Authorize your application to send data to Amazon.

    Creating a new Amazon Cognito identity pool requires administrative permissions. For more information, see IAM policies to use CloudWatch RUM.

  10. (Optional) By default, when you add the RUM code snippet to your application, the web client injects the JavaScript tag to monitor usage into the HTML code of all pages of your application. To change this, choose Configure pages and then choose either Include only these pages or Exclude these pages. Then, specify the pages to include or exclude. To specify a page to include or exclude, enter its complete URLs. To specify additional pages, choose Add URL.

  11. To enable Amazon X-Ray tracing of the user sessions that are sampled by the app monitor, choose Active tracing and select Trace my service with Amazon X-Ray.

    If you select this, XMLHttpRequest and fetch requests made during user sessions sampled by the app monitor are traced. You can then see traces and segments from these user sessions in the RUM dashboard, the CloudWatch ServiceLens console, and the X-Ray console.

    By making additional configuration changes to the CloudWatch RUM web client, you can add an X-Ray trace header to HTTP requests to enable end-to-end tracing of user sessions through to downstream Amazon managed services. For more information, see Enabling X-Ray end-to-end tracing.

  12. (Optional) To add tags to the app monitor, choose Tags, Add new tag.

    Then, for Key, enter a name for the tag. You can add an optional value for the tag in Value.

    To add another tag, choose Add new tag again.

    For more information, see Tagging Amazon Resources.

  13. Choose Add app monitor.

  14. In the Sample code section, you can copy the code snippet to use to add to your application. We recommend that you choose JavaScript or TypeScript and use NPM to install the CloudWatch RUM web client as a JavaScript module.

    Alternatively, you can choose HTML to use a content delivery network (CDN) to install the CloudWatch RUM web client. The disadvantage of using a CDN is that the web client is often blocked by ad blockers.

  15. Choose Copy or Download, and then choose Done.