# Bulk messages sent through Logstash are stored a message

**URL:** https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265
**Category:** Logstash
**Created:** [June 1, 2018, 6:42pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265 "2018-06-01T18:42:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![paulo.leao](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@paulo.leao](https://discuss.elastic.co/u/paulo.leao)
#### Post date: [June 1, 2018, 6:42pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265/1 "2018-06-01T18:42:47Z")

</div>

Hello Everyone,

I developed a powershell script to send message in bulk to Elastiseach using the Invoke-RestMethod command.

When I send a bulk request directly to Elasticsearch, I can see the properties of my json object stored in the source field.

> <https://gist.github.com/591573/e93b7138d702e120dbf8eb42437b29bd>

However, when I use logstash in the middle, the json object gets stored in the message field as string.

> <https://gist.github.com/591573/18e34c8e22b753124075a6871a161e63>

I`ve already read this discussing [here](https://discuss.elastic.co/t/how-to-send-json-directly-to-elasticsearch-w-o-any-parsing-in-logstash/123331), but I am still confused.

How I can send bulk messages through Logstash so that they I will get correctly store on ElasticSearch?

Thank for you help

---

<div class="post-metadata">

### Author: ![paulo.leao](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@paulo.leao](https://discuss.elastic.co/u/paulo.leao)
#### Post date: [June 1, 2018, 7:29pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265/2 "2018-06-01T19:29:01Z")

</div>

I forgot to mention how I am sending data through logstash

Here is the powershell command I am using to send messages:

Invoke-RestMethod -Uri ($uri + '/\_bulk') -Method POST -ContentType 'application/x-ndjson' -Body $jsonObjectToSend

---

<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: [June 3, 2018, 8:24pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265/3 "2018-06-03T20:24:11Z")

</div>

I'm assuming you're using an http input. Set its codec option to json.

---

<div class="post-metadata">

### Author: ![paulo.leao](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@paulo.leao](https://discuss.elastic.co/u/paulo.leao)
#### Post date: [June 18, 2018, 5:54pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265/4 "2018-06-18T17:54:03Z")

</div>

Yes, I am. But I have already solved this problem.

input {  
http {  
port =\> "5001"  
codec =\> "json"  
}  
}  
filter{  
json {  
source =\> "message"  
remove\_field =\> ["message"]  
}

```
    mutate{
            remove_field => ["headers","message"]
    }

```

}

output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
index =\> "logstash-windows-filereport-%{+YYYY.MM.dd}"  
user =\> "username"  
password =\> "password"  
}  
#stdout{}  
}

---

<div class="post-metadata">

### Author: ![paulo.leao](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@paulo.leao](https://discuss.elastic.co/u/paulo.leao)
#### Post date: [June 18, 2018, 5:54pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265/5 "2018-06-18T17:54:22Z")

</div>

Thank you

---

<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 16, 2018, 5:54pm UTC](https://discuss.elastic.co/t/bulk-messages-sent-through-logstash-are-stored-a-message/134265/6 "2018-07-16T17:54:27Z")

</div>

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