Parse User-Agent Function

Functions of this type parse a user agent string into its components.

It is a wrapper around the BrowserScope's user agent string parser.

Configuration

A new function of type http.useragent named <id> can be created as follows:

mldb.put("/v1/functions/"+<id>, {
    "type": "http.useragent",
    "params": {
        "regexFile": <string>
    }
})

with the following key-value definitions for params:

Field, Type, DefaultDescription

regexFile
string
"/opt/bin/useragent-regexes.yaml"

User agent string parser YAML configuration file

Input and Output Values

Functions of this type have a single input value named ua which is a string.

The output values of functions of this type are:

Example

Assume we have created a function of this type called ua_parser, the following call:

SELECT ua_parser({ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3'}) as *

will return:

rowName browser.family browser.version device.brand device.model isSpider os.family os.version
result Mobile Safari 5.1.0 Apple iPhone 0 iOS 5.1.1

See also