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.
Here's what you'll need to set up agentless Real User Monitoring:
Perform the following actions to set up agentless monitoring.
Create an application and insert RUM JavaScript
Choose another RUM JavaScript insertion format
Keep RUM JavaScript up-to-date
In Dynatrace Hub, select Web application monitoring via manual insertion.
Select Set up.
Enter your application name and select Add web application. A custom JavaScript code snippet is generated for your application.
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 Code snippet synchronous ((syncCS)
) 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.
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.
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.
Dynatrace offers several insertion formats of the RUM JavaScript. 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
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.
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.
sendSessionProperties
(but it allows reporting only a single response code for the whole session)addActionProperties
(it allows reporting a response code for one request per action, but you probably want to have response codes for multiple requests)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.
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.
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.
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.
For agentless monitoring, the ability to link user actions and distributed traces depends on the technologies that your application uses.
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.