Filebeat decode_json_fields не обрабатывает массивы - PullRequest
0 голосов
/ 30 октября 2019

Мы используем filbeat процессор decode_json-fields для обработки сообщений журнала в Json. Проблема, с которой мы сталкиваемся, состоит в том, что некоторые из наших журналов являются многослойными с довольно большим количеством массивов и несколькими вложенными объектами. Мы попытались использовать decode_json_fields с установленным значением true для флага process_array, но Filebeat по-прежнему обрабатывает все, что следует за '[', в одном поле.

Это то, что мы получаем на дисплее Кибаны:

@timestamp                   Oct 28, 2019 @ 12:22:06.610
t _id                        pKEaEm4B7zyLz8s9M8Xe
t _index                     filebeat-7.3.2-2019.10.28-000001
# _score                     -
t _type                      _doc
t agent.ephemeral_id         7c3cd7b7-2f76-424e-a417-5aa82f119bed
t agent.hostname             ******
t agent.id                   571154fa-e864-49b1-a224-9d405befeddf
t agent.type                 filebeat
t agent.version              7.3.2
? circuitPath                { "policy": "Health Check LB", "execTime": 0, "filters": [ { "class": "com.vordel.circuit.attribute.CompareAttributeFilter", "status": "Pass", "filterTime": 1557733771853, "execTime": 0, "espk": "PrimaryStore-43595d15-05f6-4135-aa9a-e8b9b2a35bda:-439438454261778670", "name": "Compare Attribute", "type": "CompareAttributeFilter" }, { "execTime": 0, "espk": "PrimaryStore-43595d15-05f6-4135-aa9a-e8b9b2a35bda:-6704867506249825459", "name": "Set Message - OK", "type": "ChangeMessageFilter", "class": "com.vordel.circuit.conversion.ChangeMessageFilter", "status": "Pass", "filterTime": 1557733771853 }, { "execTime": 0, "espk": "PrimaryStore-43595d15-05f6-4135-aa9a-e8b9b2a35bda:-5308572925601299001", "name": "Reflect - OK", "type": "ReflectFilter", "class": "com.vordel.circuit.net.ReflectFilter", "status": "Pass", "filterTime": 1557733771853 } ] }
? correlationId              *******************
t ecs.version                1.0.1
t host.name                  *****
t input.type                 log
t log.file.path              *****
# log.offset                 747,788
? processInfo.domainId       *******************
? processInfo.groupId        group-2
? processInfo.groupName      ******
? processInfo.hostname       f3slsea310
? processInfo.serviceId      instance-6
? processInfo.serviceName    ******
? processInfo.version        7.6.2 SP1
suricata.eve.timestamp       Oct 28, 2019 @ 12:22:06.610
? timestamp                  1557733771854

Как вы можете видеть, в тот момент, когда Filebeat попадает во вложенный массив «circuitPath», он разбирает все в одном поле до тех пор, пока массив не будет закрыт.

Вот пример одного из журналов, которые мы имеемпроблема с:

{"timestamp":1557733646862,"correlationId":"***************","processInfo":{"hostname":"f3slsea310","domainId":"*******************","groupId":"group-2","groupName":"*****","serviceId":"instance-6","serviceName":"*******","version":"7.6.2 SP1"},"circuitPath":[ { "policy": "Health Check LB", "execTime": 0, "filters": [  { "espk": "PrimaryStore-43595d15-05f6-4135-aa9a-e8b9b2a35bda:-439438454261778670", "name": "Compare Attribute", "type": "CompareAttributeFilter", "class": "com.vordel.circuit.attribute.CompareAttributeFilter", "status": "Pass", "filterTime": 1557733646861, "execTime": 0 } , { "espk": "PrimaryStore-43595d15-05f6-4135-aa9a-e8b9b2a35bda:-6704867506249825459", "name": "Set Message - OK", "type": "ChangeMessageFilter", "class": "com.vordel.circuit.conversion.ChangeMessageFilter", "status": "Pass", "filterTime": 1557733646861, "execTime": 0 } , { "espk": "PrimaryStore-43595d15-05f6-4135-aa9a-e8b9b2a35bda:-5308572925601299001", "name": "Reflect - OK", "type": "ReflectFilter", "class": "com.vordel.circuit.net.ReflectFilter", "status": "Pass", "filterTime": 1557733646861, "execTime": 0 }  ] } ]}

Filebeat.yml

processors:
   - decode_json_fields:
       fields: [message]
       process_array: true
       max_depth: 11
       overwrite_keys: true
...