Set up agentless Real User Monitoring

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 ((jsTagComplete)) format.

    Dynatrace offers several insertion formats of the RUM JavaScript. If you might want to use another insertion format of the RUM JavaScript, see the next step.

  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 insertion format optional

While the JavaScript tag ((jsTagComplete)) format is the ideal choice for the majority of use cases, Dynatrace offers several insertion 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 RUM JavaScript injection | Manual insertion.

To get a different insertion 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 Setup > Setup.
  5. Go to the Manual insertion tab and select the required insertion format.
  6. Select Copy to copy the JavaScript code, tag, or snippet to the clipboard.

Step 4 Keep RUM JavaScript up-to-date

When you want the RUM JavaScript to be updated automatically, choose the JavaScript tag insertion format. For other insertion 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 Real User Monitoring JavaScript API.

In the Dynatrace web UI, you can also retrieve a URL to download the RUM JavaScript as an HTML tag.

  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 Setup > Setup.
  5. Go to the Retrieve via API tab and select the required format.
  6. Select Copy and use the URL in your build process.

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 insertion formats of the RUM JavaScript, URLs can change depending on the application settings.

The CDN or caching proxy should respect the Expires header. Some insertion formats of the RUM JavaScript can be cached for a long time, while others change more often.

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 insertion option 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.

  • Only OneAgent running within a web server can capture HTTP response codes for requests made. In other words, request error capture requires OneAgent to be injected into a web server. Note that, however, OneAgent is not required for capturing request errors for XmlHttpRequests or fetch() calls.

    As an alternative, you can use one of the methods of the RUM JavaScript API to report HTTP response codes for an agentless application. However, there are certain limitations to this approach, and that's why we recommend installing OneAgent.

    • For arbitrary, standalone requests—sendSessionProperties (but it allows reporting only a single response code for the whole session)
    • For XHR actions—addActionProperties (it allows reporting a response code for one request per action, but you probably want to have response codes for multiple requests)
    • For page loads—markAsErrorPage

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 insertion option.

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 insertion 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.

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.

  • The RUM JavaScript sends beacons to the servers. See How can I confirm that the RUM JavaScript reports data to the server? for details.

  • 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 Troubleshooting RUM for web applications for more information.