All Products
Search
Document Center

Simple Log Service:Parsing functions

Last Updated:Jun 16, 2026

Simple Log Service provides User-Agent parsing functions to extract device, operating system, and browser information from User-Agent strings, as well as URL parsing functions to decompose URLs and query strings.

Function list

Function

Description

ua_parse_device

Parses device information from the User-Agent string.

ua_parse_os

Parses operating system information from the User-Agent string.

ua_parse_agent

Parses browser information from the User-Agent string.

ua_parse_all

Parses all information from the User-Agent string.

url_parse

Parses the components of a URL.

url_parse_qs

Parses the parameters contained in the query string of a URL.

Note

The User-Agent parsing functions remove fields that have a value of None after parsing. For example, if the parsed device data is {'brand': None, 'family': 'Other', 'model': None}, the brand and model fields are removed. The final result is {'family': 'Other'}.

ua_parse_device

Parses device information from the User-Agent string.

  • Syntax

    ua_parse_device(value)
  • Parameters

    Parameter Name

    Data type

    Required

    Description

    value

    String

    Yes

    The User-Agent string to parse.

  • Response

    Returns JSON.

  • 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":"Mac","brand":"Apple","model":"Mac"}

ua_parse_os

Parses operating system information from the User-Agent string.

  • Syntax

    ua_parse_os(value)
  • Parameters

    Parameter name

    Data type

    Required

    Description

    value

    String

    Yes

    The User-Agent string to parse.

  • Response

    Returns JSON.

  • 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

Parses browser information from the User-Agent string.

  • Syntax

    ua_parse_agent(value)
  • Parameters

    Parameter

    Data type

    Required

    Description

    value

    String

    Yes

    The User-Agent string to parse.

  • Response

    Returns JSON.

  • 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

Parses all information from the User-Agent string.

  • Syntax

    ua_parse_all(value)
  • Parameters

    Parameter Name

    Data type

    Required

    Description

    value

    String

    Yes

    The User-Agent string to parse.

  • Response

    Returns JSON.

  • 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"
        }
      }

url_parse

Parses the components of a URL.

  • Syntax

    url_parse(url, scheme="", allow_fragments=True)
  • Parameters

    Parameter Name

    Data type

    Required

    Description

    value

    String

    Yes

    The URL to parse.

    scheme

    String

    No

    The network protocol. Default: empty string.

    Used as the scheme value in the result only when the URL does not contain a protocol.

    allow_fragments

    Boolean

    No

    Whether to parse the fragment part of the URL.

    • True (default): Parses the fragment part. The fragment field in the result contains the specific value.

    • False: Does not parse the fragment part. The fragment field in the result is an empty string.

  • Response

    Returns JSON with the following fields.

    Field

    Description

    scheme

    Network protocol

    netloc

    Network location

    path

    Hierarchical path

    query

    Query component

    fragment

    Fragment identifier

  • Examples

    • Example 1: Use default parameters to return the components of a URL.

      • Raw log

        content:https://username:username@example.com:8083/hello/asdah/;type=docx?filename=python3.docx#urllib
      • Transformation rule

        e_set("url",url_parse(v("content")))
      • Result

        content:https://username:username@example.com:8083/hello/asdah/;type=docx?filename=python3.docx#urllib
        url:{
                "scheme": "https",
                "netloc": "username:username@example.com:8083",
                "path": "/hello/asdah/;type=docx",
                "query": "filename=python3.docx",
                "fragment": "urllib"
            }
    • Example 2: Set allow_fragments to False. The value of the fragment parameter in the result is an empty string.

      • Raw log

        content:https://username:username@example.com:8083/hello/asdah/;type=docx?filename=python3.docx#urllib
      • Transformation rule

        e_set("url",url_parse(v("content"),allow_fragments=False))
      • Result

        content:https://username:username@example.com:8083/hello/asdah/;type=docx?filename=python3.docx#urllib
        url:{
                 "scheme": "https",
                "netloc": "username:username@example.com:8083",
                "path": "/hello/asdah/;type=docx",
                "query": "filename=python3.docx",
                "fragment": ""
            }
    • Example 3: Set scheme to https and allow_fragments to False. The value of the scheme parameter in the result is https, and the value of the fragment parameter is an empty string.

      • Raw log

        content://username:username@example.com:8083/hello/asdah/;type=docx?filename=python3.docx#urllib
      • Transformation rule

        e_set("url",url_parse(v("content"),scheme="https", allow_fragments=False))
      • Result

        content://username:username@example.com:8083/hello/asdah/;type=docx?filename=python3.docx#urllib
        url:{
               "scheme": "https",
                "netloc": "username:username@example.com:8083",
                "path": "/hello/asdah/;type=docx",
                "query": "filename=python3.docx",
                "fragment": ""
            }

