Filebeat - как анализировать вложенный объект json на уровне управления - decode_json_fields - PullRequest
0 голосов
/ 24 января 2019

как я могу контролировать уровень из decode_json_fields?

max_depth, кажется, не помогает в моем случае.

цель: парсинг '/ var / lib /docker / Containers / / .log ', но с контролем максимальной глубины json (не для создания сотен вложенных полей в индексе эластичного поиска)

name: "host-01"
queue:
  mem:
    events: 16384
    # batch of events to the outputs. "0" ensures events are immediately available to be sent to the outputs.
    flush.min_events: 0


filebeat:
  prospectors:
    - type: log
      paths:
       - '/tmp/test.log'
      json:
        # key on which to apply the line filtering and multiline settings
        message_key: log
        keys_under_root: true
        add_error_key: true
      processors:
      - decode_json_fields:
          fields: ["log"]
          process_array: false
          max_depth: 1
          overwrite_keys: false

output:
  console:
    pretty: true

Пример

echo '{"log":"{ "status": { "foo": { "bar": 1 } }, "bytes_sent": "0", "gzip_ratio": "-", "hostname": "cb7b5441f0da" }\n","stream":"stdout","time":"2018-12-29T11:25:36.130729806Z"}' >> /tmp/test.log

Фактический результат:

{
...
  "log": {
    "status": {
      "foo": {
        "bar": 1
      }
    },
    "bytes_sent": "0",
    "gzip_ratio": "-",
    "hostname": "cb7b5441f0da"
...
}

Ожидаемый результат:

{
...
  "log": {
    "status": "{  \"foo\": { \"bar\": 1 } }"
   },
  "bytes_sent": "0",
  "gzip_ratio": "-",
  "hostname": "cb7b5441f0da"
...
}

Как управлять вложенными объектами json?

Вот некоторые объяснения https://github.com/elastic/beats/issues/9834#issuecomment-451134008 1, но удалениеjson: и оставить только decode_json_fields не помогает

сшить для обсуждения .elastic.co https://discuss.elastic.co/t/filebeat-how-control-level-nested-json-object-parsing-decode-json-fields/162876

...