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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...