Splunk Search

Why is time formatting not working with my search?

jaho_splunk
Engager

Why is time formatting not working with the following search:

index=_internal sourcetype=splunkd  "Ignoring" AND "binary" | eval time=strftime(_time, "%m/%d/%y %H:%M:%S") | stats earliest(_time) as start, latest(_time) as stop by message, host
0 Karma
1 Solution

somesoni2
Revered Legend

The field name created for formatted _time is not used in stats, hence the problem. Try like this

index=_internal sourcetype=splunkd  "Ignoring" AND "binary" | eval time=strftime(_time, "%m/%d/%y %H:%M:%S") | stats earliest(time) as start, latest(time) as stop by message, host

OR more efficient method (formatting should be done after aggregation, if possible/feasible)

 index=_internal sourcetype=splunkd  "Ignoring" AND "binary" | stats earliest(_time) as start, latest(_time) as stop by message, host | convert ctime(start) ctime(stop) timeformat="%m/%d/%y %H:%M:%S"

View solution in original post

somesoni2
Revered Legend

The field name created for formatted _time is not used in stats, hence the problem. Try like this

index=_internal sourcetype=splunkd  "Ignoring" AND "binary" | eval time=strftime(_time, "%m/%d/%y %H:%M:%S") | stats earliest(time) as start, latest(time) as stop by message, host

OR more efficient method (formatting should be done after aggregation, if possible/feasible)

 index=_internal sourcetype=splunkd  "Ignoring" AND "binary" | stats earliest(_time) as start, latest(_time) as stop by message, host | convert ctime(start) ctime(stop) timeformat="%m/%d/%y %H:%M:%S"

jaho_splunk
Engager

Thank you somesoni2 for the solution.

0 Karma

ppablo
Retired

Hi @jaho_splunk

If somesoni2's answer solved your question, please don't forget to resolve the post by clicking "Accept" directly below his answer and upvote him for being helpful. Thanks!

Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...