# How to insert Data to Elasticsearch using Logstash?

**URL:** https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130
**Category:** Logstash
**Created:** [June 13, 2017, 2:16am UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130 "2017-06-13T02:16:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![amruth](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@amruth](https://discuss.elastic.co/u/amruth)
#### Post date: [June 13, 2017, 2:16am UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/1 "2017-06-13T02:16:03Z")

</div>

Hi, I am trying to insert data to Elasticsearch using Logstash. I created an index 'twitter' and my config file is as follows,

input{  
file{  
path=\>"C:/Users/Sample.log"  
codec=\>json  
}  
}  
output{  
stdout{  
codec=\>rubydebug  
}

```
elasticsearch {  
hosts => "13.10.256.10:9200"
 index => "twitter"
}

```

}

I could see the logs in command prompt but when I checked elasticsearch with the API '[http://13.10.256.10:9200/\_cat/indices?v](http://13.10.256.10:9200/_cat/indices?v)', it's showing docs.count as 0. What wrong am I doing? Do I need to create any other fields other than index? Please help me on this issue.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 13, 2017, 5:04am UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/2 "2017-06-13T05:04:30Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

I moved your question to #logstash.  
May be share the output of logstash and of your curl command?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [June 13, 2017, 5:11am UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/3 "2017-06-13T05:11:25Z")

</div>

The [file input plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html#plugins-inputs-file) by default tails the file, so if it was created before Logstash was started you will need to set `start_position` to `beginning` and also delete the sincedb file, as this will have recorded the current file as processed.

---

<div class="post-metadata">

### Author: ![amruth](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@amruth](https://discuss.elastic.co/u/amruth)
#### Post date: [June 13, 2017, 3:28pm UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/4 "2017-06-13T15:28:20Z")

</div>

Hi David,

Thanks for your quick reply. Please see my logstash output and output of elasticsearch.

Logstash:

{  
"CheckTS" =\> 1496264400085,  
"path" =\> "C:/Users/Sample.log",  
"@timestamp" =\> 2017-06-13T13:49:01.335Z,  
"VersionTag" =\> 0,  
"@version" =\> "1",  
"host" =\> "localhost",  
"location" =\> "abc",  
"Component" =\> "mongodb",  
"Application" =\> "Test"  
}  
{  
"CheckTS" =\> 1496264400085,  
"path" =\> "C:/Users/Sample.log",  
"@timestamp" =\> 2017-06-13T13:49:01.335Z,  
"VersionTag" =\> 0,  
"@version" =\> "1",  
"host" =\> "localhost",  
"location" =\> "abc",  
"Component" =\> "sql",  
"Application" =\> "Test1"  
}

Elasticsearch:

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size  
yellow open twitter BcDQCs7uRWunz39AavLAVg 3 2 0 0 477b 477b

---

<div class="post-metadata">

### Author: ![amruth](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@amruth](https://discuss.elastic.co/u/amruth)
#### Post date: [June 13, 2017, 3:30pm UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/5 "2017-06-13T15:30:27Z")

</div>

Hi Christian, I don't have problem with start\_position, because I am able to see all my results in the command prompt output. The only problem is I can't see when I check it in the elasticsearch index.

---

<div class="post-metadata">

### Author: ![amruth](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@amruth](https://discuss.elastic.co/u/amruth)
#### Post date: [June 14, 2017, 5:46pm UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/6 "2017-06-14T17:46:05Z")

</div>

I got it solved. Logstash is running from 2 different folders and that made the mess.

---

<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: [July 12, 2017, 5:46pm UTC](https://discuss.elastic.co/t/how-to-insert-data-to-elasticsearch-using-logstash/89130/7 "2017-07-12T17:46:12Z")

</div>

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