【问题标题】:Issue while sending file content from filebeat to logstash将文件内容从 filebeat 发送到 logstash 时出现问题
【发布时间】:2017-05-10 05:46:09
【问题描述】:

我是 ELK 的新手,我正在尝试使用 ELK 堆栈进行一些动手操作。我在 WINDOWS 上执行以下操作, 1.安装Elasticsearch,确认http://localhost:9200/ 2. 安装logstash,使用http://localhost:9600/确认 logstash -f logstash.config

    logstash.config file looks like this,
    input {
        beats {
            port => "5043"
        }
    }
    # The filter part of this file is commented out to indicate that it is
    # optional.
    # filter {
    #
    # }
    output {
        elasticsearch { hosts => ["localhost:9200"] }
    }


 3. Installed Kibana, confirmed using http://localhost:5601

    Now, i want to use filebeat to pass a log file to logstash which parses and forwards it to Elastic search for indexing. and finally kibana displays it.

    In order to do that, 
"

i did the following changes in filebeat.yml.
change 1 :
In Filebeat prospectors, i added 
paths:
    # - /var/log/*.log
     - D:\KibanaInput\vinod.log
Contents of vinod.log: Hello World from FileBeat.

Change 2:
In Outputs,
#output.logstash:
  # The Logstash hosts
   hosts: ["localhost:9600"]

when i run the below command,
filebeat  -c filebeat.yml -e

i get the below error,
ERR Connecting error publishing events (retrying): Failed to parse JSON response: json: cannot unmarshal string into Go value of type struct { Number string }

Please let me know what mistake i am doing.

【问题讨论】:

  • 你添加了 - input_type: log 吗?
  • 是的。在 filebeat.yml 中,它在那里..
  • 我修改了logstash.config文件如下,输入{beats { input_type: log port => "5043" } } filter { grok { match => ["message"] } } output { elasticsearch { hosts => ["localhost:9200"] } } 并将 vinod.log 的内容修改为 "message":"Hello World from FileBeat" .. 现在我没有看到任何错误。但我没有看到 kibana 中反映的内容。

标签: logstash elastic-stack filebeat


【解决方案1】:

你走在一条好路上。

请确认以下内容:

  1. 在您的 filebeat.yml 中,确保您在 output.logstash: 行中没有与您的更改编号 2 相对应的注释。
  2. 确保您的消息被正确理解。在您的 logstash 管道配置文件中添加以下输出。

    输出{ 标准输出 { 编解码器 => json } }

    3.在调试模式下启动您的logstash。

    4.如果您正在读取具有相同内容的相同文件,请确保删除 filebeat 中的注册表文件。 ($filebeatHome/data/registry)

    5.读取日志文件。

【讨论】:

  • 您好,感谢您的信息。是的, output.logstash 行已被评论,现在可以正常工作了。我有几个疑问,
  • 我现在收到以下错误,2017/05/10 11:40:26.828016 single.go:91: INFO Error publishing events (retrying): lumberjack protocol error
  • 如果我评论 output.logstash: 并且只使用 output.elasticsearch:,那么它工作正常。日志中的任何更改都反映在 kibana .但是如果我评论 output.elasticsearch: 并使用 output.logstash:,那么我会遇到以下错误,2017/05/10 12:12:29.767016 sync.go: 85:ERR 无法发布事件导致:lumberjack 协议错误 2017/05/10 12:12:29.767016 single.go:91:INFO 发布事件错误(重试):lumberjack 协议错误请让我知道我在做什么错误
  • 您确定 logstash 已启动并正在运行吗?您在 logstash 日志中看到任何日志错误吗?你安装 X-Pack 吗?或者从您的 filebeat 到 logstash 进行任何身份验证?
  • 好的。我发现了你的问题。只需将 filebeat.yml 中的以下行 hosts: ["localhost:9600"] 修改为 hosts: ["localhost:5043"] 即可。并将答案标记为正确。
猜你喜欢
  • 2017-04-08
  • 2019-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-25
相关资源
最近更新 更多