Reporting

How to format _time field in results email?

tmeader
Contributor

Finally got the csv results sent out in emails to only include the relevant info by using the "fields - xxxx,_raw" statement, however, the _time field that's included by default is sent out only as the epoch timestamp.

I'm sure I can use "fields - xxxx,_time,_raw" to get rid of the epoch version, but what would be the syntax to get a FORMATTED timestamp back in the output along the lines of:

HH:MM:SS MM-DD-YYYY

for each event line? Looked at the "format" operator, and tried looking up "format _time" and "timestamp formatting output" to no avail in the docs.

Thanks.

Tags (2)
2 Solutions

southeringtonp
Motivator

Pipe it to convert:

| convert ctime(_time) as timestamp 

View solution in original post

echalex
Builder

And five years later, I was struggling to find the command that formats a field without actually changing the actual value of the field. This five year old answer is one that kept turning up. If anyone still reads this, I would really recommend looking into fieldformat instead. This command has been around since 6.0, so it wasn't available five years ago.

I noticed with convert that you can have some unexpected results, because it changes the sorting order, e.g. in the output of stats, eventhough you might sort before using convert.

Check out fieldformat:
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fieldformat

sajbutler
Path Finder

I have used the convert command to format timestamp:

| convert ctime(_time) as datetime timeformat="%d/%m/%Y %H:%M:%S"

0 Karma

ziegfried
Influencer

southeringtonp
Motivator

Pipe it to convert:

| convert ctime(_time) as timestamp 
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...