无法将 Filebeat 连接到 logstash 以使用 ELK 进行日志记录

Unable to connect Filebeat to logstash for logging using ELK

您好,我一直在使用弹性堆栈进行自动日志记录。我有 filebeat 从路径读取日志,输出设置为端口 5044 上的 logstash。 logstash 配置有一个监听 5044 的输入和推送到 localhost:9200 的输出。问题是我无法让它工作,我不知道发生了什么。以下是文件:

我的filebeat.yml路径:etc/filebeat/filebeat.yml

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- input_type: log

# Paths that should be crawled and fetched. Glob based paths.
paths:
- /mnt/vol1/autosuggest/logs/*.log
#- c:\programdata\elasticsearch\logs\*
<other commented stuff>
#----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
hosts: ["10.10.XX.XX:5044"]

# Optional SSL. By default is off.
<other commented stuff>

我的logstash.yml路径:etc/logstash/logstash.yml

<other commented stuff>
path.data: /var/lib/logstash
<other commented stuff>
path.config: /etc/logstash/conf.d
<other commented stuff>

# ------------ Metrics Settings --------------
#
# Bind address for the metrics REST endpoint
#
http.host: "10.10.XX.XX"
#
# Bind port for the metrics REST endpoint, this option also accept a range
# (9600-9700) and logstash will pick up the first available ports.
#
# http.port: 9600-9700
<other commented stuff>
path.logs: /var/log/logstash
<other commented stuff>

我的logpipeline30aug.config文件路径:/usr/share/logstash

input {
  beats {
  port => 5044
  }
}

filter {
  grok {
match => { "message" => "\A%{TIMESTAMP_ISO8601:timestamp}%{SPACE}%{WORD:var0}%{SPACE}%{NOTSPACE}%{SPACE}(?<searchinfo>[^#]*)#(?<username>[^#]*)#(?<searchQuery>[^#]*)#(?<latitude>[^#]*)#(?<longitude>[^#]*)#(?<client_ip>[^#]*)#(?<responseTime>[^#]*)" }
  }
}

output {
   elasticsearch {
      hosts => ["http://localhost:9200"]
      index => "logstash30aug2017"
      document_type => "log"
   }
}

请注意: Elasticsearch, logstash, filebeat 都安装在同一台机器上,ip: 10.10.XX.XX 我已经检查了防火墙,这不是问题当然可以。

查了一下logstash,filebeat服务都是运行。 Filebeat 在配置时能够将数据推送到 elasticsearch,而 logstash 在配置时能够将数据推送到 elasticsearch。


也许这是我执行流程的方式问题.. 我在 /usr/share/logstash 中执行 bin/logstash -f logpipeline30aug.config 来启动它,然后我从根目录执行 /etc/init.d/filebeat start

请注意:由于 Whosebug 格式问题,格式可能会受到影响

有人可以帮忙吗?从 3 天以来,我一直在尝试一切,我也浏览了文档

您的 filebeat.yml 看起来无效。

输出部分缺少缩进:

output.logstash:
  hosts: ["10.10.XX.XX:5044"]

一般来说,检查配置文件的正确性以确保它们没问题。

例如,对于filebeat,你可以运行:

filebeat -c /etc/filebeat/filebeat.yml -configtest

如果您有任何错误,它会解释错误是什么,以便您可以修复它。

您也可以对其他 ELK 服务使用类似的方法