Kibana在通过Logstash发送的2台服务器中仅显示1台服务器日志

时间:2019-08-01 14:49:41

标签: elasticsearch logstash kibana filebeat elk

我有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字段下)。

请提出一些建议。

1 个答案:

答案 0 :(得分:0)

配置中没有明显的错误,如果它适用于一台服务器,那么它也应该适用于另一台服务器,所以我怀疑这是一个配置错误的问题。

我认为最好查看服务器之间的差异,并确保它们的配置完全相同。

检查以下内容:

  • 从两台服务器(尤其是发生故障的服务器)通过文件拍到Logstash服务器和端口的连接
  • 比较两个服务器上的日志文件的文件权限
  • 在filebeat和logstash上启用INFO登录,并尝试查看是否有任何突出之处
  • 确保版本与两台服务器上的Beats和ELK兼容(https://www.elastic.co/support/matrix#matrix_compatibility