# Strange JSON Codec Behavior

**URL:** <https://discuss.elastic.co/t/strange-json-codec-behavior/110570>\
**Category:** Logstash\
**Created:** [December 6, 2017, 7:55pm UTC](https://discuss.elastic.co/t/strange-json-codec-behavior/110570 "2017-12-06T19:55:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![code\_diva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/code_diva/32/25135_2.png) [@code\_diva](https://discuss.elastic.co/u/code_diva)\
**Post date:** [December 6, 2017, 7:55pm UTC](https://discuss.elastic.co/t/strange-json-codec-behavior/110570/1 "2017-12-06T19:55:30Z")

</div>

Hi,  
I have been using logstash for quite some time and I have never seen behavior quite like this. I am attributing it to the JSON codec because I have never used it before. When I run logstash with the information below, the JSON data is fetched and can even be pushed to elastic just fine, however, logstash does not stop the pipeline automatically as it normally does. Also, If I do not delete the "data" folder and all its contents (including the sincedb files) after each time I run it, logstash does not fetch any data from the json file and just goes into the "pushing flush onto pipeline" loop (shown below). I find this very puzzling.  
.conf:  
input {  
file {  
start\_position =\> "beginning"  
path =\> "/home/username/logstash-5.6.4/bin/sql-to-elastic.json"  
codec =\> "json"  
}  
}  
output { stdout { codec =\> rubydebug } }

JSON:  
[{"NAME":"A","SIZE":"2"},{"NAME":"B","SIZE":"3"},{"NAME":"C","SIZE":"4"},{"NAME":"D","SIZE":"5"}]

Command: ./logstash -w 1 -f json-test2.conf --verbose --debug

Strange Output loop after data is fetched (it also pushes to elastic just fine when I try that):  
[2017-12-06T12:58:44,871][DEBUG][logstash.pipeline] Pushing flush onto p  
ipeline  
[2017-12-06T12:58:49,872][DEBUG][logstash.pipeline] Pushing flush onto p  
ipeline  
[2017-12-06T12:58:54,199][DEBUG][logstash.inputs.file] \_globbed\_files: /hom  
e/username/logstash-5.6.4/bin/sql-to-elastic.json: glob is: ["/home/username/logst  
ash-5.6.4/bin/sql-to-elastic.json"]  
[2017-12-06T12:58:54,877][DEBUG][logstash.pipeline] Pushing flush onto p  
ipeline  
[2017-12-06T12:58:59,877][DEBUG][logstash.pipeline] Pushing flush onto p  
ipeline  
[2017-12-06T12:59:04,878][DEBUG][logstash.pipeline] Pushing flush onto p  
ipeline  
[2017-12-06T12:59:09,231][DEBUG][logstash.inputs.file] \_globbed\_files: /hom  
e/username/logstash-5.6.4/bin/sql-to-elastic.json: glob is: ["/home/username/logst  
ash-5.6.4/bin/sql-to-elastic.json"]

...And it just goes on an on like that until I kill the process. The log file contains the same information.

My goal is for logstash to shut down the pipeline on its own normally without me killing the process and to not have to delete my data folder and all its contents every time.

If anyone has an insight, I would be very appreciative.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 6, 2017, 8:48pm UTC](https://discuss.elastic.co/t/strange-json-codec-behavior/110570/2 "2017-12-06T20:48:58Z")

</div>

> however, logstash does not stop the pipeline automatically as it normally does.

Logstash doesn't shut down itself when using the file input.

> Also, If I do not delete the "data" folder and all its contents (including the sincedb files) after each time I run it, logstash does not fetch any data from the json file and just goes into the "pushing flush onto pipeline" loop (shown below).

Have you added any new data to the JSON files? Or replaced them? Or what's the scenario, i.e. why do you want Logstash to process the file again?

---

<div class="post-metadata">

**Author:** ![code\_diva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/code_diva/32/25135_2.png) [@code\_diva](https://discuss.elastic.co/u/code_diva)\
**Post date:** [December 6, 2017, 9:03pm UTC](https://discuss.elastic.co/t/strange-json-codec-behavior/110570/3 "2017-12-06T21:03:49Z")

</div>

oh ok awesome I didn't know that. I was always using it against SQL before.

I am just in the setup phase of my logstash/elastic design. I have a java project which generates JSON files which logstash then feeds to elastic. I needed to stop logstash and then run it again because I am in the process of editing my .conf file and I like to test its output to make sure I am on the right track. When I am satisfied with my conf file, I was going to have the Java project delete and replace the JSON file that logstash uses. Maybe in this case I should just keep adding onto the same file though...

(The data that the java generates keeps getting updated and that is why i need to run both that and logstash multiple times so that the elastic data can get updated as well 😀 )

Thanks!

---

<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:** [January 3, 2018, 9:07pm UTC](https://discuss.elastic.co/t/strange-json-codec-behavior/110570/5 "2018-01-03T21:07:44Z")

</div>

Closed on January 3, 2018, 9:07pm UTC

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