Splunk Search

How can I extract SOAP envelope from raw data using rex

msmit205
New Member

I would like to use a rex so I can pull the SOAP Envelope out of raw text and then send it to xmlprettyprint. Can anyone help me with the rex statement that would extract just the soap envelope from the example raw text below?

{"severity":"DEBUG","logger":"org.mule.module.http.internal.HttpMessageLogger","thread":"[dmvproxy-1.0.2-RELEASE].HTTP_Listener_Configuration.worker.790","message":"LISTENER\nPOST \/inolrsproxy HTTP\/1.1\r\nContent-Type: text\/xml; charset=UTF-8\r\nAccept: *\/*\r\nUser-Agent: Apache CXF 3.1.4\r\nX-Takipi-SN: 18480\r\nCache-Control: no-cache\r\nPragma: no-cache\r\nHost: dmv-proxy.dmv-proxy.rancher.internal:8081\r\nConnection: keep-alive\r\nContent-Length: 3413\r\n\r\n<soap:Envelope xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\"><soap:Body><test>testvalue<\/test><\/soap:Body><\/soap:Envelope>"}
0 Karma
1 Solution

elliotproebstel
Champion

Sure. I'd use this:
... | rex field=_raw "(?<soap_envelope><soap:Envelope.*\/soap:Envelope>)"

If you also want it to remove all the extra escape characters, you could add this to the end:
| rex mode=sed field=soap_envelope "s/\\\//g"

Here's where I tested the first part of the regex:
https://regex101.com/r/3SO9zD/1

View solution in original post

0 Karma

elliotproebstel
Champion

Sure. I'd use this:
... | rex field=_raw "(?<soap_envelope><soap:Envelope.*\/soap:Envelope>)"

If you also want it to remove all the extra escape characters, you could add this to the end:
| rex mode=sed field=soap_envelope "s/\\\//g"

Here's where I tested the first part of the regex:
https://regex101.com/r/3SO9zD/1

0 Karma

msmit205
New Member

Thanks for the quick reply. When I run this search in the browser, I still get the standard result with TIME and EVENT columns, and the EVENT looks the same as it did before. How can I get the browser to display just the Soap that has been extracted by rex?

0 Karma

elliotproebstel
Champion

If you only want to display the value of the soap_envelope fields, you can append this to your search:
| stats values(soap_envelope) AS soap_envelope

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...