url_parse_qs

Parses the components of a URL query string.

  • Syntax

    url_parse_qs(
        url_qs,
        keep_blank_values=False,
        strict_parsing=False,
        encoding="utf-8",
        errors="replace",
        ignore_multi_fields=True,
    )
  • Parameters

    Parameter Name

    Data type

    Required

    Description

    url_qs

    String

    Yes

    The URL query string to parse.

    keep_blank_values

    Boolean

    No

    Whether to return parameters that have empty values.

    • False (default): The value is not returned.

    • True: Returns these parameters and sets their values to empty strings.

    strict_parsing

    Boolean

    No

    How to handle parsing errors.

    • True: A ValueError exception is triggered.

    • False (default): Errors are ignored.

    encoding

    String

    No

    The codec used to decode percent-encoded characters into Unicode. Default: utf-8. ASCII is also supported.

    errors

    String

    No

    How to handle characters that cannot be decoded by the specified codec. Valid values:

    • ignore: No action is taken.

    • strict: Reports an error and discards the log entry.

    • replace (default): Replaces the unrecognized characters with a question mark (?).

    • xmlcharrefreplace: Replaces the unrecognized characters with the corresponding XML character references.

    ignore_multi_fields

    Number

    No

    Whether to return only the first value for each parameter.

    • True (default): Returns only the first value for each parameter. The value is a string.

    • False: Returns all values for each parameter. The values are returned in a list.

  • Response

    Returns JSON with the following fields.

    Parameter

    Description

    logType

    Log type.

    uid

    Unique identifier of the log.

    time

    Timestamp of the log.

    msg

    Log message content.

  • Examples

    • Example 1: Set keep_blank_values to True. The result includes parameters with empty values.

      • Raw log

        content:logType=net_wheel_log&uid=62452****&vid=6.1.0_gf_pc&asb=1206427&git=&time=22-11-3+%e4%b8%8a11%e6%97%b649%e5%88%8633%e7%a7%92&operatingSystem=Windows+10++(10.0.0)+64bit&deviceModel=System+Product+Name+(System+manufacturer)&graphicsDeviceName=NVIDIA+GeForce+GTX+1650&graphicsDeviceType=Direct3D11&graphicsDeviceVendor=NVIDIA&graphicsDeviceVersion=Direct3D+11.0+%5blevel+11.1%5d&graphicsMemorySize=3962&systemMemorySize=8127&processorCount=6&processorFrequency=3000&processorType=Intel(R)+Core(TM)+i5-9500F+CPU+%40+3.00GHz&deviceID=96da5902a042a5f84118995f88373f73650e76be166589726****&guessUID=62452****&networkReachability=wifi&msg=GetAuthkeyRsp
      • Transformation rule

        e_set("url",url_parse_qs(v("content"), keep_blank_values=True))
      • Result

        content:logType=net_wheel_log&uid=62452****&vid=6.1.0_gf_pc&asb=1206427&git=&time=22-11-3+%e4%b8%8a11%e6%97%b649%e5%88%8633%e7%a7%92&operatingSystem=Windows+10++(10.0.0)+64bit&deviceModel=System+Product+Name+(System+manufacturer)&graphicsDeviceName=NVIDIA+GeForce+GTX+1650&graphicsDeviceType=Direct3D11&graphicsDeviceVendor=NVIDIA&graphicsDeviceVersion=Direct3D+11.0+%5blevel+11.1%5d&graphicsMemorySize=3962&systemMemorySize=8127&processorCount=6&processorFrequency=3000&processorType=Intel(R)+Core(TM)+i5-9500F+CPU+%40+3.00GHz&deviceID=96da5902a042a5f84118995f88373f73650e76be166589726****&guessUID=62452****&networkReachability=wifi&msg=GetAuthkeyRsp
        url:{
                "logType": "net_wheel_log",
                "uid": "62452****",
                "vid": "6.1.0_gf_pc",
                "asb": "1206427",
                "git": "",
                "time": "22-11-3 11:49:33 AM",
                "operatingSystem": "Windows 10  (10.0.0) 64bit",
                "deviceModel": "System Product Name (System manufacturer)",
                "graphicsDeviceName": "NVIDIA GeForce GTX 1650",
                "graphicsDeviceType": "Direct3D11",
                "graphicsDeviceVendor": "NVIDIA",
                "graphicsDeviceVersion": "Direct3D 11.0 [level 11.1]",
                "graphicsMemorySize": "3962",
                "systemMemorySize": "8127",
                "processorCount": "6",
                "processorFrequency": "3000",
                "processorType": "Intel(R) Core(TM) i5-9500F CPU @ 3.00GHz",
                "deviceID": "96da5902a042a5f84118995f88373f73650e76be166589726****",
                "guessUID": "62452****",
                "networkReachability": "wifi",
                "msg": "GetAuthkeyRsp"
            }
    • Example 2: Set keep_blank_values to the default value (False). The result does not include parameters with empty values.

      • Raw log

        content:logType=net_wheel_log&uid=62452****&vid=6.1.0_gf_pc&asb=1206427&git=&time=22-11-3+%e4%b8%8a11%e6%97%b649%e5%88%8633%e7%a7%92&operatingSystem=Windows+10++(10.0.0)+64bit&deviceModel=System+Product+Name+(System+manufacturer)&graphicsDeviceName=NVIDIA+GeForce+GTX+1650&graphicsDeviceType=Direct3D11&graphicsDeviceVendor=NVIDIA&graphicsDeviceVersion=Direct3D+11.0+%5blevel+11.1%5d&graphicsMemorySize=3962&systemMemorySize=8127&processorCount=6&processorFrequency=3000&processorType=Intel(R)+Core(TM)+i5-9500F+CPU+%40+3.00GHz&deviceID=96da5902a042a5f84118995f88373f73650e76be166589726****&guessUID=62452****&networkReachability=wifi&msg=GetAuthkeyRsp
      • Transformation rule

        e_set("url",url_parse_qs(v("content")))
      • Results

        content:logType=net_wheel_log&uid=62452****&vid=6.1.0_gf_pc&asb=1206427&git=&time=22-11-3+%e4%b8%8a11%e6%97%b649%e5%88%8633%e7%a7%92&operatingSystem=Windows+10++(10.0.0)+64bit&deviceModel=System+Product+Name+(System+manufacturer)&graphicsDeviceName=NVIDIA+GeForce+GTX+1650&graphicsDeviceType=Direct3D11&graphicsDeviceVendor=NVIDIA&graphicsDeviceVersion=Direct3D+11.0+%5blevel+11.1%5d&graphicsMemorySize=3962&systemMemorySize=8127&processorCount=6&processorFrequency=3000&processorType=Intel(R)+Core(TM)+i5-9500F+CPU+%40+3.00GHz&deviceID=96da5902a042a5f84118995f88373f73650e76be166589726****&guessUID=62452****&networkReachability=wifi&msg=GetAuthkeyRsp
        url:{
                "logType": "net_wheel_log",
                "uid": "62452****",
                "vid": "6.1.0_gf_pc",
                "asb": "1206427",
                "time": "22-11-3 11:49:33",
                "operatingSystem": "Windows 10  (10.0.0) 64bit",
                "deviceModel": "System Product Name (System manufacturer)",
                "graphicsDeviceName": "NVIDIA GeForce GTX 1650",
                "graphicsDeviceType": "Direct3D11",
                "graphicsDeviceVendor": "NVIDIA",
                "graphicsDeviceVersion": "Direct3D 11.0 [level 11.1]",
                "graphicsMemorySize": "3962",
                "systemMemorySize": "8127",
                "processorCount": "6",
                "processorFrequency": "3000",
                "processorType": "Intel(R) Core(TM) i5-9500F CPU @ 3.00GHz",
                "deviceID": "96da5902a042a5f84118995f88373f73650e76be166589726****",
                "guessUID": "62452****",
                "networkReachability": "wifi",
                "msg": "GetAuthkeyRsp"
            }
    • Example 3: Set ignore_multi_fields to the default value (True). Only the first value for each parameter is returned.

      • Raw log

        content:logType=net_log&uid=62452****&x=1&x=2&x=3&asb=123&asb=456
      • Transformation rule

        e_set("url",url_parse_qs(v("content")))
      • Result

        content:logType=net_log&uid=62452****&x=1&x=2&x=3&asb=123&asb=456
        url:{
            "logType": "net_log",
            "uid": "62452****",
            "x": "1",
            "asb": "123"
        }
    • Example 4: Set ignore_multi_fields to False. All values for each parameter are returned.

      • Raw log

        content:logType=net_log&uid=62452****&x=1&x=2&x=3&asb=123&asb=456
      • Transformation rule

        e_set("url",url_parse_qs(v("content"),ignore_multi_fields=False))
      • Result

        content:logType=net_log&uid=62452****&x=1&x=2&x=3&asb=123&asb=456
        url:{
            "logType": ["net_log"],
              "uid": ["62452****"],
              "x": ["1", "2", "3"],
              "asb": ["123", "456"]
        }