Menu
Grafana Cloud

Automatically inject the RUM SDK into your sites

Sometimes you cannot add the RUM SDK snippet to an application. This could be because a different internal team owns the app or because the app is in maintenance mode.

This document highlights a strategy that you can use to inject the snippet, so that you can still use Grafana Faro in these scenarios.

Note

We recommend directly adding the Web SDK to the applications, so they can use the SDK to augment the automatically created telemetry.

Requirements

This approach requires a reverse proxy technology that sits in front of the served application and can modify the response content.

Example (nginx)

An nginx implementation could be as simple as adding a sub_filter directive to the location that is used to reverse-proxy the application.

nginx
location / {
    # example value
    proxy_pass http://app:8080/;

    # we match the closing `head` tag and append a script snippet
    sub_filter '</head>' '</head>
    <!-- replace the next line with the "CDN" snippet from the Configuration page -->
    <script></script>';
    sub_filter_once on;
}

Learn more