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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...