Forum Discussion

sandiksk_35282's avatar
sandiksk_35282
Icon for Altostratus rankAltostratus
Jan 21, 2017

log command into an irule

How to insert a log command into an irule to see traffic traffic particular source getting hit to all the condition applied in the irule and going to the correct pool

 

8 Replies

  • See logging.

    Example:

    when HTTP_REQUEST {
    log local0. “Requested hostname: [HTTP::host] from IP: [IP::local_addr]”
    }
    
  • Is this what you're after?

    when XML_CONTENT_BASED_ROUTING { 
      for {set i 0} { $i < $XML_count } {incr i} {
        if {($XML_queries($i) contains "CDetails")} {
           pool qa2-pool
        } elseif {($XML_queries($i) contains "GetBalances")} {
           pool qa2-pool
        }  
        log local0. "IP:[IP::remote_addr] XML_queries\($i\):$XML_queries($i) pool:[LB::server pool]"
      }
    }
    

    BTW the logic above doesn't quite make sense - you may want to put a 'break' statement in to leave the loop?

    • sandiksk_35282's avatar
      sandiksk_35282
      Icon for Altostratus rankAltostratus

      This is the irule I am using .

       

      ltm rule prd_xml_irule { when XML_CONTENT_BASED_ROUTING { for {set i 0} { $i < $XML_count } {incr i} { log local0. $XML_queries($i) if {($XML_queries($i) contains "CDetails")} { pool prd2_pool } elseif {($XML_queries($i) contains "GetBalances")} { pool prd2_pool } elseif {($XML_queries($i) contains "GetSPoints")} { pool prd2_pool }

       

      } } } and if these attributes does not match then they will be hitting the default pool defined in the VS.

       

    • IheartF5_45022's avatar
      IheartF5_45022
      Icon for Nacreous rankNacreous

      So once you've found an element that contains the string you are looking for - do you need to keep looking? If you can stop looking after finding the first occurrence, you can use 'break' to leave the loop.

      when XML_CONTENT_BASED_ROUTING { 
        for {set i 0} { $i < $XML_count } {incr i} {
          log local0. "$i: $XML_queries($i)"
          switch -glob -- $XML_queries($i) {
             "*CDetails*" -
             "*GetBalances*" -
             "*GetSPoints*" {  
                 log local0. "Choosing pool prd2_pool"
                 pool prd2_pool 
                 break
             }
          }
      }
      

      Ignore the switch (I like how switches look), the main point is the 'break'

    • sandiksk_35282's avatar
      sandiksk_35282
      Icon for Altostratus rankAltostratus

      Will iRule be used once per TCP connection , in our scenario client is opening a TCP session and with in the same session application is making multiple call , is it possible for each call to hit the irule or can i create a loop for the same TCP session . we are doing ssl offload on f5 and again encrypting the traffic from f5 to pool members.

       

      Please advice me on this