Knowledge Management

Field extraction not working with transforms and props

lclayton95
Loves-to-Learn Everything

I am trying to extract some field values that comes in the following format

<date>00-mon-year</date>
<DisplayName>example</DisplayName>

<Hostname>example</Hostname>

 

When using the spl rex function i am able to extract the fields using 

rex field=_raw "Hostname>(?<hostname>.*)<".

 

Then i have tried to use both a inline regex function in props with the same regex (without quotes) and it does not work. I have also used a transforms.conf with the stanza as follows

[hostname]

FORMAT = Hostname::$1

REGEX =  Hostname>(?<hostname>(.*?))</Hostname

 

then in the props

REPORT -Hostname = hostname

 

and this does not work.

 

However, i have another source that pulls the same type of logs and i am able to use inline regex in spl format just fine with no issues. This issue is only specific to this source which i have as

[source::/opt/*]

 

Any ideas on this fix?

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

It's best to put sample data and configs in code blocks so the formatting is retained.

You say you tried an inline regex in props.   Would you please share that?  The transform shared looks like it should have worked.  Please confirm the sourcetype in inputs.conf matches that in props.conf.

You have a source that works - how does that working config differ from the non-working one?  Please share the complete stanzas so we can spot any differences.

---
If this reply helps you, Karma would be appreciated.
0 Karma

lclayton95
Loves-to-Learn Everything

In my indexes.conf there isn't a stanza specified for source type the lines i have are

[example]

coldPath

coldToFrozenDir

enableDataIntergrity

homePath

thawedpath

 

The index in the props.conf that works is

 

[source::C:\\examplelogs*]

EXTRACT-logs = Hostname>(?<hostname>(.*?))</Hostname
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Sourcetypes should match between inputs.conf and props.conf, except when props are specified for hosts or sources rather than sourcetypes.  The indexes.conf file does not use sourcetypes.

The regex needs an escape character before the /.  Also, the expression has two capture groups so make sure $1 is the group you expect.  Or use a single group.

Hostname>(?<hostname>.*?)<\/Hostname
---
If this reply helps you, Karma would be appreciated.
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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...