Splunk Search

How do I get first match from lookup with multiple entries

rajashekar_s
Path Finder

I am trying to match a field A from base query with a kv store lookup to get field B from lookup. Apparently there are multiple matches for field A in the lookup which doesn't give me field B in my final table.
1. I cannot use a join for the lookup as the number of entries even if i dedup is more than 600k.
2. I cannot edit the transforms.conf for max_matches entry as I dont have admin access.

3. Tried using lookup in subsearch with no luck.

Query -
query -- | lookup LKP_NAME A AS A OUTPUT B AS B
| table field1 field2 fieldA fieldB

My result table has 7 rows of which 5 rows have single match and I get fieldB perfectly. The other two rows have 2 matches each in lookup and I don't get fieldB for them.
Looking for any help to guide me how to get the field B from lookup on first match.

0 Karma
1 Solution

starcher
Influencer

Where you have multiple values for B this will give you the first one or the only if it returns only one.

| lookup LKP_NAME A AS A OUTPUT B AS B
| eval B=mvindex(B,0)

View solution in original post

starcher
Influencer

Where you have multiple values for B this will give you the first one or the only if it returns only one.

| lookup LKP_NAME A AS A OUTPUT B AS B
| eval B=mvindex(B,0)

rajashekar_s
Path Finder

Thanks. Not sure how I missed this one.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...