hi, im facing an issue with logstash while inserting json data to elasticsearch.
here is my logstash config file
input
{
file
{
codec => multiline
{
pattern => '^{'
negate => true
what => previous
}
path => ["/usr/local/Cellar/logstash/5.1.1/test_payment.json"] start_position => "beginning" sincedb_path => "/dev/null" codec => "json" }
}
filter
{
mutate
{
replace => [ "message", "%{message}" ]
gsub => [ 'message','\n','']
}
if [message] =~ /^{.*}$/
{
json { source => message }
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
user => elastic
password => techno2013
index => "test_payment"
}
stdout { codec => rubydebug }
}
then, this is my json file
{
"user_id":0,
"cart_id":"81746",
"error_status":"",
"error_message":"",
"data":{
"ord_id":218308,
"cart":{
"cart_id":"81746",
"session_id":"7afaaf7fac9bb934de4c6ecb2567461a6178495e",
"ip_address":"180.254.65.91",
"usr_id":"0",
"created_date":"2017-01-19 17:29:20",
"updated_date":"2017-01-19 18:08:35"
},
"cart_data":{
"coupon_code":"",
"ord_email":"shanti.swaragama@gmail.com",
"ord_firstname":"adhe",
"ord_lastname":"shanti",
"ord_address_line1":"Radio Swaragama, Komplek Bulaksumur Blok H No 5",
"ord_address_line2":"",
"country_id":"1",
"prov_id":"9",
"city_id":"45",
"ord_postcode":"55281",
"ord_phone":"082227369636",
"dif_addr":null,
"rec_name":"",
"rec_address_line1":"",
"rec_address_line2":"",
"rec_country":"1",
"rec_prov":"10",
"rec_city":"0",
"rec_postcode":"",
"rec_phone":"",
"wrap_type":"1",
"psncard_type":null,
"psncard_message":null,
"currency":"IDR",
"currency_value":1,
"language":"en",
"is_mobile":"0",
"ord_shp_fee":18000,
"ord_shp_mode":"reg",
"ord_py_mode":"transfer",
"newtoken":"",
"cc_credit_option":null,
"cc_saved_bank":"",
"cc_saved_period":"",
"cc_savecc":null,
"cc_saved_no":null,
"cc_savedccv":null,
"cc_new_bank":"",
"cc_new_period":"",
"cc_newcc1":"",
"cc_newcc2":"",
"cc_newcc3":"",
"cc_newcc4":"",
"cc_newexp1":"",
"cc_newexp2":"",
"cc_newccv":""
},
"cart_detail":[
{
"cadet_id":"179977",
"cart_id":"81746",
"stk_id":"5240",
"cadet_qty":"1",
"cadet_data":"",
"pd_id":"4890",
"pd_name":"Denim Odette",
"pd_shortdesc":"Cut-out Shoulders Top",
"pd_price":"249000.00",
"pd_img_primary":"DenimOdette_260916_04.jpg",
"color_id":"145",
"pd_special":"0",
"pd_sale":"0",
"pd_weight":"0.15",
"color_name":"Blue Jeans",
"color_thumbnail":"Blue-Jeans.jpg",
"size_id":"40",
"size_name":"Size L",
"size_shortname":"L",
"cat_name":"Tops",
"cat_id":"6",
"sub_id":"16",
"sub_name":"Short Sleeved",
"str_coll_id":"2"
}
],
"order_summary":{
"err_status":false,
"err_msg":"",
"subtotal":249000,
"promotion":0,
"wrapping":0,
"shipping":18000,
"total":267000,
"total_weight":0.15,
"coupon_code":"",
"coupon_type":"",
"boledisc":0,
"arrboledisc":[
], "bolefreeship":249000, "boleinstallment":249000, "shipping_code":"reg" }
}
}
when i try running logstash -f logstash.conf
all data successfully insert to elasticsearch, but the problem is
i only got the structure of json data, the value of its json not inserted to elasticsearch.
for example i have this json file
{"foo":"foo value", "bar": "bar value"}
{"hello":"world", "goodnight": "moon"}
when i insert to elasticsearch, i only got foo, and bar, im not get foo value and bar value.
the question is, how can i inserted object and value to elasticsearch.
im confused.
please help me.