This topic describes the syntax and parameters of User-Agent parsing functions. This topic also provides examples on how to use the functions.

Functions

Function Description
ua_parse_device Parses User-Agent and returns the device information.
ua_parse_os Parses User-Agent and returns the operating system information.
ua_parse_agent Parses User-Agent and returns the browser information.
ua_parse_all Parses User-Agent and returns all information.
Note The User-Agent parsing functions delete fields whose parsed values are None. For example, if the device information that is obtained is {'brand': None, 'family': 'Other', 'model': None}, the brand and model fields are deleted and the final parsing result is {'family': 'Other'}.

ua_parse_device

The ua_parse_device function parses User-Agent and returns the device information.
  • Syntax

    ua_parse_device(value)
  • Parameters

    Parameter Type Required Description
    value String Yes The User-Agent string that you want to parse. Example: ua_parse_device(v("http_user_agent")).
  • Response

    A JSON-formatted data set is returned.

  • Examples

    • Raw log
      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

The ua_parse_os function parses User-Agent and returns the operating system information.
  • Syntax

    ua_parse_os(value)
  • Parameters

    Parameter Type Required Description
    value String Yes The User-Agent string that you want to parse. Example: ua_parse_os(v("http_user_agent")).
  • Response

    A JSON-formatted data set is returned.

  • Examples

    • Raw log
      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

The ua_parse_agent function parses User-Agent and returns the browser information.
  • Syntax

    ua_parse_agent(value)
  • Parameters

    Parameter Type Required Description
    value String Yes The User-Agent string that you want to parse. Example: ua_parse_agent(v("http_user_agent")).
  • Response

    A JSON-formatted data set is returned.

  • Examples

    • Raw log
      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_agent(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

The ua_parse_all function parses User-Agent and returns all information.
  • Syntax

    ua_parse_all(value)
  • Parameters

    Parameter Type Required Description
    value String Yes The User-Agent string that you want to parse. Example: ua_parse_all(v("http_user_agent")).
  • Response

    A JSON-formatted data set is returned.

  • Examples

    • Raw log
      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: {
        "user_agent": {
          "family": "Chrome",
          "major": "192",
          "minor": "168",
          "patch": "0"
        },
        "os": {
          "family": "Mac OS X",
          "major": "10",
          "minor": "9",
          "patch": "4"
        },
        "device": {
          "family": "Mac",
          "brand": "Apple",
          "model": "Mac"
        }
      }