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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...