Knowledge Base

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I inject the 4.2.x EUM Javascript Agent with an F5 load balancer?

A load balancer is a device that distributes network or application traffic across a number of servers. Load balancers are used to increase capacity and reliability of applications.

 

When properly configured, F5 iRules utilize a scripting syntax which allows the load balancer to intercept, inspect, transform, and direct inbound or outbound application traffic.

 

In the event the application's source is unable to be modified and all other forms of injection have failed or are not applicable (i.e. assisted injection through Java rules for a PHP-based application), clients with a F5 load balancer can request their network security team configure an iRule to intercept an application's response and inject HTML into the page source necessary for enabling EUM. This is similar to the format that manual injection uses, but HTML is inserted into the webserver's response rather than into the original source code.

 

For instructions on how to build, deploy, and test an iRule, we recommend you consult your F5 support team and network security team as they are most knowledgeable and equipped to handle such a request. From an AppDynanics perspective, you must be properly licensed for EUM and have End User Monitoring (EUM) enabled for an application in your AppDynamics controller UI. Clients who have the limited option of injection via F5 iRules have seen success using a template similar to the iRule listed below.

 

 

Generic F5 iRule Template (requires further customization)

 

when HTTP_REQUEST 
{
# This is the condition for which requests will be matched against
if {[HTTP::uri] contains "segment/in/uri"} {
set enableEum 1
}
else {
set enableEum 0
}
# Disable the stream filter for client requests as we are only interested in the server response
STREAM::disable
# LTM does not uncompress response content, so if the server has compression enabled
# and it cannot be disabled on the server, we can prevent the server from
# sending a compressed response by removing the compression offerings from the client
# HTTP::header remove "Accept-Encoding"
}

when HTTP_RESPONSE
{
# Disable the stream filter for all server responses
STREAM::disable
# Inserts the necessary JavaScript for EUM
if {($enableEum == 1) && ([HTTP::header "Content-Type"] starts_with "text/html")} {
STREAM::expression {
@</title>@</title>
<script>
window["adrum-app-key"] = "AAB-AA-AUA";
window["adrum-start-time"] = new Date().getTime();
</script>
<script type="text/javascript" src="http://cdn.appdynamics.com/adrum/adrum-latest.js"></script>@}
# Enable the stream filter for this response only
STREAM::enable
}
}

 

 

How to use this template

1) Matching Condition - The matching condition in your first "if statement."

Change this segment in the above template to match a specific piece of your application.

 

In the template we use the application's URI, however, there are other properties of the application which can be matched up (i.e [HTTP::path], [HTTP::host], etc.). 

[HTTP::uri] contains "segment/in/uri"

 

2) Compression - Does your application use compression?

 

If it does, uncomment the following line from the template.

HTTP::header remove "Accept-Encoding"

If there isn't any compression, then keep the line commented out.

# HTTP::header remove "Accept-Encoding"

 

3) EUM Application Key - What is your EUM Application Key as assigned in your Controller's UI?

This can be found by accessing your EUM Application Configuration via the controller UI. The key is typically eight letters long.

 

Change the example key (AAB-AA-AUA) in the above template to your specific application key.

 

window["adrum-app-key"] = "AAB-AA-AUA";

 

4) JavaScript Agent Location - Where is the JavaScript agent being hosted?

The file (adrum.js or adrum-latest.js) will either need to be hosted with your application or can be hosted in our content distribution network (CDN).

 

If you intend to host the file yourself, update the address between the <script> tags of the iRule template (which is pointing the script src to the AppDynamics CDN).

http://cdn.appdynamics.com/adrum/adrum-latest.js 

 

5) Other points to consider

In some cases the Stream profile must re-enable response rechunking as documented in https://support.f5.com/csp/article/K6422.

 

Although the above script template is typically successful, every client environment is different. Therefore our team recommends that you consult a trained engineer responsible for managing your F5 load balancer. We also highly recommend testing in a sandbox or development environment before deploying any changes to your production environment. 

 

Results 

If properly configured, the iRule matches a condition for your application-specific traffic, the load balancer will inject the EUM-specific source into the response received by the browser allowing the Javascript agent to load in the browser, capture EUM data, and send the associated beacons back to the EUM Server.

 

<script>
window["adrum-app-key"] = "AAB-AA-AUA";
window["adrum-start-time"] = new Date().getTime();
</script>
<script src="https://cdn.appdynamics.com/adrum/adrum-latest.js"></script>
Version history
Revision #:
15 of 15
Last update:
‎10-05-2018 01:43 PM
Updated by:
 
Labels (1)
0 Kudos
Comments

In some cases https://support.f5.com/csp/article/K6422 applies. We have to enable re-chunking of the responses.