# Issue with posting json data to elastic search via Flume

**URL:** <https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953>\
**Category:** Elasticsearch\
**Created:** [April 11, 2014, 11:44am UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953 "2014-04-11T11:44:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepakas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepakas/32/697_2.png) [@deepakas](https://discuss.elastic.co/u/deepakas)\
**Post date:** [April 11, 2014, 11:44am UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/1 "2014-04-11T11:44:23Z")

</div>

I am using Flume to post data to ElasticSearch. When the data is xml it  
works fine. But when the data is json it is loading incorrect data in the  
message field.I checked the flume code. It looks like the issue may be with  
the elasticsearch code XContentBuilder.

Instead of JSON message it is storing message data as  
"org.elasticsearch.common.xcontent.XContentBuilder@32f4122e"

I tried using the DynamicSerializer and  
ElasticSearchIndexRequestBuilderFactory but no luck.

Here is the sample data posted on Elastic Search when the data loaded is  
JSON.

{

"\_index": "test\_flume-2014-04-07",

"\_type": "logs",

"\_id": "M9E-33RQTy2kA6QhW6mSUw",

"\_score": null,

"\_source": {

"@message": "org.elasticsearch.common.xcontent.XContentBuilder@58bf76d2",

"@timestamp": "2014-04-07T09:49:26.490Z",

"@fields": {

"timestamp": "1396864166490"

}

},

"sort": [

1396864166490,

1396864166490

]

--  
Deepak Subhramanian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CA%2BUubig41Nk%3DDkXK3H5WL8ceKHrEp%2B8%2BtQvFDDTq9Lz0Sa5ohA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CA%2BUubig41Nk%3DDkXK3H5WL8ceKHrEp%2B8%2BtQvFDDTq9Lz0Sa5ohA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [April 11, 2014, 7:01pm UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/2 "2014-04-11T19:01:49Z")

</div>

Deepak,

> 

The output you see is likely calling the XContentBuilder._to_String method.

The output you want (the JSON string) is obtained by calling the  
XContentBuilder.string method instead.

Brian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7649ebf5-254b-4411-9d90-99bde1941208%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7649ebf5-254b-4411-9d90-99bde1941208%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![esbium](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@esbium](https://discuss.elastic.co/u/esbium)\
**Post date:** [April 17, 2014, 2:45am UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/3 "2014-04-17T02:45:57Z")

</div>

Deepak, any update on whether or not the suggestion worked for you?

---

<div class="post-metadata">

**Author:** ![saad373](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saad373/32/1596_2.png) [@saad373](https://discuss.elastic.co/u/saad373)\
**Post date:** [May 1, 2014, 6:08pm UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/4 "2014-05-01T18:08:11Z")

</div>

Hi,

Can you please suggest where to add this code. We have setup ES sink in flume.conf and data is pused to ElasticSearch.

---

<div class="post-metadata">

**Author:** ![deepakas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepakas/32/697_2.png) [@deepakas](https://discuss.elastic.co/u/deepakas)\
**Post date:** [May 8, 2014, 3:01pm UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/5 "2014-05-08T15:01:06Z")

</div>

I was on vacation . I am looking into it now. Thanks.

---

<div class="post-metadata">

**Author:** ![deepakas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deepakas/32/697_2.png) [@deepakas](https://discuss.elastic.co/u/deepakas)\
**Post date:** [May 8, 2014, 5:28pm UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/6 "2014-05-08T17:28:48Z")

</div>

The temporary fix helped. I can now see the JSON message instead of seeing data as ""org.elasticsearch.common.xcontent.XContentBuilder@32f4122e" .  
There is a JIRA also on the issue. [https://issues.apache.org/jira/browse/FLUME-2126](https://issues.apache.org/jira/browse/FLUME-2126)

From Hive when I load JSON data it automatically splits JSON fields to different columns. For some reason the ESSink doesnt load in the same way. I am not sure if I am setting the correct type. There is a parameter es.input.json I have to set to true in hive table . Is there any similar variable I have to set for ESSink .I set some headers as application/json. But no luck. Here is the data I am getting in KIbana.

{  
"\_index": "test-2014-05-08",  
"\_type": "parsed\_logs",  
"\_id": "7qSBgRx-Q\_GLaCDWARs\_Cg",  
"\_score": null,  
"\_source": {  
"@message": "{"action":{"id":"00001"}}",  
"@timestamp": "2014-05-08T16:48:44.180Z",  
"@type": "application/json",  
"@fields": {  
"\_attachment\_mimetype": "application/json",  
"timestamp": "1399567724180",  
"\_type": "application/json",  
"type": "application/json"  
}  
},  
"sort": [  
1399567724180  
]  
}

---

<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, 1:30am UTC](https://discuss.elastic.co/t/issue-with-posting-json-data-to-elastic-search-via-flume/16953/7 "2017-07-06T01:30:43Z")

</div>


