Tech Tips on DevCentral
   
You are here: Tutorials > Tech Tips

Current Articles | Categories | Search | Syndication

Automated Gomez Performance Monitoring Part 3 - Page Identification

by Joe - 2358 views Article Rating

gomez_solutions In the first article in this series “Automated Gomez Performance Monitoring”, I illustrated how to create an iRule that would automatically inject the required JavaScript code into your web pages to integrate your application with the Gomez Performance monitoring system.

In part two titled “Automated Gomez Performance Monitoring Part 2 – DataCenter Identification”, I expanded on the first article by allowing you to add DataCenter specific identifiers into the Gomez script, thus enabling you to build reports for your applications running from specific geographic locations.

For this third article, I’m going show how to build a lookup table in your iRule that will allow you to give user friendly names to different application pages.

On a site like DevCentral that uses URI formats to optimize Search Engine Optimization (SEO) rankings, there can be a lot of URLs generated.  Take, for instance, our tech tip page that this article is hosted on.  It it really just a single application presenting tech tips but the tech tip identifier is presented as part of the URI (ie. …/ArticleView/articleId/1234/default.aspx).  For a reporting system like Gomez, each page looks like a separate page.  This doesn’t scale well when your report contains 10’s of 1000’s of URLs.  In the site for DevCentral, we decided it would be better to report on Tech Tips as a whole and treat them as a single “page”. 

The Page Identifier

Like the Group Id parameter defined in the last article, there is a Page Identifier (pgId) parameter allowed in the Gomez client code.  By default, if this value is omitted, the reporting system goes by the URI of the page.  But, you can put whatever you want in and that will override the URI as the key and use the supplied value. 

For iRules, this turns out to be quite simple.  The first step is to build a lookup table.  I did this by using the TCL list command to create a basic list.

   1: set GOMEZ_PAGEID_LIST [list \
   2:   "eq / HomePage" \
   3:   "eq /default.aspx HomePage" \
   4:   "starts_with /app1/page1 App1_SubPage1" \
   5:   "starts_with /app1/page2 App1_SubPage2" \
   6:   "starts_with /app1/page3 App1_SubPage3" \
   7:   "starts_with /app2/page1 App2_SubPage1" \
   8:   "contains /forum/tech Forums_Tech" \
   9:   "contains /forum/finance Forums_Finance" \
  10:   "contains /forum/ Forums_Unknown" \
  11:   "ends_with default.aspx Unknown" \
  12: ];

In this list are three tokens.  The first is the comparison operator to use with the URI.  The second is the comparison string itself, and the last is the page identifier.  In the HTTP_REQUEST event, I create a lower case version of the URI and then iterate through the list and perform the requested comparisons (eq, starts_with, ends_with, contains, etc) on the values and, if a match is found, use the associated page id in the resulting injected script.

   1: when HTTP_REQUEST {
   2:   set gws_luri [string tolower [HTTP::uri]];
   3:   # ---------------------------------------------------------------------
   4:   # Loop through the page id list and look for a match.
   5:   # ---------------------------------------------------------------------
   6:   foreach {mapping} $::GOMEZ_PAGEID_LIST {
   7:   
   8:     if { $::GOMEZ_DEBUG > 2 } { log local0. "Testing mapping ${mapping};" };
   9:  
  10:     set gws_tokens [split $mapping " "];
  11:     set gws_op [lindex $gws_tokens 0];
  12:     set gws_match [lindex $gws_tokens 1];
  13:     set gws_pageid [lindex $gws_tokens 2];
  14:     set gws_found_match 0;
  15:   
  16:     # -------------------------------------------------------------------
  17:     # attempt to process the comparison.  Catch any exceptions and treat
  18:     # them like a false match.
  19:     # -------------------------------------------------------------------
  20:     set error [catch { set gws_found_match [expr \$gws_luri $gws_op \$gws_match]; }];
  21:   
  22:     if { $gws_found_match } {
  23:     
  24:       if { $::GOMEZ_DEBUG > 0 } { log local0. "Found match with ${gws_match} for uri ${gws_luri};" };
  25:       set gomez_page_id $gws_pageid;
  26:       break;
  27:     }
  28:   }
  29: }
  30:  
  31: when HTTP_RESPONSE {
  32:   # -------------------------------------------------------------------------
  33:   # Only process stream replacement if a valid page (uri) was requested and the content type is html.
  34:   # -------------------------------------------------------------------------
  35:   if { [info exists gomez_page_id] && ([HTTP::header value "Content-Type"] contains "text/html") } {
  36:    
  37:     set gomez_client [subst {<SCRIPT LANGUAGE="JavaScript"><!--
  38:       var gomez={gs: new Date().getTime(), acctId:'$::GOMEZ_APP_ID', pgId:'$gomez_page_id', grpId:''};
  39:       //--></SCRIPT> 
  40:       <script src="/js/axfTag.js" type="text/javascript"></script>
  41:     } ];
  42:   }
  43: }

