Splunk Search

Timechart with Convert Timeformat

hartfoml
Motivator

So i can build a timechart like this:

| timechart limit=3 span=1m count by host useother=F 

But when I export the results the time format is not readable
How to I format the _time in Timechart or how do I create this kind of chart so that I can format or convert the _time

_time sys01 sys06 srv01 srv02

1334078460 3 2 2 3

1334078520 2 3 2 2

1334078580 3 2 3 3

1334078640 3 3 3 3

1334078700 2 3 2 2

1334078760 2 2 2 2

1334078820 2 2 2 2

Tags (3)
1 Solution

yannK
Splunk Employee
Splunk Employee

try to convert after the timechart.


* | timechart span=1d count by source | convert timeformat=""%Y-%m-%d %H:%M:%S"" ctime(_time) AS date | sort _time | fields - _time | table date *

View solution in original post

0 Karma

yannK
Splunk Employee
Splunk Employee

try to convert after the timechart.


* | timechart span=1d count by source | convert timeformat=""%Y-%m-%d %H:%M:%S"" ctime(_time) AS date | sort _time | fields - _time | table date *

0 Karma

pbankar
Path Finder

@yannK , thanks for your input.
I'm not getting the exact time for the query.
For example: If I have a DateTime: 2019-12-19T15:03:20Z I see 2019-12-19T00:00:00Z
How can I get the exact DateTime for the event?

my query:
eventtype="xxxxxxx" state!=null xxxx="*" | timechart count by state | convert timeformat="%Y-%m-%dT%H:%M:%SZ" ctime(_time) AS DateTime | sort _time | fields - _time | table DateTime, *

0 Karma

hartfoml
Motivator

Ya Man this did it thanks

0 Karma

tysonstewart
Path Finder

Try

... | timechart limit=3 span=1m count by host useother=F | eval Time=strftime(_time,"%H:%M:%S") | table Time,*

Use of convert is considered deprecated, so the eval will accomplish the same thing, then table will reorder the columns.

mikeydee77
Path Finder

Helpful description of the commands. Thanks

0 Karma

MarioM
Motivator

did you try with | convert ctime(_time)

hartfoml
Motivator

Ya thanks I tried that first thing.

I tried | convert timeformat="%H:%M:%S" ctime(_time) AS Time | timechart limit=3 span=1m count by host useother=F

But I didn't know how to work in the "Time" veritable

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!

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...