Splunk Search

Extract value from fields that are named the same

hippe21
Explorer

Here's some sample data:

appName=test-application projectId=unknown projectName=My Test, id=123, projectId=12345abcde000, file=testing, other data...

The issue I have is, the first projectId value is being auto extracted, therefore projectId=unknown. If I attempt to run anything against this data for projectId, unknown is always returned.

With this sample data having 2 fields with the exact same name, how can I extract the one I actually need (2nd projectId), which in this sample, would be projectId=12345abcde000?

Tags (3)
0 Karma
1 Solution

DalJeanis
Legend

First, you can (and should) set the extract for projectid to allow multiple extractions of the field. These two are the lines either or both of which may need to get added to the appropriate stanza in transforms.conf:

REPEAT_MATCH=TRUE
MV_ADD = TRUE

For more info, here's one example answer - https://answers.splunk.com/answers/484037/multi-value-field-extraction-propsconf-transformsc.html

Second, for items that have already been indexed, you can do this at search time -

| rex field=_raw "projectId=(?<projectId>\w+)\b" max_match=0
| eval projectId=mvfilter(NOT match(projectId,"unknown"))

View solution in original post

0 Karma

DalJeanis
Legend

First, you can (and should) set the extract for projectid to allow multiple extractions of the field. These two are the lines either or both of which may need to get added to the appropriate stanza in transforms.conf:

REPEAT_MATCH=TRUE
MV_ADD = TRUE

For more info, here's one example answer - https://answers.splunk.com/answers/484037/multi-value-field-extraction-propsconf-transformsc.html

Second, for items that have already been indexed, you can do this at search time -

| rex field=_raw "projectId=(?<projectId>\w+)\b" max_match=0
| eval projectId=mvfilter(NOT match(projectId,"unknown"))

0 Karma

hippe21
Explorer

Thank you, this is exactly what I was looking for!

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!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

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 ...