Splunk Search

Is it possible to add only some specific values from lookup?

AlexeySh
Communicator

Hello.

I use a dbxquery to import some user data including user priority. The result looks like this:

user    | priority
Bob     | low
Tom     | medium
Jack    | high
Bill    | low

At the same time I have a dynamic lookup table with users which currently has admin rights and I'd like to evaluate a priority for those users. The lookup looks like this:

user
Bob
Tom

What I’m trying to do is to add this line to my dbxquery:

| eval priority=if(isnotnull(|lookup my_lookup.csv user OUTPUT user), "high", priority)

But it doesn't work.

I tried to add a new column to my lookup table to make it look like this:

 user    | priority
 Bob     | high
 Tom     | high

and then simply add this line to my dbxquery:

| lookup my_lookup.csv user OUTPUT priority

But it doesn't work either. It actually erases a priority for all users who is not listed in lookup.

Do you have an advice how can I solve that issue?

Thanks for the help!

0 Karma
1 Solution

tiagofbmm
Influencer

So what you want is to make the priority of admin users as High, no matter what is coming from your dbxquery.

dbxquery  
| lookup my_lookup.csv user OUTPUT user as AdminUser
| eval priority=if(user==AdminUser,"high", priority)

Let use know if it works

View solution in original post

tiagofbmm
Influencer

So what you want is to make the priority of admin users as High, no matter what is coming from your dbxquery.

dbxquery  
| lookup my_lookup.csv user OUTPUT user as AdminUser
| eval priority=if(user==AdminUser,"high", priority)

Let use know if it works

AlexeySh
Communicator

Great!
That's exactly what a was searching for.
Thanks for your help!

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...