Getting Data In

How do I rename xml fields in props.conf?

cphair
Builder

I have a file of XML-like events that look like this:

<Event Field1=foo Field2=bar Field3=baz >
    <Data Field4=whz Field5=zip Field3=floo/>
</Event>

Both the Event line and the Data line have a field named Field3, and they are automatically extracted as the same field in the search. Is there a way to prepend the first tag (i.e. either Event or Data) to the Field3 name so Splunk can tell they're distinct? Prepending Event or Data to all the field names would also work.

In props.conf:


[xml_sample]
SHOULD_LINEMERGE = true
DATETIME_CONFIG = NONE
BREAK_ONLY_BEFORE_DATE = false
BREAK_ONLY_BEFORE =]>
MUST_BREAK_AFTER =

0 Karma
1 Solution

chanfoli
Builder

I would disable the automatic key-value extractions with KV_MODE = none and then define your own regex based extractions which use the element names, "Event" and "Data" for example as anchors. If you don't know how to set up regex extractions in the config files, the interactive field extractor tool might help you at least get close to the regex you need if not the exact regex you need, depending on your data and how it responds to you removing the values it gets wrong, presuming it selects incorrect fields from other XML elements.

View solution in original post

gabetheISguy
Explorer

If its during search time, you can either use the mode=sed with a regular expression

For e.g.

| rex mode=sed "s///g"

OR I would use sedcmd in props.conf

SEDCMD-change_field = s///g

0 Karma

cphair
Builder

Regexing from the search interface isn't convenient when you have to do it for every search. SEDCMD replaces the raw data, and I just want to update the field names.

0 Karma

chanfoli
Builder

I would disable the automatic key-value extractions with KV_MODE = none and then define your own regex based extractions which use the element names, "Event" and "Data" for example as anchors. If you don't know how to set up regex extractions in the config files, the interactive field extractor tool might help you at least get close to the regex you need if not the exact regex you need, depending on your data and how it responds to you removing the values it gets wrong, presuming it selects incorrect fields from other XML elements.

cphair
Builder

I was hoping there was an easier way, but I guess this'll work. Thanks.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...