Filebeat 可以将 JSON 字段而不是整个 JSON 对象解析为 kibana 吗?

the*_*e88 2 json elasticsearch logstash kibana filebeat

我能够在 Kibana 中获取单个 JSON 对象:

在此输入图像描述

通过将其放入 filebeat.yml 文件中:

output.elasticsearch:
  hosts: ["localhost:9200"]
Run Code Online (Sandbox Code Playgroud)

如何获取 JSON 字符串中的各个元素。假设我想比较所有 JSON 对象的所有“伪范围”字段。我会怎样:

  1. 从我的所有 JSON 消息中选择“pseudorange”字段来比较它们。
  2. 在 kibana 中直观地比较它们。目前我什至找不到该消息,更不用说可视化选项卡中的各个字段了......

我听说有人使用 Logstash 以某种方式解析字符串,但是有没有办法简单地使用 filebeat 来做到这一点?如果没有,那么我该如何使用 Logstash 来帮助过滤 json 中的各个字段,而不是让我的消息只是一个我无法与之交互的大 json 字符串?

我从 output.console 得到以下输出,请注意我将一些信息放入 <> 中以隐藏它:

  "@timestamp": "2021-03-23T09:37:21.941Z",
  "@metadata": {
    "beat": "filebeat",
    "type": "doc",
    "version": "6.8.14",
    "truncated": false
  },
  "message": "{\n\t\"Signal_data\" : \n\t{\n\t\t\"antenna type:\" : \"GPS\",\n\t\t\"frequency type:\" : \"GPS\",\n\t\t\"position x:\" : 0.0,\n\t\t\"position y:\" : 0.0,\n\t\t\"position z:\" : 0.0,\n\t\t\"pseudorange:\" : 20280317.359730639,\n\t\t\"pseudorange_error:\" : 0.0,\n\t\t\"pseudorange_rate:\" : -152.02620448094211,\n\t\t\"svid\" : 18\n\t}\n}\u0000",
  "source": <ip address>,
  "log": {
    "source": {
      "address": <ip address>
    }
  },
  "input": {
    "type": "udp"
  },
  "prospector": {
    "type": "udp"
  },
  "beat": {
    "name": <ip address>,
    "hostname": "ip-<ip address>",
    "version": "6.8.14"
  },
  "host": {
    "name": "ip-<ip address>",
    "os": {
      <ubuntu info>
    },
    "id": <id>,
    "containerized": false,
    "architecture": "x86_64"
  },
  "meta": {
    "cloud": {
      <cloud info>
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Val*_*Val 5

在 Filebeat 中,您可以利用decode_json_fields处理器来解码 JSON 字符串并将解码后的字段添加到根对象中:

processors:
  - decode_json_fields:
      fields: ["message"]
      process_array: false
      max_depth: 2
      target: ""
      overwrite_keys: true
      add_error_key: false
Run Code Online (Sandbox Code Playgroud)