This topic describes the syntax and parameters of the functions that are used to parse the User-Agent HTTP header. The topic also provides examples of the functions.

Functions

Function Description
ua_parse_device Parses the device information in the User-Agent HTTP header.
ua_parse_os Parses the operating system information in the User-Agent HTTP header.
ua_parse_agent Parses the browser information in the User-Agent HTTP header.
ua_parse_all Parses all the information in the User-Agent HTTP header.
Note If the value of a field that is parsed from the User-Agent HTTP header is None, the field is dropped. For example, if the device information is parsed into {'brand': None, 'family': 'Other', 'model': None}, the brand and model fields are dropped. Therefore, the parsing result is {'family': 'Other'}.

ua_parse_device

Parses the device information in the User-Agent HTTP header.

  • Syntax
    ua_parse_device(value)
  • Parameters
    Parameter Data type Required Description
    value String Yes The User-Agent HTTP header, in the format of a string, for example, ua_parse_device(v("http_user_agent")).
  • Response

    JSON-formatted data is returned.

  • Examples
    • Raw log entry:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
    • Transformation rule:
      e_set("new_column",ua_parse_device(v("http_user_agent")))
    • Result:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
      new_column:{'family': 'Other'}

ua_parse_os

Parses the operating system information in the User-Agent HTTP header.

  • Syntax
    ua_parse_os(value)
  • Parameters
    Parameter Data type Required Description
    value String Yes The User-Agent HTTP header, in the format of a string, for example, ua_parse_os(v("http_user_agent")).
  • Response

    JSON-formatted data is returned.

  • Examples
    • Raw log entry:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
    • Transformation rule:
      e_set("new_column",ua_parse_os(v("http_user_agent")))
    • Result:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
      new_column:{'family': 'Mac OS X',
                          'major': '10',
                          'minor': '9',
                          'patch': '4'}

ua_parse_agent

Parses the browser information in the User-Agent HTTP header.

  • Syntax
    ua_parse_device(value)
  • Parameters
    Parameter Data type Required Description
    value String Yes The User-Agent HTTP header, in the format of a string, for example, ua_parse_agent(v("http_user_agent")).
  • Response

    JSON-formatted data is returned.

  • Examples
    • Raw log entry:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
    • Transformation rule:
      e_set("new_column",ua_parse_(v("http_user_agent")))
    • Result:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
      new_column:{'family': 'Chrome', 'major': '192', 'minor': '168', 'patch': '0'}

ua_parse_all

Parses all the information in the User-Agent HTTP header.

  • Syntax
    ua_parse_all(value)
  • Parameters
    Parameter Data type Required Description
    value String Yes The User-Agent HTTP header, in the format of a string, for example, ua_parse_all(v("http_user_agent")).
  • Response

    JSON-formatted data is returned.

  • Examples
    • Raw log entry:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
    • Transformation rule:
      e_set("new_column",ua_parse_all(v("http_user_agent")))
    • Result:
      http_user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/192.168.0.0 Safari/537.36
      new_column:{   
          'device': {'family': 'Other',},
          'os': {   'family': 'Mac OS X',
                    'major': '10',
                    'minor': '9',
                    'patch': '4'},
          'user_agent': {   'family': 'Chrome',
                            'major': '192',
                            'minor': '168',
                            'patch': '0'}}