The magic here is in the fact that with TCL you can evaluate expressions dynamically.  In the comparison loop, I’m executing the TCL “expr” statement to evaluate at runtime the comparison defined in the list entry.  Cool huh!

In the HTTP_RESPONSE event, the pgId value is inserted from the $gomez_page_id variable and is passed to the Stream filter with the STREAM::expression

   1: STREAM::expression "@</head>@$gomez_client</head>@@<body>@$gomez_client<body>@";

I’ve included two expressions in the case that the “</head>” element doesn’t exist on the page.  After the first match, we cancel all further matches in the STREAM_MATCHED event.

   1: when STREAM_MATCHED {
   2:   STREAM::disable;
   3: }

Conclusion

Now, whether you want a minimal integration with your performance code, or you want more granular reporting with geographically different datacenters or page level identification, you can easily implement them from within the network layer.  It is trivial to add support for both DataCenter (grpId) and Page level (pgId) into a single iRule to have an all encompassing solution.

Download

You can download the full script from the iRule CodeShare under GomezInjectionWithPageId.



Rate This Article:

COMMENTS

There are currently no comments, be the first to post one.
Only registered users may post comments.
  
Subscriptions: Video  |  Audio  |  Tutorials  |  Tech Tips  |  Features  | 

More...

 

 

Essentials Quick Start Guides
iRules Wiki | iControl SDK | WebAccelerator Wiki iRules | iControl
FirePass Wiki | Advanced Design & Config Wiki WebAccelerator | FirePass

 

Videos

  

Audio

Cache in with LTM and iRules
Can iRules fix my cert mismatch errors?
Concurrent iControl Programming Explained
Cookie LoJack vi iRules
Creating An iControl PowerShell Monitoring Dashboard With Google Charts
Custom SNMP Traps
Exchange Persistence Duality and iRules
FTPS Offload via iRules
Getting Started with pyControl
iControl 101 - #19 - Time Conversions
iControl 101 - #20 - Port Lockdown
iControl 101 - #21 - Rate Classes
iControl 101 - #22 - GTM Data Centers
iControl Apps - #04 - Graceful Server Shutdown
iControl Apps - #05 - Rate Based Statistics
iControl Apps - #06 - Configuration Archiving
iControl Apps - #07 - System Http Statistics
iControl Apps - #08 - System IP Statistics
iControl Apps - #09 - TMM Statistics
iControl Apps - #10 - Bigpipe List
iControl Apps - #11 - Global GTM Statistics
iControl Apps - #12 - Global SSL Statistics
iControl Apps - #13 - System PVA Statistics
iControl Apps - #14 - Global Statistics
iControl Apps - #18 - Virtual Server Reverse Lookup
Investigating the LTM TCP Profile: Acknowledgements
Investigating the LTM TCP Profile: Congestion Control Algorithms
Investigating the LTM TCP Profile: ECN &amp; LTR
Investigating the LTM TCP Profile: Max Syn Retransmissions &amp; Idle Timeout
Investigating the LTM TCP Profile: Nagle’s Algorithm
Investigating the LTM TCP Profile: The Finish Line
Investigating the LTM TCP Profile: Windows &amp; Buffers
iRules 101 - #13 - TCL String Commands Part 1
iRules 101 - #14 - TCL String Commands Part 2
iRules 101 - #15 - TCL List Handling Commands
iRules Event Order
Managing The System Boot Location with iControl
Persisting SSL Connections
Replacing the WebSphere Apache Plugin with iRules
Ruby meets iControl: Creating VIPs
Ruby meets iControl: Making Wide IPs
Ruby Meets iControl: Switching Policies
Ten Steps to iRules Optimization
Unbind your LDAP servers with iRules
v.10 - A new iRules Namespace
v.10 - FastHTTP and Cookie Persistence
v.10 - iRules and the after command
v.10 - New class features in iRules
v.10 - Remote Authorization via TACACS&#43;
v10.1 - Configuring GTM's DNS Security Extensions

  

Features

  

Tutorials

  

iControl

  

iRules

  

Monitoring & Management

  

Advanced Design & Config

  

93,050 Members in 191 Countries and Growing!

Join DevCentral Today!

About DevCentral

F5 DevCentral is your source for the best technical documentation, discussion forums, blogs, media and more related to application delivery networking.

So dive in, meet your peers, and get familiar with DevCentral. We hope it makes your job easier and helps you get more from your F5 investment. If new to DevCentral, check out the Getting Started section. And if you have any problems, or think something could be easier to use, let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback      or