F5 BIG-IP Irule - redirect to individual node for external monitoring
Hi all
I'm looking at implementing an external monitoring solution whereby we do something like the following
-
read the URI and see if it contains formatting like this "/monitoring/servername" (filter on the "monitoring/" part and set that as a variable)
-
use that variable as the pool name and send traffic to it (ideally create the pool dynamically based on DNS)
-
rewrite the uri to remove the "/monitoring/servername" (where servername can be anything) to "*" (whatever is behind /monitoring/servername)
e.g if the f5 receives the following traffic:
HTTP GET: http://testing.com/login/login.aspx/monitoring/server21
It should interpret the string, send the traffic to server21, and remove the /monitoring/server21 from the URI.
i have looked at both policies and irules for this and I am pretty sure I need an irule. However I am not 100% on what to do. I would like the irule to be as flexible as possible ideally.
I know the below does not work but I am just trying to piece it together now... help?
when HTTP_REQUEST {
Check if path contains /monitoring
if {[HTTP::path] contains "/monitoring "}{
use getfield to split the uri based on monitoring/ and then return the server name after that
set server_id [getfield [HTTP::uri] "monitoring/" 1 ]
Replace /monitoring with / in the path
HTTP::redirect [string map {/monitoring /} [HTTP::path]]
pool ${server_id}
}
}