Splunk Search

System login after hours

essibong1
New Member

Hello,
I had requested help with a "search language that could determine system logins after core hours" and one of the nice people here puts the below search together for me. does this search need any revisions or is it incomplete? if it does need some revisions can anyone help with such revisions please?

[out_working_time]
definition = | eval day=strftime(_time,"%d/%m/%Y")\
| lookup SIEMCAL.csv day OUTPUT type\
| search Tipo=2 OR (Tipo=1 (date_hour>14 OR (date_hour<7 AND date_minute<45))) OR (Tipo=0 (date_hour>20 OR (date_hour<8 AND date_minute<45)))
iseval = 0

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @essibong1,
sorry, probably I wasn't so clear in my previous answer!

this is a macro definition that I hinted in my answer to your previous question ( https://answers.splunk.com/answers/789359/can-any-one-provide-me-with-a-good-search-to-monit.html#an... 😞 I used a macro to have in only one point the working time definition so I can modify it in only one point instead in each search of my app.

Anyway, if you don't want to use a macro, you have to create your search starting from the filter for the access events (e.g. in windows EventCode=4624) and then filter for the hours and minutes.

The other needed information is if you want only to filter for time or you want also to filter for holydays:

if you want to filter only for time, you can run something like this (working time 8.00 - 17.00):

index=your_index EventCode=4624 (date_hour<8 OR date_hour>18)
| ...

If instead you want also holydays (using the lookup), you have to create a lookup (called e.g. SIEMCAL.csv) containing two information:

  • day in a format you like (e.g. dd/mm/yyyy),
  • type (0 for working time, 1 for half working time, 2 for holydays).

So for windows systems you can run something like this:

index=your_index EventCode=4624 
| eval day=strftime(_time,"%d/%m/%Y")
| lookup SIEMCAL.csv day OUTPUT type
| search type=2 OR (Tipo=1 (date_hour>14 OR (date_hour<8)) OR (type=0 (date_hour>18 OR date_hour<8)))
| ...

Ciao.
Giuseppe

0 Karma

FrankVl
Ultra Champion

That's not a search, it is a macro.

Maybe easier to just continue in the original question: https://answers.splunk.com/answers/789359/can-any-one-provide-me-with-a-good-search-to-monit.html

As I mentioned there, there are some serious caveats with that macro, so I'd not recommend using it like that. Especially if you apparently don't understand what it does.

There were some good comments and questions on your previous post. I'd start with looking at those and responding to the clarification questions that were asked there. Otherwise it is not really possible to provide a lot of help.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

That doesn't look like a search. It looks like a macro definition.
Your best option is to ask the person who gave you the information.

---
If this reply helps you, Karma would be appreciated.
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!

Think Like an Architect: Introducing the Splunk Certified Cybersecurity Defense ...

In cybersecurity, defenders respond to threats. Architects design the systems that stop them.    As ...

Index This | What has goals but no motivation?

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

Deep Dive: Accelerate threat investigation with Splunk’s AI Assistant in Security

AI is one of the biggest topics in the market today, and for security teams, its value goes far beyond the ...