# How to read json file as input and index the data using elasticsearch as output?

**URL:** <https://discuss.elastic.co/t/how-to-read-json-file-as-input-and-index-the-data-using-elasticsearch-as-output/79997>\
**Category:** Logstash\
**Created:** [March 25, 2017, 4:38pm UTC](https://discuss.elastic.co/t/how-to-read-json-file-as-input-and-index-the-data-using-elasticsearch-as-output/79997 "2017-03-25T16:38:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sowji\_Sowjanya](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Sowji\_Sowjanya](https://discuss.elastic.co/u/Sowji_Sowjanya)\
**Post date:** [March 25, 2017, 4:38pm UTC](https://discuss.elastic.co/t/how-to-read-json-file-as-input-and-index-the-data-using-elasticsearch-as-output/79997/1 "2017-03-25T16:38:34Z")

</div>

Hi,

I have a file having Json data. I have an index "company" and document-type as "employee" present in my local elasticsearch server. I am unable to index the data from the file and send it to elasticsearch server.

**config file name** : logstash\_test.conf  
**content in config file:**  
input{  
file {  
path =\> "/opt/test.log"  
type =\> "json"  
start\_position =\> "beginning"  
codec =\> "json"  
}  
}

output {  
elasticsearch { hosts =\> ["localhost:9200"]  
index =\> "company"  
document\_type =\> "employee"  
document\_id =\> "%{@timestamp}"  
}  
stdout { codec =\> rubydebug }  
}

**My json data file content is:**  
{{"first\_name":"r1","last\_name":"j1","dob":"1922-05-09"},  
{"first\_name":"r2","last\_name":"j2","dob":"1944-05-09"}}

Please help me out in resolving this issue.

---

<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:** [March 27, 2017, 7:32am UTC](https://discuss.elastic.co/t/how-to-read-json-file-as-input-and-index-the-data-using-elasticsearch-as-output/79997/2 "2017-03-27T07:32:16Z")

</div>

Have you checked the Logstash logs for clues? To debug, comment out the elasticsearch output so rule out one error source. It's quite likely that Logstash is tailing the log file, in which case deleting the sincedb file or setting `sincedb_path` to /dev/null will help. Read the file input documentation to learn more about 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:** [April 24, 2017, 7:32am UTC](https://discuss.elastic.co/t/how-to-read-json-file-as-input-and-index-the-data-using-elasticsearch-as-output/79997/3 "2017-04-24T07:32:25Z")

</div>

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