Splunk Search

extract only xml part from an event

eranhauser
Path Finder

Hi,
my event has unstructured data i.e. few strings than xml part than few more strings and another xml follow by few more strings.
How do I extract only the xml parts from the event when there is no pattern  to the string i.e. number of lines before and after the xml nor the string content has a pattern.

 

 

Tags (1)
0 Karma

eranhauser
Path Finder

it loos like
this is the first line
this is the second line

<!DOCTYPE....>

......... the rest of the xml is here

this is the third line

<!DOCTYPE...>

.......rest of the xml is here

this is the fourth line

this is the fifth line

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Is there any word or some token how you know where first xml part will ends or is it just end of line and then 3rd line is some other text?

0 Karma

eranhauser
Path Finder

I am trying to get values from xml part of an event. The event starts with few lines than it has xml part, after that few more lines and another xml part. I want to extract at first only the parts of the event that are in xml format.

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

until you give some sample data to us, it’s hard to tell exactly how to do it. Here is some ideas how to proceed with this case

...
| rex "....(?<yourXML>....until it ends)...."
| fields _time yourXML
| xmlkv maxinputs=99999 yourXML
....

r. Ismo

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

We need more information. Are you trying to extract at search time or index time?  Are you trying keep the XML or discard it?  Please share a sanitized sample event or two.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...