# Represent logstash output in proper json format

**URL:** <https://discuss.elastic.co/t/represent-logstash-output-in-proper-json-format/152185>\
**Category:** Logstash\
**Created:** [October 12, 2018, 7:58am UTC](https://discuss.elastic.co/t/represent-logstash-output-in-proper-json-format/152185 "2018-10-12T07:58:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [October 12, 2018, 7:58am UTC](https://discuss.elastic.co/t/represent-logstash-output-in-proper-json-format/152185/1 "2018-10-12T07:58:45Z")

</div>

How to represent logstash output in proper json format

 ![station](https://us1.discourse-cdn.com/elastic/original/3X/e/8/e8d2188d3f38179dfb3ad93c9843e5597dca1b4c.png)

event name represents station name, event id represent station id.  
How can i combine them to get proper json data

My conf file:

input {  
file {  
path =\> "D:/ELK-stack/stations.xml"  
start\_position =\> "beginning"  
sincedb\_path =\> "NUL"  
codec =\> multiline {  
pattern =\> "|"  
negate =\> true  
what =\> "previous"  
auto\_flush\_interval =\> 1  
}  
}  
}

filter {  
if [message] == "" or [message] == "" {  
drop {}  
}  
xml {  
source =\> "message"  
target =\> "message.parsed"  
xpath =\> [  
"/stations/station/id/text()", eventid ,  
"/stations/station/name/text()", eventname  
]  
force\_array =\> false  
}  
}

output {  
stdout { codec =\> rubydebug }  
}

My Xml file:

.stations\>  
.\station\>  
.id\>5 ./id\>  
.name\>Aurora Hills Community Ctr/18th - Hayes St . /name\>  
./station\>  
.station\>  
.id\>6  
.name\>Pentagon City Metro / 12th - S Hayes St ./name\>  
./station\>  
./stations\>

Please help me

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [October 12, 2018, 3:23pm UTC](https://discuss.elastic.co/t/represent-logstash-output-in-proper-json-format/152185/2 "2018-10-12T15:23:36Z")

</div>

output { stdout { codec =\> json } }

🙂

---

<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:** [November 9, 2018, 3:23pm UTC](https://discuss.elastic.co/t/represent-logstash-output-in-proper-json-format/152185/3 "2018-11-09T15:23:39Z")

</div>

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