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 + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...