[Logstash] input file start_position => "end"

Elastic/Logstash 2017. 8. 17. 11:20

먼저 앞서 기술한 input file 에 대한 내용을 먼저 읽어 보시면 이해 하시는데 도움이 됩니다.


※ [Logstash] input file plugin 에 대해서 알아 봅니다.


이전 글은 데이터 유실 방지를 위한 설정과 input file 의 주요 설정 정보에 대해서 알아 봤습니다.

이번 글에서는 반대로 start_position => "end" 로 했을 때 왜 데이터가 유실 되는지 간략하게 살펴 보겠습니다.


설정)

input {

  file {

    path => "/xxxx/logs/test-file.log"

    start_position => "end"

    stat_interval => 1

  }


  file {

    path => "/xxxx/logs/test-file1.log"

    start_position => "end"

    stat_interval => 10

  }

}


output {

    stdout {

      codec => "rubydebug"

    }

}


첫 번째 실행)

$ bin/logstash -f config/test-file.conf


첫번째 실행 후 sincedb)

189766986 1 4 3675


두 번째 실행)

$ bin/logstash -f config/test-file.conf


두번째 실행 후 sincedb)

189766986 1 4 4065


보시는 것 처럼 start_position => "end"로 했을 경우 해당 파일의 end byte offset 정보를 기록하게 됩니다.

이후 sincedb  정보는 변경이 되지 않게 됩니다.

logstash 를 중지 하고 재실행 합니다.

그 동안 test-file.log 에는 계속 데이터가 누적 되도록 하였습니다.

두 번째 실행 된 후 sincedb 값을 확인해 보면 변경 되어 있는 것을 볼 수 있습니다.


이와 같이 첫 번째 offset 정보와 두 번째 offset 정보의 차이 만큼 데이터가 유실 되게 되는 것입니다.


: