# Logstash es\_bulk codec only processing last event

**URL:** https://discuss.elastic.co/t/logstash-es-bulk-codec-only-processing-last-event/56771
**Category:** Logstash
**Created:** [July 29, 2016, 8:31pm UTC](https://discuss.elastic.co/t/logstash-es-bulk-codec-only-processing-last-event/56771 "2016-07-29T20:31:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![esds2000](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@esds2000](https://discuss.elastic.co/u/esds2000)
#### Post date: [July 29, 2016, 8:31pm UTC](https://discuss.elastic.co/t/logstash-es-bulk-codec-only-processing-last-event/56771/1 "2016-07-29T20:31:09Z")

</div>

Trying send bulk index request through a logstash pipeline using the http input with es\_bulk codec. Having an issue where only the last event in the payload is being passed through. Sending the same payload to elasticsearch directly works fine. Tried

Sample payload stored in data.json:  
{ "index" : { "\_index" : "test", "\_type" : "type1", "\_id" : "1" } }  
{ "field1" : "value1" }  
{ "index" : { "\_index" : "test", "\_type" : "type1", "\_id" : "2" } }  
{ "field1" : "value2" }

Sample logstash config:  
input {  
http {  
port =\> 8080  
codec =\> es\_bulk  
}  
}  
filter {}  
output {  
file {  
path =\> "/tmp/logstash.txt"  
}  
}

Post:  
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-binary "@data.json" localhost:8080/\_bulk

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [July 31, 2016, 12:29am UTC](https://discuss.elastic.co/t/logstash-es-bulk-codec-only-processing-last-event/56771/2 "2016-07-31T00:29:42Z")

</div>

Do you have `\n` on the end of the lines?  
[https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-bulk.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-bulk.html)

---

<div class="post-metadata">

### Author: ![esds2000](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@esds2000](https://discuss.elastic.co/u/esds2000)
#### Post date: [August 1, 2016, 6:46pm UTC](https://discuss.elastic.co/t/logstash-es-bulk-codec-only-processing-last-event/56771/3 "2016-08-01T18:46:32Z")

</div>

Yes, I'm using the data-binary flag with a text file so the new lines are preserved (From [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-bulk.html:](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-bulk.html:) "If you’re providing text file input to curl, you must use the --data-binary flag instead of plain -d. The latter doesn’t preserve newlines. Example:"). Also, the command works fine going straight to elastic and I've captured the raw payload and everything looks right. Just not sure what is missing with the logstash listener.

---

<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 6, 2017, 4:45am UTC](https://discuss.elastic.co/t/logstash-es-bulk-codec-only-processing-last-event/56771/4 "2017-07-06T04:45:31Z")

</div>


