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!

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...