# \[Logstash\] sincedbファイルに unknown 履歴が挿入されることに関して

**URL:** <https://discuss.elastic.co/t/logstash-sincedb-unknown/155972>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [November 9, 2018, 4:08am UTC](https://discuss.elastic.co/t/logstash-sincedb-unknown/155972 "2018-11-09T04:08:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![drifting\_school](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@drifting\_school](https://discuss.elastic.co/u/drifting_school)\
**Post date:** [November 9, 2018, 4:08am UTC](https://discuss.elastic.co/t/logstash-sincedb-unknown/155972/1 "2018-11-09T04:08:19Z")

</div>

■環境  
・Windows10  
・Logstash6.4.2

Logstashのinput-fileプラグインでファイルの監視中に

> [2018-11-09T12:16:50,332][WARN][filewatch.tailmode.processor] \>\>\> Rotation In Progress - inode change detected and original content is not fully read, file is closed and path points to new content {"watched\_file details"=\>"\<FileWatch::WatchedFile: @filename='4.txt', @state='rotation\_in\_progress', @recent\_states='[:watched, :watched]', @bytes\_read='0', @bytes\_unread='0', current\_size='25', last\_stat\_size='25', file\_open?='false', @initial=false, @sincedb\_key='unknown 0 0'\>"}

という警告が発生することがあります。  
何度か検証を繰り返している中で、警告が発生する前にsincedbファイルにsincedb\_keyの部分に 'unknown' という履歴が挿入されていることがわかりました。  
この状態になるとsincedbファイルが破損している状態になるのかファイルの読み込み位置が正しく判定されないファイルが発生する場合があります。

この問題により不正な情報がElasticsearchに転送される可能性があり情報を集めています。  
同様の問題に遭遇した方や原因、解決方法をご存知の方がいましたら情報をお願いします。

検証用に作成したconfファイルと手順です。

■ confファイル

> input {  
> file {  
> path =\> "D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/\*.txt"  
> start\_position =\> beginning  
> sincedb\_path =\> "./\_sincedb/test.db"  
> }  
> }  
> filter {  
> }  
> output {  
> stdout {  
> codec =\> line {  
> format =\> "event : %{path} =\> %{message}"  
> }  
> }  
> }

■検証用監視ファイル

> ファイル名 : \<数字\>.txt ※数字の部分を０~ 連番で用意  
> ファイルの中身 : this file name is \<数字\>.txt

■手順

1. cmd or psでlogstash起動 (logstash -f confファイル)
2. 監視フォルダに作成済みファイルをコピーする
3. ログに該当の警告"Rotation In Progress - ～"が表示されたらsincedbを確認する
4. 内部にunknownキーの履歴があることを確認する

■発生時のログ

> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/1.txt =\> this file name is 1.txt  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/2.txt =\> this file name is 2.txt  
> [2018-11-09T12:29:04,151][WARN][filewatch.tailmode.processor] \>\>\> Rotation In Progress - inode change detected and original content is not fully read, file is closed and path points to new content {"watched\_file details"=\>"\<FileWatch::WatchedFile: @filename='3.txt', @state='rotation\_in\_progress', @recent\_states='[:watched, :watched]', @bytes\_read='0', @bytes\_unread='0', current\_size='25', last\_stat\_size='25', file\_open?='false', @initial=false, @sincedb\_key='unknown 0 0'\>"}  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/3.txt =\> this file name is 3.txt  
> [2018-11-09T12:29:34,291][WARN][filewatch.tailmode.processor] \>\>\> Rotation In Progress - inode change detected and original content is not fully read, file is closed and path points to new content {"watched\_file details"=\>"\<FileWatch::WatchedFile: @filename='4.txt', @state='rotation\_in\_progress', @recent\_states='[:watched, :watched]', @bytes\_read='0', @bytes\_unread='0', current\_size='25', last\_stat\_size='25', file\_open?='false', @initial=false, @sincedb\_key='unknown 0 0'\>"}  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/4.txt =\> this file name is 4.txt  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/5.txt =\> this file name is 5.txt  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/6.txt =\> this file name is 6.txt  
> [2018-11-09T12:30:19,451][WARN][filewatch.tailmode.processor] \>\>\> Rotation In Progress - inode change detected and original content is not fully read, file is closed and path points to new content {"watched\_file details"=\>"\<FileWatch::WatchedFile: @filename='8.txt', @state='rotation\_in\_progress', @recent\_states='[:watched, :watched]', @bytes\_read='0', @bytes\_unread='0', current\_size='27', last\_stat\_size='27', file\_open?='false', @initial=false, @sincedb\_key='unknown 0 0'\>"}  
> [2018-11-09T12:30:19,453][WARN][filewatch.tailmode.processor] \>\>\> Rotation In Progress - inode change detected and original content is not fully read, file is closed and path points to new content {"watched\_file details"=\>"\<FileWatch::WatchedFile: @filename='9.txt', @state='rotation\_in\_progress', @recent\_states='[:watched, :watched]', @bytes\_read='0', @bytes\_unread='0', current\_size='27', last\_stat\_size='27', file\_open?='false', @initial=false, @sincedb\_key='unknown 0 0'\>"}  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/7.txt =\> this file name is 7.txt  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/7.txt =\>  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/2.txt =\> this file name is 2.txt  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/8.txt =\> this file name is 8.txt  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/8.txt =\>  
> event : D:/Elastic\_Kibana/logstash-6.4.2/\_testdata/9.txt =\>

---

<div class="post-metadata">

**Author:** ![drifting\_school](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@drifting\_school](https://discuss.elastic.co/u/drifting_school)\
**Post date:** [November 13, 2018, 9:09am UTC](https://discuss.elastic.co/t/logstash-sincedb-unknown/155972/2 "2018-11-13T09:09:35Z")

</div>

補足です。

上記再現手順時は、2.txtの履歴がsincedbに書き込まれた時に inode名が 'unknown' となっていました。  
その後はログの通りmessageが空のイベントがや重複したイベントがトリガーされます。

英語フォーラム、githubのissueなどを一通り探したのですが解決に至る情報は見つけられませんでした。  
（英語フォーラムには同様のトピックがありましたがリプライがないままクローズされていました）

引き続き情報のほどお願いします。

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [November 20, 2018, 3:42am UTC](https://discuss.elastic.co/t/logstash-sincedb-unknown/155972/3 "2018-11-20T03:42:07Z")

</div>

これは、同じファイルをコピーして、既存のファイルに上書きをしてるということでしょうか？

---

<div class="post-metadata">

**Author:** ![drifting\_school](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@drifting\_school](https://discuss.elastic.co/u/drifting_school)\
**Post date:** [November 20, 2018, 11:39pm UTC](https://discuss.elastic.co/t/logstash-sincedb-unknown/155972/4 "2018-11-20T23:39:35Z")

</div>

input-fileプラグインの監視対象パスに  
連番で用意した別々のファイルを一つずつコピー(移動)しています  
※sincedbファイルは削除して検証しています

また、ファイルは完成済みの状態でコピーされ  
監視対象になってから加筆されることはありません

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 18, 2018, 11:39pm UTC](https://discuss.elastic.co/t/logstash-sincedb-unknown/155972/5 "2018-12-18T23:39:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
