Splunk Search

Field extraction in XML (need some regex assistance)

efelder0
Communicator

I am extracting a field out of an XML feed. More specifically, this is the field:
2012-01-30T12:57:20/x:LastUpdated

I need some assistance on manipulating my regex statement in props.conf to force the output to look like this:

2012-01-30 12:57:20

Here is what is in my props.conf:
EXTRACT-Last_Updated = (?i)(?P[^<]+)

Any suggestions?

Tags (1)
0 Karma
1 Solution

FunPolice
Path Finder

Pulling the time and date out as two separate fields would possibly require the least processing, if that suits:

EXTRACT-Last_Updated = (?i)<x:lastupdated>(?P<last_updated_date>[^T]+)T(?P<last_updated_time>[^<]+)

Maybe then you could concatenate them if necessary.

View solution in original post

0 Karma

clintsharp
Explorer

It doesn't change the regex statement, it changes the rest of your search. After you've extracted both fields, if you want them formatted in the way you're wanting, simply do something like:

<yoursearch> | eval last_updated_dt=last_updated_date+" "+last_updated_time

That will give you a field with the formatting you're looking for while remaining flexible having the time and date separated as FunPolice suggested.

0 Karma

efelder0
Communicator

OK, that works.. However, I need to invoke a space between the 2 fields. I believe \s will work here. how does that change the regex statement?

0 Karma

FunPolice
Path Finder

Pulling the time and date out as two separate fields would possibly require the least processing, if that suits:

EXTRACT-Last_Updated = (?i)<x:lastupdated>(?P<last_updated_date>[^T]+)T(?P<last_updated_time>[^<]+)

Maybe then you could concatenate them if necessary.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...