Here is my logstash config:
input {
file {
path => "/var/log/nginx/access.log"
codec => "json"
}
}
output {
elasticsearch {
hosts => ["https://10.0.5.132:9200"]
ssl => true
cacert => "/etc/logstash/logstash.crt"
user => "logstash"
password => "xxx"
index => "nginx-%{+yyyy.MM.dd}"
ilm_rollover_alias => "nginx"
ilm_pattern => "{now/d}-00001"
ilm_policy => "test"
}
}
When I start logstash, error occurs
Mar 31 19:21:41 ip-10-0-5-152 logstash[5757]: [2022-03-31T19:21:41,513][WARN ][org.logstash.execution.ShutdownWatcherExt] {"inflight_count"=>0, "stalling_threads_info"=>{"other"=>[{"thread_id"=>31, "name"=>"[main]>worker0", "current_call"=>"[...]/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/interval.rb:95:in `sleep'"}, {"thread_id"=>32, "name"=>"[main]>worker1", "current_call"=>"[...]/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/interval.rb:89:in `sleep'"}, {"thread_id"=>33, "name"=>"[main]>worker2", "current_call"=>"[...]/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/interval.rb:95:in `sleep'"}, {"thread_id"=>34, "name"=>"[main]>worker3", "current_call"=>"[...]/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/interval.rb:95:in `sleep'"}]}}
Mar 31 19:21:42 ip-10-0-5-152 logstash[5757]: [2022-03-31T19:21:42,232][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error {:url=>"https://10.0.5.132:9200/", :exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :message=>"Got response code '401' contacting Elasticsearch at URL 'https://10.0.5.132:9200/'"}
But I curl it success
root@ip-10-0-5-152:~# curl -H "Content-Type: application/json" --user logstash:xxx --cacert /etc/logstash/logstash.crt -XGET https://10.0.5.132:9200/_cat/nodes
10.0.5.132 23 87 3 0.00 0.02 0.05 hilmst - node_hot
10.0.5.168 44 82 0 0.00 0.00 0.00 chm * node_frozen
10.0.5.174 47 82 0 0.00 0.00 0.00 cm - node_cold
What's the problem?