我有2台安装了文件拍子的服务器,在另一台服务器上装有ELK堆栈。
在Logstash conf目录下的ELK服务器上,我创建了代表2个服务器的2个文件
在两台服务器上,在filebeat配置文件中,我为每台服务器指定了不同的端口(Logstash作为输出)
这是我的服务器1的Logstash文件,
$ behave -f plain
Feature: User Login only actually happens once
Background: User Login
Scenario: User clicks Home
Logging user in for the first time
Given the user is logged in ... passed in 0.000s
The user clicked the Home button
When the user clicks the Home button ... passed in 0.000s
The Home page is being shown
Then the Home page is shown ... passed in 0.000s
Scenario: User clicks About
The user is already logged in, will not log in again
Given the user is logged in ... passed in 0.000s
The user clicked the About button
When the user clicks the About button ... passed in 0.000s
The About page is being shown
Then the About page is shown ... passed in 0.000s
1 feature passed, 0 failed, 0 skipped
2 scenarios passed, 0 failed, 0 skipped
6 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.001s
这是我的服务器2的Logstash文件,
input {
beats {
port => 5044
}
}
output {
if "api_logs" in [tags] {
elasticsearch {
hosts => [ "es:9200" ]
index => "api_logs-%{+YYYY.MM.dd}"
}
}
else if "error_logs" in [tags] {
elasticsearch {
hosts => [ "es:9200" ]
index => "error_logs-%{+YYYY.MM.dd}"
}
}
}
我的服务器1的filebeat文件
input {
beats {
port => 5045
}
}
output {
if "api_logs" in [tags] {
elasticsearch {
hosts => [ "es:9200" ]
index => "api_logs-%{+YYYY.MM.dd}"
}
}
else if "error_logs" in [tags] {
elasticsearch {
hosts => [ "es:9200" ]
index => "error_logs-%{+YYYY.MM.dd}"
}
}
}
我的服务器2的文件拍拍文件
filebeat.inputs:
- type: log
tags: ["api_logs"]
enabled: true
paths:
- logs/api*
- type: log
tags: ["error_logs"]
enabled: true
paths:
- logs/error*
output.logstash:
hosts: ["es:5044"]
但是当我在Kibana中创建索引时,它仅显示一个服务器日志,而不显示另一台服务器(在host.name字段下)。
请提出一些建议。
答案 0 :(得分:0)
配置中没有明显的错误,如果它适用于一台服务器,那么它也应该适用于另一台服务器,所以我怀疑这是一个配置错误的问题。
我认为最好查看服务器之间的差异,并确保它们的配置完全相同。
检查以下内容: