Set up agentless Real User Monitoring

  • How-to guide
  • 8-min read

Agentless Real User Monitoring is designed to be used when you don't have access to your web server (and therefore can't install OneAgent), but when you have access to your application code.

The full benefits of Real User Monitoring can be obtained only after you've installed Dynatrace OneAgent. See OneAgent installation is recommended for more details.

Prerequisites

Here's what you'll need to set up agentless Real User Monitoring:

  • Access to your application's HTML source so that you can insert the RUM JavaScript
  • RUM JavaScript—a custom JavaScript tag, code, or snippet generated by Dynatrace
  • A CDN to serve the RUM JavaScript to prevent webpage performance problems during Dynatrace Managed Server maintenance periods or local network outages

Set up agentless monitoring

Perform the following actions to set up agentless monitoring.

Step 1 Configure Cluster ActiveGate URL

  1. Install a Cluster ActiveGate.
  2. Go to Settings > Public endpoints.
  3. Under Cluster ActiveGate URL, enter the URL where your new ActiveGate can be reached. The URL must be publicly accessible and able to accept HTTPS requests.

This URL is used to send the Real User Monitoring data to your Dynatrace Managed Cluster.

By default, a Cluster ActiveGate listens on port 9999. If this isn't desired, changing the port in the ActiveGate configuration is possible. Alternatively, you can use the port of your choice and then redirect the traffic to port 9999 using firewall settings.

Step 2 Create an application and insert RUM JavaScript

  1. In Dynatrace Hub, select Web application monitoring via manual insertion.

  2. Select Set up.

  3. Enter your application name and select Add web application. A custom JavaScript code snippet is generated for your application.

  4. Select Copy code snippet to copy the generated JavaScript code to the clipboard. The code generated after you've created the application is in the JavaScript tag format.

    Dynatrace offers several snippet formats of the RUM JavaScript. If you’re considering using a different snippet format, refer to the next step for guidance.

  5. Paste the JavaScript code snippet into the <head> element of all of HTML pages that you want to monitor in your application. Ensure that the RUM JavaScript is the first executable script on each page.

    For many websites, it's possible to add custom JavaScript to all pages at once by inserting the code to be reused into a centralized header.html file. If possible, use this file to insert the RUM JavaScript to avoid unnecessary work.

The following example shows the code for a simple page before and after RUM JavaScript insertion.

<html>
<head>
<title>MyApp</title>
<script type="text/javascript" src="myapp.js"></script>
</head>
<body>
<form>
Username: <input type="text name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<input type="submit" value="Login">
</form>

If you already have an application that's set up for agentless monitoring, select Applications currently set up for agentless monitoring in step 3 of the instructions above instead of entering your application name. You can then view the list of applications already set up for agentless monitoring and their corresponding JavaScript tags, codes, or snippets. This is useful when you've already added the RUM JavaScript to some of your pages and want to extend monitoring visibility to other pages.

Step 3 optional Choose another RUM JavaScript snippet format optional

While the JavaScript tag format is the ideal choice for the majority of use cases, Dynatrace offers several snippet formats of the RUM JavaScript to meet a variety of requirements. Select the format that fits your application best and meets your requirements. For detailed descriptions of all formats, see Select a snippet format.

To get a different snippet format of the RUM JavaScript

  1. Go to Web.
  2. Select the application that you want to configure.
  3. In the upper-right corner of the application overview page, select More () > Edit.
  4. From the application settings, select Injection > Manual insertion.
  5. Choose the required snippet format, then select Copy to copy it to the clipboard.

Step 4 Keep RUM JavaScript up-to-date

If you want the RUM JavaScript to be updated automatically, choose the JavaScript tag snippet format. For other snippet formats, you need to manually update the RUM JavaScript.

Dynatrace offers a REST API that allows you to retrieve the latest RUM JavaScript for your application. You can automatically inject the latest RUM JavaScript during the build time of your application. To learn how to use the API, see RUM manual insertion tags API.

Step 5 Make your cluster production ready

Load balance multiple ActiveGates

For production monitoring with higher load and strict failover requirements, use multiple load-balanced Cluster ActiveGates and add a caching proxy or CDN to serve the RUM JavaScript.

If you take this approach, provide your load balancer URL and the CDN URL in the settings.

  1. Go to Settings > Public endpoints.
  2. Under Cluster ActiveGate URL, enter your load balancer URL.
  3. Under CDN for JavaScript tag, enter your CDN URL.

Requests that your load balancer forwards to Cluster ActiveGates appear as follows.

GET and POST requests for transmitting session information to Dynatrace Managed:

<http|https>://<ClusterActiveGateHostname>/bf/<EnvironmentID>?<internalQueryParameters>

GET requests for the RUM JavaScript:

http[s]://<ClusterActiveGateHostname>/jstag/<ManagedClusterID>/<EnvironmentID>/<InternalApplicationID>/bs.js
http[s]://<ClusterActiveGateHostname>/jstag/<ManagedClusterID>/ruxitagent<configInfo>_<version>.js

