Forum Discussion
Joel_Moses
Nimbostratus
Dec 07, 2009Determining stats profile name for VS
Is there any way within an iRule to detect the Statistics profile set for the current VS? I'd assumed there would be a [PROFILE:: exists stats] or something similar, but there isn't. The Wiki isn't exactly clear on whether there's a way to do it.
6 Replies
- The_Bhattman
Nimbostratus
I suppose you can do a catch statement against STATS::get . However, that would assume that the profile on exists with a specific common field. It's not ideal but I am throwing it out there
Bhattman - Joel_Moses
Nimbostratus
Lack of a [STATS::profilename] that contains the name of the current VS's statistics profile or a [PROFILE::statisics exists] is a big problem. Means that you're forced to create a distinct stats collection iRule for each profile, rather than a single iRule that can determine which statistics profile to write to in the context of its VS.
So if I wanted to have an iRule simply add values to the current VS's configured Statistics profile, I could reuse this rule if I could do [STATS::profilename]:when HTTP_REQUEST { set t0 [clock clicks -milliseconds] } when HTTP_RESPONSE { set t1 [clock clicks -milliseconds] set total_time [expr $t1 - $t0] STATS::incr [STATS::profilename] "num_requests" 1 STATS::incr [STATS::profilename] "total_time" $total_time switch -glob [HTTP::status] { "20*" { STATS::incr [STATS::profilename] "count_20x" 1 } "30*" { STATS::incr [STATS::profilename] "count_30x" 1 } "40*" { STATS::incr [STATS::profilename] "count_40x" 1 } "50*" { STATS::incr [STATS::profilename] "count_50x" 1 } } }
But since I don't seem to have the ability to detect the profile for the currently active VS, I'm having to create multiple iRules like this:when RULE_INIT { set ::stat_profile "active_site1_page_delay" } when HTTP_REQUEST { set t0 [clock clicks -milliseconds] } when HTTP_RESPONSE { set t1 [clock clicks -milliseconds] set total_time [expr $t1 - $t0] STATS::incr $::stat_profile "num_requests" 1 STATS::incr $::stat_profile "total_time" $total_time switch -glob [HTTP::status] { "20*" { STATS::incr $::stat_profile "count_20x" 1 } "30*" { STATS::incr $::stat_profile "count_30x" 1 } "40*" { STATS::incr $::stat_profile "count_40x" 1 } "50*" { STATS::incr $::stat_profile "count_50x" 1 } } }
Unless I'm missing something. And that's more than likely. üòÜ - hoolio
Cirrostratus
It would be useful to have a way to determine the name of the stats profile from an iRule. If this isn't possible, you could open a case with F5 Support and ask them to consider adding this functionality in a future release.
For now, do you want to use one stats profile per VIP? If so, you could use a naming convention based on the VIP name that would allow you to write a generic rule:when HTTP_REQUEST { log local0. "\[virtual name\]: [virtual name]" log local0. "vip stats profile name: [virtual name]_stats" log local0. "vip stats profile field1 value: [STATS::get [virtual name]_stats field1]" log local0. "vip stats profile field1 value incr: [STATS::incr [virtual name]_stats field1]" log local0. "vip stats profile field1 value: [STATS::get [virtual name]_stats field1]" }
And the log output:
: [virtual name]: example.com_http_vs
: vip stats profile name: example.com_http_vs_stats
: vip stats profile field1 value: 0
: vip stats profile field1 value incr: 1
: vip stats profile field1 value: 1
If you're trying to use one stats profile on multiple VIPs, you could create a datagroup which maps the VIP name to the stats profile name. You could then use class or findclass in RULE_INIT to set the stats profile name for the particular VIP the iRule is running on.
Neither option is perfect, but they would get you around the need to hardcode the stats profile name in the iRule.
Aaron - GavinW_29074
Nimbostratus
Hey,
Sorry to bring this back from the dead, but I'm looking to do exactly the same thing...
Did this ever get implemented?
Cheers
Gavin - Michael_Yates
Nimbostratus
Hi GavinW,
It doesn't look like it has been implemented. You would need to open up a case with F5 and submit an RFE (or find out if there has already been one submitted that they have not gotten to yet).
Current STATS Commands: STATS - GavinW_29074
Nimbostratus
Michael
Cheers for the update.
Will get it logged...
Gav
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects