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" \
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.
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
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.
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.