DEV Community

Cover image for Dynatrace RUM: setting up Real User Monitoring and reading Core Web Vitals
Span Observer
Span Observer

Posted on Originally published at span.observer

Dynatrace RUM: setting up Real User Monitoring and reading Core Web Vitals

Server dashboards are green, service response times look fine, and yet support keeps hearing « the site is slow ». The server sees only part of the journey. Dynatrace RUM (Real User Monitoring) measures what happens in each user’s browser: loading, rendering, interactions, JavaScript errors.

For an SRE, it is the only source that tells you whether the SLO holds from the user’s point of view. Core Web Vitals (LCP, CLS, INP) give a shared language with frontend and product teams: three numbers, public thresholds, and a 75th percentile reading that stops you steering on a misleading average.

The goal of this tutorial: enable RUM on a web application, check that data arrives, then read Core Web Vitals with DQL. The setup applies to Dynatrace SaaS and Dynatrace Managed; the DQL queries on user.events concern the new RUM experience on Grail, available on SaaS.

What Core Web Vitals measure

Indicator What it measures Field in user.events
LCP (Largest Contentful Paint) When the largest visible element is displayed web_vitals.largest_contentful_paint
CLS (Cumulative Layout Shift) Visual stability: does the page « jump » while loading? web_vitals.cumulative_layout_shift
INP (Interaction to Next Paint) Responsiveness: delay between a click and the screen update web_vitals.interaction_to_next_paint

The « good / needs improvement / poor » thresholds are published by Google’s web.dev project; they change, so refer to the official page rather than a copied figure.

Prerequisites

  • A Dynatrace SaaS or Managed environment, with permission to configure web applications.
  • Either OneAgent installed on the web or application servers that serve the HTML pages (automatic injection), or access to the application’s code or HTML template (manual insertion).
  • For the DQL queries: the new RUM experience enabled on a SaaS environment, and access to Notebooks.
  • Your DPO’s agreement on what is collected: IP address, user identification, Session Replay.

Configuring Dynatrace RUM step by step

Step 1: choose the injection mode

Two paths lead to the same monitoring JavaScript:

  • Automatic injection: OneAgent, running on the web server, inserts the tag into every HTML page served. Nothing to change in the code; this is the fastest path.
  • Manual insertion: you add the tag to the HTML template. Essential when the server is not instrumented: CDN, static hosting, third-party SaaS, single-page app served from a bucket.

Step 2: define the web application

Create the web application in the Dynatrace settings and define the detection rules (domain or URL pattern) that attach traffic to it. One application per user-facing product is a sound split; avoid lumping everything into the default application, or the intranet’s Core Web Vitals will mix with the public site’s.

Step 3: fetch the tag for manual insertion

If you chose manual insertion, fetch the latest tag through the API (SaaS; on Managed, the URL follows the format https://<your-domain>/e/<env-id>):

curl -s "$DT_URL/api/v2/rum/javaScriptTag/APPLICATION-0123456789ABCDEF?scriptExecutionAttribute=ASYNC" \
  -H "Authorization: Api-Token $DT_API_TOKEN"
Enter fullscreen mode Exit fullscreen mode

The response is a <script ...> text to place as high as possible in the <head>. The scriptExecutionAttribute parameter accepts ASYNC, DEFER or NONE. Automate this call in your build: the tag references a configuration file that changes with the application settings. For the exact token scope, see the endpoint page in the documentation.

Step 4: adapt the Content Security Policy

A strict CSP silently blocks the script or the data upload. In the simplest case (automatic injection, default beacon endpoint, Session Replay disabled), the basic rule is enough:

Content-Security-Policy: script-src 'self'; connect-src 'self';
Enter fullscreen mode Exit fullscreen mode

If the script loads from a CDN or beacons go to another domain, add those origins to script-src and connect-src. Test in pre-production with the browser console open: a CSP violation shows up there immediately.

Step 5: set privacy options

Enable IP address masking, honour the « Do Not Track » signal if your policy requires it, and identify users only with a pseudonymous ID. If you enable Session Replay, pick a masking level that hides input fields (see Session Replay on Grail).

How to check that it works

Open the page in a browser, then the Network tab of the developer tools: you should see the Dynatrace script load, then beacon requests after a few interactions. On the Dynatrace side, the first sessions show up within minutes.

On SaaS, with the new RUM experience, read LCP at the 75th percentile per page in a Notebook:

fetch user.events
| filter characteristics.has_page_summary
| filter isNotNull(web_vitals.largest_contentful_paint)
| summarize page_LCP = percentile(web_vitals.largest_contentful_paint, 75), by:{ page.name }
| sort page_LCP desc
Enter fullscreen mode Exit fullscreen mode

Then all three indicators together, per application:

fetch user.events, from:now()-24h
| filter characteristics.has_page_summary
| summarize {
    lcp_p75 = percentile(web_vitals.largest_contentful_paint, 75),
    cls_p75 = percentile(web_vitals.cumulative_layout_shift, 75),
    inp_p75 = percentile(web_vitals.interaction_to_next_paint, 75),
    pages = count()
  }, by:{ frontend.name }
Enter fullscreen mode Exit fullscreen mode

An empty INP column is not necessarily an error: the indicator only exists if the user interacted with the page. On Managed (classic RUM), Core Web Vitals are read in the web application and user action analysis.

Best practices

  • Steer on the 75th percentile, never the average: an average hides slow mobile users.
  • Split by page and device: an LCP regression often hits a single template.
  • Turn an indicator into an SLO: for example « 90% of checkout pages with a good LCP » over 28 days, with burn rate alerts rather than a fixed threshold.
  • Link frontend to backend: a slow action can be followed down to the spans of the service it calls (see end-to-end OpenTelemetry).
  • Add synthetic tests for hours with no traffic, when RUM has nothing to measure.

Frequently asked questions

Does RUM slow pages down?

The script loads asynchronously and sends its data in batches. Its cost is low, but measure it: compare LCP before and after enabling it on a test page, in pre-production.

Why is no data arriving when the tag is present?

The three most common causes: a CSP blocking the script or the beacons, a detection rule attaching traffic to another application, or an ad blocker on the test machine. Check the Network tab, then the console.

Should Session Replay be enabled at the same time?

No, it is a separate decision. Start with RUM alone, validate privacy with your DPO, then enable Session Replay on a small percentage of sessions.

Conclusion

Dynatrace RUM takes about an hour to set up: automatic injection or a manual tag, an adapted CSP, clear privacy rules. The real work starts afterwards: reading LCP, CLS and INP at the 75th percentile, page by page, and turning them into SLOs that finally reflect what users experience.

span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of its owner. Field, screen and setting names change over time: check them in the official documentation for your version.


Originally published on span.observer. French version: https://span.observer/fr/rum-dynatrace-core-web-vitals/.

Top comments (0)