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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Casting Call: Compete in Cyber Games

Lights, Camera, SecOps: Apply to Compete in Cyber Games     Think you have what it takes to beat the clock? ...

Data Management Digest – June 2026

Welcome to the June 2026 edition of Data Management Digest! This month’s update is short and sweet, with a ...

Think Like an Architect: Introducing the Splunk Certified Cybersecurity Defense ...

In cybersecurity, defenders respond to threats. Architects design the systems that stop them.    As ...