Forum Discussion

Jason_46956's avatar
Jason_46956
Icon for Nimbostratus rankNimbostratus
Dec 23, 2010

Trying to create audit logs with session variable from APM

Am trying to sort out logging for auditing purposes and have the following problem. Hoping somebody here might be able to provide some guidance.

 

 

Want to log the username (to start with) of each request when going through APM. The following iRule seems to cover most of what we need.

 

The problem is that when the users web browser session swaps between the different tmm processes only one seems to have the right information.

 

 

when CLIENT_ACCEPTED {

 

log local7. "Here"

 

set userip [IP::client_addr]

 

set username "unknown"

 

set sessionid "unknown"

 

}

 

 

when HTTP_REQUEST {

 

log local7. "$userip $username $sessionid [HTTP::uri]"

 

}

 

 

when ACCESS_ACL_ALLOWED {

 

log local7. "Here"

 

set username [ACCESS::session data get "session.logon.last.username"]

 

set sessionid [ACCESS::session data get "session.user.sessionid"]

 

}

 

 

What gets logged:

 

Dec 22 14:06:05 local/tmm2/laf5a003-int info tmm2[5557]: Rule log-request : 203.8.131.32 unknown unknown /f5-w-687474703a2f2f617473776562746573742e646d7a3a39303530$$/atsweb/images/url-link.gif?F5CH=I

 

Dec 22 14:06:05 local/tmm2/laf5a003-int info tmm2[5557]: Rule log-request : Here

 

Dec 22 14:06:05 local/tmm1/laf5a003-int info tmm1[5556]: Rule log-request : 203.8.131.32 wilsonjp 0250d3a1 /f5-w-687474703a2f2f617473776562746573742e646d7a3a39303530$$/atsweb/images/logo_line2.gif?F5CH=I

 

Dec 22 14:06:05 local/tmm1/laf5a003-int info tmm1[5556]: Rule log-request : Here

 

 

When using tmm2 it does not know the user, but with tmm1 it does.

 

Need to either store the variables in a global cache, or would some sort of session persistence be better to achieve this.

 

 

This is just go get started, also need to log request sizes, response sizes and timing information too.

 

 

Running with 10.2 HF2.

 

 

Thanks,

 

Jason

 

 

  • Hi Jason,

     

     

    I would have expected APM session data to be accessible across all TMM instances. If you're not seeing this, I suggest opening a case with F5 Support. If you do, can you post back here with what you find?

     

     

    Thanks, Aaron
  • Aaron,

    I did actually log a case with F5 and they gave me some hints to fix my rule. The problem was with the order I trying to collect the data and the order that the events trigger.

    The updated rule (which does what I need so far) is:

    
    when CLIENT_ACCEPTED {
      set userip [IP::client_addr]
      set username "unknown"
      set sessionid "unknown"
    }
    
    when ACCESS_ACL_ALLOWED {
      set username [ACCESS::session data get "session.logon.last.username"]
      set sessionid [ACCESS::session data get "session.user.sessionid"]
      log local7. "$userip $username $sessionid [HTTP::uri]"
    }