Splunk Search

Why can't I use my lookup command after stats command in my search string

jcorkey
Explorer

I am trying to use stats command to display data organized by My_Field where My_Field is populated by running lookup my_lookup_script username AS user

Here's the example of the search string:

| stats STUFF by My_Field | lookup my_lookup_script username AS user

My problem is that My_Field is not populated for the stats command to use because the lookup command happens after the stats command. I tried simply running the lookup BEFORE the stats command but the lookup needs to run at the end of the search because if it does not then the lookup does not work properly. If the lookup runs before the stats command It gets inconsistent values for user. Seems like the lookup has to be at the end so the whole search can finish running and have the correct data in user for the script to use.

How can I have the lookup run after that stats command to where the stats command can use the My_Field

0 Karma

DalJeanis
Legend

You are telling us your conclusions rather than your business requirements. Here's a total stab in the dark.

 your search | stats STUFF by user  | lookup my_lookup_script username AS user | stats MORESTUFF  by My_Field

If that is not the strategy that you are looking for, then explain the following things -

1) what is in the raw fields to be aggregated
2) what is the actual field being looked up, and the output fields
3) what happens when you put the lookup before the first stats, and why do you think that is incorrect.

One other thing you can check first - is the capitalization of user field values consistently the same as are in the lookup table? If not, consider using upper() or lower() to make it so.

Get Updates on the Splunk Community!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...