본문 바로가기
프로그래밍/ELK

[ElasticSearch] 로그 수집 안되는 문제

by 뽀도 2021. 6. 11.

문제

  • 갑자기 로그가 수집이 안되는 현상이 발생 

 

 

 

원인

  • logstash 로그를 확인해보았는데, 아래와 같은 로그가 찍혀있었다. 
  • 샤드 개수 부족이었다.
- [logstash.outputs.elasticsearch][main] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"인덱스인덱스인덱스", :routing=>nil, :_type=>"_doc"}, #], :response=>{"index"=>{"_index"=>"인덱스인덱스인덱스", "_type"=>"_doc", "_id"=>nil, "status"=>400, "error"=>{"type"=>"validation_exception", "reason"=>"Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [999]/[1000] maximum shards open;"}}}}

total shards, but this cluster currently has [999]/[1000] maximum shards open;

 

 

 

파악

  • postman을 사용해서 아래의 url로 send 한다. 

  • [GET] http://localhost:9200/_cluster/settings?include_defaults&flat_settings 
  • 이때 localhost 부분에 elasicsearch 장비가 설정된 ip 주소를 입력하면 된다. 

"cluster.max_shards_per_node" 값이 기본 1000으로 설정되어있었다. 

 

 

 

 

해결

 

 

  • postman을 켠다.

method: 'put' 

주소 : http://localhost:9200/_cluster/settings 


Body 

"persistent": { "cluster.max_shards_per_node""3000" } }


설정하여 [Send]하여 shard 개수를 늘리고, logstash를 재시작 한다.

 

 

 

 

결과

[GET] http://localhost:9200/_cluster/settings?include_defaults&flat_settings 를 사용하여 다시 확인해보면 

shard가 3000개로 바뀐것을 확인할 수 있다.

 

  "cluster.max_shards_per_node": "3000"

{
    "persistent": {
        "action.destructive_requires_name": "true",
        "cluster.max_shards_per_node": "3000"
    },
    "transient": {},
    "defaults": {
       ............. (생략)
    }
}

 

그리고 다시 로그 수집이 정상화되었다. 

 

 

반응형

댓글