Splunk Search

Formatting my date

rickettw
New Member

Below is my report but my date output is blank, i am searching for powershell events on my network and need to know what date these events occurred, any suggestions?

sourcetype="symantec:ep:risk:file" index=security_sep application_name ="*.ps1" | stats count as Event_Count values(user) as User values(computer_name) as Computer_Name values(category) as Category values(application_name) as Application_Name values(strftime(_time, "%d/%m/%Y")) as Time by ip_address| sort -Event_Count _time

Thanks much.

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Try this:

sourcetype="symantec:ep:risk:file" index=security_sep application_name ="*.ps1"
| stats count as Event_Count list(user) as User list(computer_name) as Computer_Name list(category) as Category list(application_name) as Application_Name list(eval(strftime(_time, "%d/%m/%Y"))) as Time by ip_address
| sort -Event_Count _time

View solution in original post

0 Karma

woodcock
Esteemed Legend

Try this:

sourcetype="symantec:ep:risk:file" index=security_sep application_name ="*.ps1"
| stats count as Event_Count list(user) as User list(computer_name) as Computer_Name list(category) as Category list(application_name) as Application_Name list(eval(strftime(_time, "%d/%m/%Y"))) as Time by ip_address
| sort -Event_Count _time
0 Karma

richgalloway
SplunkTrust
SplunkTrust

I've had mixed results using eval within stats so I would use a separate eval.

 sourcetype="symantec:ep:risk:file" index=security_sep application_name ="*.ps1" | eval Time=strftime(_time, "%d/%m/%Y") | stats count as Event_Count values(user) as User values(computer_name) as Computer_Name values(category) as Category values(application_name) as Application_Name values(Time) as Time by ip_address| sort -Event_Count Time
---
If this reply helps you, Karma would be appreciated.
0 Karma

cmerriman
Super Champion

add eval into your Time command.

values(eval(strftime(_time, "%d/%m/%Y"))) as Time
0 Karma

micahkemp
Champion

Your stats search named the values() function output Time, so _time isn't available. Try changing your sort to:

sort -Event_Count Time

Or change your values() function to name the field _time.

Edit: and change your values() function to use eval(), as per the answer below.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...