Logstash erstellt keinen Index in Elasticsearch

Logstash erstellt keinen Index in Elasticsearch

Ich habe dieses Tutorial von Digital Ocean zur Installation eines ELK-Stacks auf einer CentOS 7-Maschine befolgt.

Digital Ocean ELK-Setup CentOS

Es sah ziemlich gut aus und brachte mich soweit, dass ein anfänglicher Elastic Search-Knoten richtig funktionierte und Kibana 4 hinter NGINX lief. Aber bei der Installation von Logstash stieß ich auf ein Problem, bei dem scheinbar keine Indizes in Elasticsearch erstellt wurden!! Ich bin sicher, dass es irgendwo ein Konfigurationsproblem ist. Aber wo, weiß ich nicht!

Mir fällt auf, dass Logstash keine Indizes erstellt hat, wenn ich nach dem Neustart von Logstash die Elasticsearch-Indizes mit der _cat-API auswerte.

curl http://localhost:9200/_cat/indices
yellow open .kibana  1 1 1 0 2.4kb 2.4kb
yellow open security 5 1 0 0  575b  575b

Hier haben wir den Index von Kibana und einen, wie ich glaube, standardmäßigen ES-Index namens „Sicherheit“. Aber anscheinend kommuniziert Logstash nicht mit ES! Und alles läuft auf derselben Maschine.

Dies sind die Versionen von ES und LS, die ich installiert habe:

elasticsearch-1.5.2-1.noarch
logstash-1.5.1-1.noarch
logstash-forwarder-0.4.0-1.x86_64

Und so wie es in dem Tutorial, das ich befolgt habe, eingerichtet ist, gehen drei Konfigurationsdateien in das Logstash-Verzeichnis conf.d.

In /etc/logstash/conf.d/01-lumberjack-input.conf habe ich:

  lumberjack {
    port => 5000
    type => "logs"
    ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"
    ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"
  }
}

In /etc/logstash/conf.d/10-syslog.conf habe ich:

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => [ "received_at", "%{@timestamp}" ]
      add_field => [ "received_from", "%{host}" ]
    }
    syslog_pri { }
    date {
      match => [ "syslog_timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
    }
  }
}

Ich habe auch meine eigene Konfiguration von meinem vorherigen Logstash-Server, die ich in eine Datei namens 20-logstash.conf eingefügt habe, die auf Port 2541 lauscht:

Ich habe Folgendes in /etc/logstash/conf.d/20-logstash.conf

input {


   lumberjack {
       # The port to listen on
       port => 2541

       # The paths to your ssl cert and key
        ssl_certificate => "/etc/pki/tls/certs/lumberjack.crt"
        ssl_key => "/etc/pki/tls/private/lumberjack.key"

         # Set this to whatever you want.
         type => "logstash"
         codec => "json"
       }
}


filter {
   if [type] == "postfix" {
      grok {
            match => [ "message", "%{SYSLOGBASE}", "timestamp", "MMM dd HH:mm:ss" ]
            add_tag => [ "postfix", "grokked" ]
      }
   }
}


filter {
   if [type] == "system" {
      grok {
            match => [ "message", "%{SYSLOGBASE}" ]
            add_tag => [ "system", "grokked" ]
      }
   }
}

filter {
   if [type] == "syslog" {
      grok {
            match => [ "message", "%{SYSLOGBASE}" ]
            add_tag => [ "syslog", "grokked" ]
      }
   }
}


filter {
   if [type] == "security" {
      grok {
            match => [ "message", "%{SYSLOGBASE}" ]
            add_tag => [ "security", "grokked" ]
      }
   }
}



output {

  stdout {
           #debug => true
           #debug_format => "json"
    }

  elasticsearch {
    host => "logs.mydomain.com"
  }
}

Und in /etc/logstash/conf.d/30-lumberjack-output.conf habe ich eine Ausgabe, die an ES geht:

output {
  elasticsearch { host => localhost }
  stdout { codec => rubydebug }
}

