elasticsearch 使用logstash解析json数组字符串,elasticsearch,logstash,logstash-configuration,elasticsearch,Logstash,Logstash Configuration" /> elasticsearch 使用logstash解析json数组字符串,elasticsearch,logstash,logstash-configuration,elasticsearch,Logstash,Logstash Configuration" />

elasticsearch 使用logstash解析json数组字符串

elasticsearch 使用logstash解析json数组字符串,elasticsearch,logstash,logstash-configuration,elasticsearch,Logstash,Logstash Configuration,我想使用logstash解析这个json {“name”:“bob”,“last”:“builder”,“atts”:“{\“a\”:111,\“b\”:222}” { “name”=>“bob”, “上一个”=>“生成器” “atts”=>{ “a”=>111, “b”=>222} 两个选择 使用Logstash解析JSON 如果您想使用logstash解析JSON-请参考此处的logstash插件: 要实现这一点,您需要使用logstash.conf的过滤器部分: filter {

我想使用logstash解析这个json

{“name”:“bob”,“last”:“builder”,“atts”:“{\“a\”:111,\“b\”:222}”

{ “name”=>“bob”, “上一个”=>“生成器” “atts”=>{ “a”=>111, “b”=>222}

两个选择

使用Logstash解析JSON

如果您想使用logstash解析JSON-请参考此处的logstash插件:

要实现这一点,您需要使用logstash.conf的过滤器部分:

filter {
   json {
     source => "message"
   }
}
该链接中有更多的json解码示例

使用Filebeat解析JSON

您的另一个选择是在json进入日志存储之前在filebeat端对其进行解码。相关链接:

下面是针对这种情况的filebeat.yml示例:

filebeat.inputs:
  - type: log
    paths:
      - 'path to the log directory you want to track'
    enter code here
    input_type: log
    json.keys_under_root: true
    json.add_error_key: true
    fields:
        log_type: 'type of log'

    processors:
    - decode_json_fields:
        fields: ["message"]
        process_array: true

    - add_tags:
        tags:
            - 'tag in elastic'

filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml

setup.template.settings:
  index.number_of_shards: 1

output.logstash:
  # The Logstash hosts
  hosts: ["where logstash is running"]
  index: 'your index'

  codec.json:
    pretty: true
    escape_html: false

#================================ Processors =====================================
# Configure processors to enhance or manipulate events generated by the beat.
processors:
- decode_json_fields:
    fields: ["message"]
    process_array: true

成功了。

两个选项

使用Logstash解析JSON

如果您想使用logstash解析JSON-请参考此处的logstash插件:

要实现这一点,您需要使用logstash.conf的过滤器部分:

filter {
   json {
     source => "message"
   }
}
该链接中有更多的json解码示例

使用Filebeat解析JSON

您的另一个选择是在json进入日志存储之前在filebeat端对其进行解码。相关链接:

下面是针对这种情况的filebeat.yml示例:

filebeat.inputs:
  - type: log
    paths:
      - 'path to the log directory you want to track'
    enter code here
    input_type: log
    json.keys_under_root: true
    json.add_error_key: true
    fields:
        log_type: 'type of log'

    processors:
    - decode_json_fields:
        fields: ["message"]
        process_array: true

    - add_tags:
        tags:
            - 'tag in elastic'

filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml

setup.template.settings:
  index.number_of_shards: 1

output.logstash:
  # The Logstash hosts
  hosts: ["where logstash is running"]
  index: 'your index'

  codec.json:
    pretty: true
    escape_html: false

#================================ Processors =====================================
# Configure processors to enhance or manipulate events generated by the beat.
processors:
- decode_json_fields:
    fields: ["message"]
    process_array: true


成功了。

请添加有关您的用例的更多详细信息。那我们就可以帮你了。并添加您尝试过的示例。请添加有关您的用例的更多详细信息。那我们就可以帮你了。并添加您尝试过的示例。