Splunk Search

Can you help me integrate a lookup into a search?

donemery
Explorer

I am trying to integrate a lookup into a search with no success. My goal is to run the search, lookup the hostname or TID and compare it to the lookup table (HOSTNAME field) and return results based on matches to the ROLE field. The ROLE column in the lookup that defines whether TID is core, cpe or aggregation. Here is my search:

index=my_main "SFP receive power low  alarm set" 
| stats dc(date_mday) as Days, count by TID, J_Port | eval c_TID=upper(c_TID) 
| where Days > 2 AND count > 49 | appendpipe [stats count | where count=0]
| rename count as "Total Errors", TID as Hostname, J_Port as Port
| sort -"Total Errors"

The lookup table file and definition are working. My difficulty is integrating it into my search.

0 Karma
1 Solution

skoelpin
SplunkTrust
SplunkTrust

I don't see your lookup in the search. It should follow this format

| lookup filename.csv hostname AS host OUTPUT ROLE

View solution in original post

0 Karma

Vijeta
Influencer

Place it at the end of the search, and if you still get the error please paste the complete search with lookup and the error message.

0 Karma

skoelpin
SplunkTrust
SplunkTrust

I don't see your lookup in the search. It should follow this format

| lookup filename.csv hostname AS host OUTPUT ROLE

0 Karma

donemery
Explorer

I didn't include it in the search because no matter where I try it, I get an error back when it is executed. Any guidance as to the proper placement of the lookup is appreciated.

0 Karma

skoelpin
SplunkTrust
SplunkTrust

For performance purposes, its always better to have a stats before the lookup. Place it like this

index=my_main "SFP receive power low  alarm set" 
 | stats dc(date_mday) as Days, count by TID, J_Port | eval c_TID=upper(c_TID) 
| lookup filename.csv hostname AS host OUTPUT ROLE
 | where Days > 2 AND count > 49 | appendpipe [stats count | where count=0]
 | rename count as "Total Errors", TID as Hostname, J_Port as Port
 | sort -"Total Errors"

donemery
Explorer

It's working now. Thanks!

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...