Und jetzt, nachdem ich Logstash erneut neu gestartet habe, sehe ich, dass Logstash auf den Ports lauscht, die ich in der Konfiguration angegeben habe:

[root@logs:/etc/logstash] #lsof -i :5000
COMMAND   PID     USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    23893 logstash   16u  IPv6 11665234      0t0  TCP *:commplex-main (LISTEN)
[root@logs:/etc/logstash] #lsof -i :2541
COMMAND   PID     USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    23893 logstash   18u  IPv6 11665237      0t0  TCP *:lonworks2 (LISTEN)

Zum jetzigen Zeitpunkt läuft Logstash und erzeugt keine Protokollausgabe:

#ps -ef | grep logstash | grep -v grep
logstash 23893     1 16 11:49 ?        00:01:45 /bin/java -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=/var/lib/logstash -Xmx500m -Xss2048k -Djffi.boot.library.path=/opt/logstash/vendor/jruby/lib/jni -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=/var/lib/logstash -Xbootclasspath/a:/opt/logstash/vendor/jruby/lib/jruby.jar -classpath : -Djruby.home=/opt/logstash/vendor/jruby -Djruby.lib=/opt/logstash/vendor/jruby/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main --1.9 /opt/logstash/lib/bootstrap/environment.rb logstash/runner.rb agent -f /etc/logstash/conf.d -l /var/log/logstash/logstash.log

ls -lh /var/log/logstash/logstash.log
-rw-r--r--. 1 logstash logstash 0 Jun 22 11:49 /var/log/logstash/logstash.log

Aber in Elasticsearch wurden immer noch keine Indizes erstellt:

#curl http://localhost:9200/_cat/indices
yellow open .kibana  1 1 1 0 2.4kb 2.4kb
yellow open security 5 1 0 0  575b  575b

Und wenn ich Kibana konfiguriere, heißt es, dass mit „logstash-*“ keine Muster zum Suchen gefunden werden können.

Wie kann ich das jetzt zum Laufen bringen? Die Konfigurationen selbst sind unverändert, seit ich sie Ihnen zuvor gezeigt habe.

Ich habe nicht versucht, irgendwelche Logstash-Weiterleitungen darauf hinzuweisen, aber ich habe versucht, mit diesem Befehl stdin in den Elasticsearch-Cluster zu schreiben:

logstash -e 'input { stdin { } } output { elasticsearch { host => localhost } }'

Und ich habe diesen Fehler zurückbekommen:

`Got error to send bulk of actions: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];[SERVICE_UNAVAILABLE/2/no master]; {:level=>:error}
Failed to flush outgoing items {:outgoing_count=>1, :exception=>org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];[SERVICE_UNAVAILABLE/2/no master];, :backtrace=>["org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException(org/elasticsearch/cluster/block/ClusterBlocks.java:151)", "org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedRaiseException(org/elasticsearch/cluster/block/ClusterBlocks.java:141)", "org.elasticsearch.action.bulk.TransportBulkAction.executeBulk(org/elasticsearch/action/bulk/TransportBulkAction.java:210)", "org.elasticsearch.action.bulk.TransportBulkAction.access$000(org/elasticsearch/action/bulk/TransportBulkAction.java:73)", "org.elasticsearch.action.bulk.TransportBulkAction$1.onFailure(org/elasticsearch/action/bulk/TransportBulkAction.java:148)", "org.elasticsearch.action.support.TransportAction$ThreadedActionListener$2.run(org/elasticsearch/action/support/TransportAction.java:137)", "java.util.concurrent.ThreadPoolExecutor.runWorker(java/util/concurrent/ThreadPoolExecutor.java:1142)", "java.util.concurrent.ThreadPoolExecutor$Worker.run(java/util/concurrent/ThreadPoolExecutor.java:617)", "java.lang.Thread.run(java/lang/Thread.java:745)"], :level=>:warn}`

Irgendwelche Ideen, was passiert sein könnte?

verwandte Informationen