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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...