Elastic Real User Monitoring (GET PAST AD-BLOCKERS)

Varun Subramanian
CodeX
Published in
2 min readJul 4, 2023

--

Elastic APM RUM agent monitors the real user experience and interaction within your client-side application. The RUM JavaScript agent is also framework-agnostic, which means it can be used with any front-end JavaScript application.

The Elastic RUM endpoint uses the following URL to POST events to the Integration (APM/Fleet) server.

**http(s)://{hostname}:{port}/intake/v2/rum/events**

Ad-blockers have become a necessity for content filtering — primarily aimed at neutralising privacy invasion and removing or hiding targeted advertising content during browsing.

For example, the U-Origin (https://ublockorigin.com/) blocker has blacklisted the following prefix (rum/events) which will lead to client side events being blocked at the browser level.

Failed RUM Transactions

Proposed Solution:

The proposed solution consists of adding an additional level of abstraction to ensure the flow of network traffic between clients and servers. Nginx, Akamai etc. have the capability to direct client requests to the appropriate backend server using the concept called Reverse Proxy.

Successful RUM transactions using Reverse Proxy

Sample configuration with Nginx:

   location /prefix/of/your/choice {


proxy_pass http(s)://{hostname}:{port}/intake/v2/rum/events;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}

By adding an intermediate reverse proxy server, we gain more control over the endpoint as it provides better security, reliability and load balancing.

Elasticsearch RUM Configuration:

Once the above setup is complete, the following configuration needs to be updated in the RUM agent.

initApm({
// Set required service name (allowed characters: a-z, A-Z, 0-9, -, _, and space)
serviceName: 'service-name',
serverUrl: "<intermediate-client-url>",
serverUrlPrefix: "/prefix/of/your/choice"
})

It is important to set the serverUrlPrefix field to the intermediate layer endpoint prefix; if not the RUM agent will end up taking the default elastic RUM endpoint.

Conclusion:

To conclude, end users can always add/update their ad-blocker privacy list to block requests. The proposed solution will enable teams with a workaround in their attempt to capture important metrics related to their application’s performance.
The approach is not limited to Elasticsearch but also to other Real User Monitoring (RUM) tools in the market.

References:

--

--