# Changing xml console output

**URL:** <https://discuss.elastic.co/t/changing-xml-console-output/209356>\
**Category:** Logstash\
**Created:** [November 25, 2019, 6:18pm UTC](https://discuss.elastic.co/t/changing-xml-console-output/209356 "2019-11-25T18:18:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcb](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@kcb](https://discuss.elastic.co/u/kcb)\
**Post date:** [November 25, 2019, 6:18pm UTC](https://discuss.elastic.co/t/changing-xml-console-output/209356/1 "2019-11-25T18:18:58Z")

</div>

We have a logstash script that successfully parses xml files. Our output displays in format:  
geo =\> {  
"service" =\> "abc"  
"version: =\> "1.1.1"  
...  
}

Is it possible to get rid of the "geo" in the display, so the display is instead  
"service" =\> "abc"  
"version" =\> "1.1.1"  
...

Our logstash configuration file is:

input {  
file {  
path =\> "D:/temp/geoserver\_audit\_\*.log"  
sincedb\_path =\> "nul"  
start\_position =\> "beginning"  
type =\> "xml"  
codec =\> multiline {  
pattern =\> "\<Request "  
negate =\> true  
what =\> "previous"  
auto\_flush\_interval =\> 1  
}  
}  
}

filter {  
if [message] =~ /\<?xml/ { drop {} }  
mutate { gsub =\> ["message", "\<(/)?Requests\>", ""] }

```
xml 
{
    source => "message"
    target => "geo"
	store_xml => true
	force_array => false
}

ruby {
	code => '
		x = event.get("geo")
		if x
			x.each { |k, v|
				newk = k.gsub(/(?!^)([A-Z])/, "_\\1")
				newk = newk.downcase
				event.remove("[geo][#{k}]")
				event.set("[geo][#{newk}]", v)
			}
		end
	'
}
mutate {
  remove_field => [tags, host, message, path]
}

```

}

output {  
stdout {  
codec =\> rubydebug  
}

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [November 25, 2019, 6:26pm UTC](https://discuss.elastic.co/t/changing-xml-console-output/209356/2 "2019-11-25T18:26:20Z")

</div>

> [@kcb](#):
>
> event.set("[geo][#{newk}]", v)

If you change that to

```
event.set("[#{newk}]", v)

```

that should do what you want.

---

<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:** [December 23, 2019, 6:26pm UTC](https://discuss.elastic.co/t/changing-xml-console-output/209356/3 "2019-12-23T18:26:27Z")

</div>

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