Splunk Search

how to sort column chart based on month-year order

dhavamanis
Builder

Need your help,

We have column charts with the below query and its working fine,

index="myindex" source="/opt/apps/data/views/app_PV_UV_Data_3.csv" |timechart sum(PAGE_VIEWS) as PageViews span=1mon

its showing as

2013-Jan, Feb...2014-Jan,Feb....2015-Jan,Feb

but there is requirement to show data in this order,

Jan-2013,Jan-2014,Jan-2015,Feb-2014,Feb-2014,Feb-2015

Can you please help us to write this query

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

Currently you're getting a timechart with field _time (epoch) and PageViews, with results sorted ascending order of _time. Try something like this

 index="myindex" source="/opt/apps/data/views/app_PV_UV_Data_3.csv" |timechart sum(PAGE_VIEWS) as PageViews span=1mon | eval Timestamp=strftime(_time,"%m-%Y-%b-%Y") | table Timestamp PageViews | sort Timestamp | eval Timestamp=substr(Timestamp,8)

View solution in original post

woodcock
Esteemed Legend

Do it like this:

index="myindex" source="/opt/apps/data/views/app_PV_UV_Data_3.csv" | bucket _time span=1m | chart sum(PAGE_VIEWS) as PageViews by _time | eval myTime = strftime(_time, "%m-%y") | sort myTime | fields myTime PageViews | fields - _time
0 Karma

somesoni2
Revered Legend

Currently you're getting a timechart with field _time (epoch) and PageViews, with results sorted ascending order of _time. Try something like this

 index="myindex" source="/opt/apps/data/views/app_PV_UV_Data_3.csv" |timechart sum(PAGE_VIEWS) as PageViews span=1mon | eval Timestamp=strftime(_time,"%m-%Y-%b-%Y") | table Timestamp PageViews | sort Timestamp | eval Timestamp=substr(Timestamp,8)

dhavamanis
Builder

Thank you so much, its working fine, can you please give me the query with out hyphen (-jan-2013) in the beginning.

0 Karma

dhavamanis
Builder

i just adjusted the query and it works. Thank you,

eval Timestamp=substr(Timestamp,9)

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...