Forum Discussion

Woody_'s avatar
Woody_
Icon for Nimbostratus rankNimbostratus
Dec 12, 2016

Collect Browser Version (UserAgent) via iRule?

Hello,

 

Our development team has asked us for a list of browsers/versions that clients are using to access our sites.

 

Running BigIP LTM 12.1.1, would this need to be accomplished via an iRule and if so, this is what I've come up with so far:

 

log local0. "User-Agent:[HTTP::header "User-Agent"]"

 

I would like the iRule to dump the output to a log file and attach said iRule to a few VS in our environment.

 

6 Replies

  • You've got it.

    when HTTP_REQUEST {
      log local0. "User Agent: [HTTP::header "User-Agent"]
    }
    
  • Try to write irule like below.

    when HTTP_REQUEST {
        log local0. "User-Agent:[HTTP::header "User-Agent"]"
    }
    
    • Vijay_E's avatar
      Vijay_E
      Icon for Cirrus rankCirrus

      /var/log/ directory. File name starts with ltm, ltm.1.gz etc

       

  • Another option you could use is to build some in-memory reporting with the STATS profile/commands. You can create custom metrics and build an iRule to report them directly from a virtual server on the BIG-IP. If you want to automate archiving the content, then you can add a QUERY option to the request to the VIP to tell the iRule to build a different response format (csv, txt, etc) and build a curl script to pull it down regularly.

     

    Here's something in that thought that I wrote a while ago around storing HTTP Status codes and reporting on them. Changing this to monitor User Agents wouldn't be that difficult.

     

    https://devcentral.f5.com/articles/custom-reporting-with-irules

     

    Good luck!

     

    -Joe

     

  • I have added log local0. "User Agent: [HTTP::header "User-Agent"] to my iRule. No matter if I use Chrome, IE, Firefox, or Safari, I get the same entry in the log:

     

    User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36

     

    Thoughts?