使用 X-Pack 写入 Elasticsearch 时的 Logstash "no such index error"

Logstash "no such index error" when writting to Elasticsearch with X-Pack

我已经设置了一个 版本 5 ELK 堆栈(使用 X-Pack)并且我使用了以下 logstash conf 文件,它似乎正确地解析了访问日志(如我所见它在输出中):

input {
  file {
    path => ["/path/to/access_log"]
    start_position => "beginning"
  }
}

filter {
    mutate { replace => { "type" => "apache_access" } }
    grok {
      match => { "message" => "%{COMBINEDAPACHELOG}" }
    }

  date {
    match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
  }
}

output {
  elasticsearch {
    hosts => ["127.0.0.1:9200"] 
    user => "elastic"
    password => "*****"
  }
  stdout { codec => rubydebug }
} 

但是 elasticsearch 输出 returns 404 ("no such index") error 无论我做什么,除非我尝试使用以下 curl 手动创建索引命令:

curl -XPUT 'elastic:******@localhost:9200/logstash-2016.09.28

[2016-11-02T17:30:09,535][WARN ][logstash.outputs.elasticsearch] Failed action. {:status=>404, :action=>["index", {:_id=>nil, :_index=>"logstash-2016.09.28", :_type=>"apache_access", :_routing=>nil}, 2016-09-28T11:50:32.000Z mypchost 10.2.33.155 - - [28/Sep/2016:14:50:32 +0300] "GET /MyApp/page HTTP/1.1" 302 - "http://myhttpserver/MyApp/page?22" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0" ], :response=>{"index"=>{"_index"=>"logstash-2016.09.28", "_type"=>"apache_access", "_id"=>nil, "status"=>404, "error"=>{"type"=>"index_not_found_exception", "reason"=>"no such index", "resource.type"=>"index_expression", "resource.id"=>"logstash-2016.09.28", "index_uuid"=>"na", "index"=>"logstash-2016.09.28"}}}}

没有自动创建索引可能是什么问题?

编辑: 从 ES 卸载 X-Pack 并重新 运行 logstash 完成了这项工作,即创建了一个索引。 现在我需要找出 X-Pack 的问题所在。

尝试修改您的 logstash 输出并尝试重新索引它。我可以看到您没有索引参数,您需要 logstash 文件来创建索引。

如果您使用 logstash 对其进行索引,则不必单独 运行 CURL 命令。这将自动创建索引。

output {
    elasticsearch {
        index => "yourindex"
    }

    stdout { codec => rubydebug }
}

显然它会抛出该错误,因为尚未创建索引。使用此 CURL curl 'yourhost:9200/_cat/indices?v' 运行 logstash 文件后,请检查您的索引是否已创建。上面的命令将列出所有索引。

最后,问题是由我在安装 X-Pack 软件包时添加的 elasticsearch.yml 中的以下行引起的 在麋鹿:

action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*