08-Oct-2020 07:48
I wish to log via HSL a mesage that contains some repeatable text as well as some user generated text. so one of two ways to get text generated I can see. But I some issues with each method. #1: Use a loggin profile template, but when you do how to you add some text to the end (or access via a variable text you feed it? i.e the vIP has a template assignmed, iRule has an HSL::open call, then the iRule later calls say HSL::send $hsl "and does this then get appended to the end?". And all you get is what is specified in the template. How can I pass my string body (value or reference) into the template.
#2 Use all text generation in the iRule, but then how do I get at dynamic values that I want but that are only available when you log via the profile/template. For example: $DATE_MON $DATE_DD $TIME_HMS $BIGIP_HOSTNAME and so on.
Solved! Go to Solution.
20-Oct-2020 01:23
Hello Martin.
With a request-logging profile you can set any kind of format in the template field.
An example of CEF format:
CEF:0|F5|MyEnv|1|sip=$CLIENT_IP sprt=$CLIENT_PORT snatip=$SNAT_IP snatprt=$SNAT_PORT dstip=$SERVER_IP dstprt=$SERVER_PORT dhost=$BIGIP_HOSTNAME apm=$X_APM
Where 'X_APM can be configured injecting an HTTP header:
when HTTP_REQUEST {
HTTP::header replace X_APM [ACCESS::session data get session.custom.name]
}
when HTTP_REQUEST_RELEASE {
HTTP::header remove X_APM
}
---
In case you still want to use an iRule, you can get those parameters with:
1) Hostname
$static::tcl_platform(machine)
2) Time
set curtime [clock seconds]
set formattedtime [clock format $curtime]
log "$curtime seconds since epoch, $formattedtime"
Output: 1129552706 seconds since epoch, Mon Oct 17 07:38:26 CDT 2005
Regards,
Dario.
19-Oct-2020 09:42
Hello Martin.
It's better to use a request logging profile.
https://support.f5.com/csp/article/K00847516
You can add extra variables injecting HTTP headers into the HTTP_REQUEST and referencing them with the same name of the header:
$BIGIP_HOSTNAME $Host ${X-Forwarded-For} ...
If you want to avoid sending those headers to the backend server, you can remove them again using this event:
https://clouddocs.f5.com/api/irules/HTTP-REQUEST-RELEASE.html
Regards,
Dario.
19-Oct-2020 14:13
20-Oct-2020 01:23
Hello Martin.
With a request-logging profile you can set any kind of format in the template field.
An example of CEF format:
CEF:0|F5|MyEnv|1|sip=$CLIENT_IP sprt=$CLIENT_PORT snatip=$SNAT_IP snatprt=$SNAT_PORT dstip=$SERVER_IP dstprt=$SERVER_PORT dhost=$BIGIP_HOSTNAME apm=$X_APM
Where 'X_APM can be configured injecting an HTTP header:
when HTTP_REQUEST {
HTTP::header replace X_APM [ACCESS::session data get session.custom.name]
}
when HTTP_REQUEST_RELEASE {
HTTP::header remove X_APM
}
---
In case you still want to use an iRule, you can get those parameters with:
1) Hostname
$static::tcl_platform(machine)
2) Time
set curtime [clock seconds]
set formattedtime [clock format $curtime]
log "$curtime seconds since epoch, $formattedtime"
Output: 1129552706 seconds since epoch, Mon Oct 17 07:38:26 CDT 2005
Regards,
Dario.
20-Oct-2020 01:46
20-Oct-2020 02:07
Hello Martin.
Actually request-logging should have a better performance.
But any of both solutions are fine :-).
If this was helpful, I'll appreciate if you mark my answer as the best to help me for the contribution.
Regards,
Dario.
20-Oct-2020 02:15