Be sure to configure your load balancer to set the X-Forwarded-For header for all forwarded requests. This header contains the IP address of the original request. Dynatrace needs this information to determine where the request originated.

Your load balancer should terminate SSL, as this is very expensive on Cluster ActiveGate. For better performance and if security constraints allow it, traffic can be forwarded via plain HTTP from a load balancer to Cluster ActiveGate.

Cache the RUM JavaScript

To support higher load scenarios when using a load balancer, we recommend that you cache the RUM JavaScript that is loaded from the Cluster ActiveGate using a caching proxy or a CDN.

The CDN or caching proxy should forward all requests to <cdnurl>/jstag/ to http[s]://<ActiveGateHostname>/jstag/ to be prepared for configuration changes and updates. As there're multiple snippet formats of the RUM JavaScript, URLs can change depending on the application settings.

The CDN or caching proxy must respect the caching policy defined by the response headers, which varies for different snippet formats. In particular, responses have a Cache-Control header, which may specify directives such as max-age, s-maxage, public and immutable. Additionally, an Expires header is included as a fallback.

Serve the RUM JavaScript via CDN

When the RUM JavaScript is served from your CDN, the GET requests for the RUM JavaScript are directed to your CDN.

To serve the RUM JavaScript from your CDN

  1. Go to Settings > Public endpoints.
  2. Under CDN for JavaScript tag, enter the root path of your CDN.

Things to consider

OneAgent installation is recommended

Installation of Dynatrace OneAgent is preferable to agentless monitoring for the following reasons:

  • With agentless monitoring, you need to manually insert the RUM JavaScript into each of your application's pages, which might be challenging. Dynatrace OneAgent handles the insertion of the RUM JavaScript for you.
  • Unless you use the JavaScript tag snippet format for agentless monitoring, the RUM JavaScript embedded into your application's pages is not automatically updated when you change your application monitoring settings. You'll have to update the code manually.

For a list of technologies and servers that support automatic RUM JavaScript injection, see Technology support - Real User Monitoring - Web servers and applications.

For some technologies, automatic RUM JavaScript injection is not supported even when you can install OneAgent. For example, while OneAgent can monitor the server side of a Heroku application, it can't inject the RUM JavaScript into the application's pages. If that's the case, manually add the RUM JavaScript to your application's pages.

Performance impact

To minimize the impact of the RUM JavaScript on the page load time, you might want to load scripts as late as possible. Use blocking script tags to ensure that the RUM JavaScript is executed exactly where you've placed it. If you need a script to run as early as possible, the execution can't be postponed.

One way to avoid these additional blocking requests during page load is to inline the script code. The script code needs to be inlined into each document, thereby propagating the data of a single cached file into every page of your application. By combining both these approaches, you can get an inline JavaScript snippet that performs the required initialization and defers the loading of the bulky code to a second script.

Maintenance effort

Agentless monitoring requires you to insert the RUM JavaScript by yourself, so make sure that it requires as little manual effort as possible. If you don't want to have to change your code every time your application monitoring settings change or when a new version of the RUM JavaScript is released, opt for the JavaScript tag snippet format.

Standards and security policies

Certain development standards that are created to make applications more secure and faster also introduce new limitations.

For example, the Content Security Policy (CSP) standard, which was introduced to minimize the chance of becoming a victim of cross-site scripting, disallows inline JavaScript code. This means that you might need to use the JavaScript tag snippet format of the RUM JavaScript.

User action to distributed trace correlation

For agentless monitoring, the ability to link user actions and distributed traces depends on the technologies that your application uses.

Use of tag managers

We recommend ensuring that the RUM JavaScript is the first executable script on each page, which can be challenging when using a tag manager. If you cannot guarantee this, you may lose information—such as certain timings or user actions—that are available only when both the RUM monitoring code and the configuration are fully loaded and initialized.

This risk is exacerbated if you use the code snippet in deferred mode, or if you configure the Script execution option of the JavaScript tag, OneAgent JavaScript tag, or OneAgent JavaScript tag with SRI to async or defer.

Verify agentless monitoring setup

To investigate problems that you might encounter with agentless Real User Monitoring, confirm the following:

  • The pages to be monitored contain the RUM JavaScript.

  • The RUM JavaScript is correctly downloaded by the browser (assuming you're not using inline injection).

    Use the browser developer tools to check if the response for the RUM JavaScript is 200 and if the response body contains the RUM JavaScript.

  • You're retrieving and inserting the RUM JavaScript only after fully configuring the public endpoint, such as a load balancer. This ensures that the public endpoint is correctly set in the RUM JavaScript.
  • The response of the beacon endpoint starts with OK(BF).
  • The application in the Dynatrace web UI shows data.

Also see Web applications: Issues with RUM JavaScript for more information.

Related tags
Digital Experience