Splunk Search

Eval against a lookup

Tika
Explorer

Hello, I am new to Splunk and this is probably a basic query. I have a field with an email address and I want to check if the email exists in a look up table and eval it to 1, if found and 0 if not. 

I also have multiple emails in the field and this is what I have come up with so far, any help is much appreciated.

 

 

 

| rename "my_user.user_email" as email | mvexpand email | stats count by email  | eval useremail= email."@my_domain.com" | table useremail count | lookup userdomain_email email as useremail OUTPUT user as user 

 

 

 

But this gives me counts and Im not sure if the result is accurate either.  Thanks!

Labels (2)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

(Clicked Enter by mistake and for some reason I cannot edit or delete the above.  So here goes)

| eval in_lookup = if(isnull(user), 0, 1)

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @Tika,

you could run something like this:

your_search
| rename "my_user.user_email" as email 
| mvexpand email 
| stats count by email  
| eval useremail= email."@my_domain.com" 
| append [ | inputlookup userdomain_email | rename email AS useremail | fields useremail ]
| stats sum(count) AS total BY useremail
| eval status=if(total=0,0,1)
| table useremail status

Ciao.

Giuseppe

0 Karma

Tika
Explorer

Thanks! that works

yuanliu
SplunkTrust
SplunkTrust

(Clicked Enter by mistake and for some reason I cannot edit or delete the above.  So here goes)

| eval in_lookup = if(isnull(user), 0, 1)

yuanliu
SplunkTrust
SplunkTrust

There is only one step from your lookup output to 0-or-1 determination: if(X,Y,Z).

Tags (1)
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...