0

我有存储在 json 文件中的测试结果。然后我让 logstash 找到该文件并尝试将所有行发送到 elasticsearch。只有大约一半的行被发送并且无法弄清楚为什么某些行被遗漏了。例如,将有 34 行,但只发送了 14 行。

input {
    file {
        path => "/data/*.json"
        start_position => "beginning"
    }
}

# ----------------------------------------------------------------------

filter {

    # Parse fields out of JSON message, then remove the raw JSON. 
    json {
        source => "message"
    }

}

# ----------------------------------------------------------------------

output {
    elasticsearch {
        hosts => ["host:9200", "localhost:9200"]
        index => "ct-%{+YYYY.MM.dd}"
    }
    stdout { codec => rubydebug }

我不确定json本身是否存在导致logstash跳过它的内容,或者我在上面发布的logstash.conf文件是否有问题。

4

1 回答 1

0

Logstash 计算不同类型的文件,以 Json 格式发送到 elasticsearch。在您的情况下,具有弹性搜索输出的 Filebeat 代理足以将 json 文件发送到 ES 并对其进行索引。

使用 Filebeat 6.x 看起来像这样:

#=========================== Filebeat inputs =============================

filebeat.inputs:

- type: log
  # Paths to the logs
  paths:
    - "/your/path/to/your/logs/file.json"
  # tags to identify the logs source, .gz files excluded from the prospector
  tags: ["beats","yourtag"]
  exclude_files: ['\.gz$']

#================================ Outputs =====================================
#----------------------------- Elasticsearch output --------------------------------
output.elasticsearch:
  # The ES host & index name
  hosts: ["yourEShost:9200"]
  index: "ct-%{+YYYY.MM.dd}"
于 2019-04-19T08:41:47.057 回答