Dashboards & Visualizations

Sorting of Fields base on Timestamp

Zyon
Engager

Hello!

Im trying to sort a field based on the timestamp.

This is my current search command

sourcetype=log | eval date_readable=date_mday." ".date_month | stats count by date_readable

Using this search command, I'm able to produce the following graph in my dashboard.
Graph: http://i40.tinypic.com/2ai0zzn.png

However, the date is not sort in a correct sequence. Is there anyway for me to sort the date_readable field according to timestamp?

Thanks!

0 Karma
1 Solution

kristian_kolb
Ultra Champion

Well, from what it looks like in the picture, it is sorted on date_readable. Unfortunately for you, date_readable has no special meaning to Splunk - it's just a string.

I'd suggest that you do the following instead;

sourcetype=log | timechart span=1d count 

That will sort it automatically.


UPDATE:

linu1988 has a point here - there is a difference between _time and the date_* fields. In your original search query, you used the date_* fields, but the timechart approach I suggested uses _time.

See lguinns excellent explanation here;

http://answers.splunk.com/answers/99451/variance-betweeen-time-and-date-fields

/K

View solution in original post

linu1988
Champion

because it's still a string not a date.

Convert into time using strftime()/ convert then do a sort then chart...

0 Karma

kristian_kolb
Ultra Champion

Well, from what it looks like in the picture, it is sorted on date_readable. Unfortunately for you, date_readable has no special meaning to Splunk - it's just a string.

I'd suggest that you do the following instead;

sourcetype=log | timechart span=1d count 

That will sort it automatically.


UPDATE:

linu1988 has a point here - there is a difference between _time and the date_* fields. In your original search query, you used the date_* fields, but the timechart approach I suggested uses _time.

See lguinns excellent explanation here;

http://answers.splunk.com/answers/99451/variance-betweeen-time-and-date-fields

/K

Zyon
Engager

sourcetype=log | timechart span=1d count works for me! Thanks a lot! (:

0 Karma

linu1988
Champion

If the eventtime is matching with the log time, if not _time needs to assigned from logs then chart...

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...