Splunk Search

Help refining .csv lookup evals, data not outputting properly

chorn3567
Engager

hi! 

Working on adding a holiday table as a lookup to reference for alerts based on volume and want to alert on different thresholds if its a holiday. the referenced search is showing data for 7/10 as nonHoliday, even though for a test, i have it listed as a holiday in the lookup file. 

its a .csv, so no initial formatting seems to be passing thru the file, need to format the holidayDate column in mm/dd/yyyy

 

 

 

index=my_index
| eval eventDate=strftime(_time, "%m/%d/%Y")
| lookup holidayLookup.csv holidayDate as eventDate OUTPUT holidayDate
| eval dateLookup = strftime(holidayDate, "%m/%d/%Y")
| eval holidayCheck=if(eventDate == dateLookup, "holiday", "nonHoliday")
| fields eventDate holidayCheck
| where holidayCheck="nonHoliday"

 

 

 

screen shot shows its captured the event date as expected and is outputting a value for holidayCheck, but, based on the data file its referencing, it should show as Holiday. 

chorn3567_0-1720638348141.png
data structure

holidayDateholidayName
07/10/2024

Testing Day

07/04/2024Independence Day

 

Labels (2)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

I'm a bit lost here. Either you miscopypasted here or it has no chance of ever matching.

You have eventDate as a string produced by strftime, you use it to find something in your lookup, then you strptime a possible match to a nummeric value dateLookup. There is no way that eventDate will ever be equal to dateLookup. One is a string, another is a number.

0 Karma

yuanliu
SplunkTrust
SplunkTrust

To make this question answerable, you need to also illustrate the content of your lookup.  Perhaps your lookup doesn't contain year? (Sometimes it makes more sense to not have year than having year.)  Also, if you only want to show events on nonHoliday, why the complicated post calculations?

Assuming your lookup is like

holidayDateholiday
1/1New Year's Day
7/10Don't Step on a Bee Day

all you need is

index=my_index
| eval eventDate=strftime(_time, "%m/%d")
| lookup holidayLookup.csv holidayDate as eventDate OUTPUT holidayDate
| where isnull(holidayDate)

 

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...