Forum Discussion

benniehanas_239's avatar
benniehanas_239
Icon for Nimbostratus rankNimbostratus
Mar 14, 2018

Help with iRule logging to local0.

I am trying to log an iRule, but it keeps erroring out. Can you help with what I'm missing?

 

when HTTP_REQUEST { if { [HTTP::path] starts_with "/media" } { pool persist cookie insert log local0. ”media.com_28080 TCP_logging fired, from [IP::client_addr]" } }

 

9 Replies

  • what is the error that you get? I noticed you are sending to a pool if it matches the uri but in your pool statement there is no pool defined.

     

    when HTTP_REQUEST { if { [HTTP::path] starts_with "/media" } { pool persist cookie insert log local0. ”media.com_28080 TCP_logging fired, from [IP::client_addr]" } }

     

  • Try this to start with. I've removed your cookie persist section as this didn't match the required syntax. See https://devcentral.f5.com/wiki/iRules.persist.ashx for details. You don't need to configure persistence with an iRule, add a cookie persistence profile to the virtual server

    when HTTP_REQUEST { 
        if { [HTTP::path] starts_with "/media" } { 
            pool  
            log local0. "media.com_28080 TCP_logging fired, from [IP::client_addr]" 
        } 
    }
    
  • I took the pool name out as it was a FQDN. My error is:

     

    01070151:3: Rule [/Common/media_pool_redirect] error: /Common/media_pool_redirect:5: error: ["invalid argument local0"][log local0 ”] /Common/media_pool_redirect:5: error: [undefined procedure: media.com_28080][media.com_28080 TCP_logging fired, from [IP::client_addr] to vip [IP::local_addr]"]

     

  • try to remove the underscores character from your media.com_28080 and TCP_logging fired section of the log. they look to be being interpreted differently by the irule. they look like actual functions similar to IP::local_addr

     

    try this for the log statement:

     

    log local0. ”media.com.28080 TCP.logging fired, from [IP::client_addr]"

     

  • so tried the irule in the lab.. here is working irule per my test.. it was not the underscore. it was some extra or missing curly bracket...

     

    when HTTP_REQUEST { if { [HTTP::path] starts_with "/media" } {

     

    pool persist cookie insert

    log local0. "mediacom_28080 TCP_logging fired, from [IP::client_addr]" } }

     

    resulting log

     

    Mar 14 09:37:22 f5 info tmm1[21757]: Rule /Common/slashmedia : mediacom_28080 TCP_logging fired, from xx.xx.xx.xx

     

  • somehow, pool and persist cookie insert shown as enlarge words.. i actually added a character in front of the line to comment them out for testing.

     

  • The issue may be the character . this is not the accepted double-quote inside irules. replace it with "