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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...