Splunk Search

db connect with lookup only returning first value it finds in lookup when feed by dbquery

rdownie
Communicator

If I use:


|dbquery mydb "select userid from mydb.people where username = 'jsmith' | rename userid as UID | lookup mydb.systems UID output SYSTEMNAME | table UID,SYSTEMNAME


This only returns the first value it finds from the lookup output when it should be returning many systems for that user. Is this expected, normally the lookup command returns all that match, how do I get it to return them all in this case?


Thanks,

Tags (1)
0 Karma

stefano_guidoba
Communicator

Hi,

in Manager > Lookups > Lookups Definition find your lookup, open it, then check the Advanced Options flag and change the value in there (It should be 1 by default).

Regards,
Stefano

0 Karma

rdownie
Communicator

when you run a database lookup, if there are multiple rows that it matches, does it only return the first row and if so, is there a way to get it to return all rows?
lookup user output system
if a user has multiple systems, I would like it to return them all. Is there a way to do this? I tried mvexpand but it is not a multivalued fields that it is returning, it is multiple matches on the lookup..
Any help would be greatly appreciated...

0 Karma

rdownie
Communicator

Unfortunately I don't have the luxary of creating custom sourcetypes. The lookup only appears to give only one result when the field is passed in from a dbquery. I have other queries where the field is passed via a sourcetype output and the lookup outputs all expected rows.

0 Karma

stefano_guidoba
Communicator

To verify that, put the data extracted from your dbquery command in an index with a custom sourcetype. Then write something like
index=mydb sourcetype=users | lookup mydb.systems UID as userid OUTPUT SYSTEMNAME
and check if you still have only one result.

0 Karma

rdownie
Communicator

I changed the Maximum matches from the default to 100 and still only returning 1 value? This appears to only happen when taking its input from the dbquery command.

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