yalp.parsers.user_agentΒΆ

Extract browser, OS, device and other information from a user agent string.

The parser supports the following configuration items:

field
The field containing the user agent string to parse. If the field is not found in the event, the event will be skipped. Defaults to agent.
out_field
Set this to a field to store the user agent information under. If not set, the new field are added at the top level of the event.
type
A type filter. Events not of this type will be skipped.

Example configuration.

parsers:
  - user_agent:
      field: 'agent'
      out_field: 'user_agent'

With an input event like the following:

{
    'hostname': 'server_hostname',
    'time_stamp': '2015-01-01T01:00:00',
    'message': '"Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"',
    'agent': '"Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"',
}

After the parser runs, the event will become:

{
    'hostname': 'server_hostname',
    'time_stamp': '2015-01-01T01:00:00',
    'message': '"Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"',
    'agent': '"Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"',
    'user_agent': {
        'os': {
            'family': 'Linux',
            'version': ''
        },
        'browser': {
            'family': 'Firefox',
            'version': '38'
        },
        'device': {
            'brand': None,
            'family': 'Other',
            'model': None,
        },
        'is_bot': False,
        'is_mobile': False,
        'is_pc': True,
        'is_tablet': False,
        'is_touch_capable': False,
    },
}