Splunk Search

Sorting data on basis of date and date_hour

Aakanksha
Path Finder

I have 1 week data uploaded in SPLUNK.

I a sorting it on weekly as well as daily basis. Query is as follow:

...
|chart limit=0 avg(KPI) by date, date _hour| sort - date _hour

However, the result is not sorted on date_hour.
How can this be resolved?

Tags (1)
0 Karma
1 Solution

dart
Splunk Employee
Splunk Employee

You need to have your rows as the field you want to sort by:

sourcetype=access_combined | chart count by date_hour,date_mday | sort date_hour

Otherwise if you're looking to sort your columns in order, try this:

sourcetype=access_combined | chart count by date_mday,date_hour | table date_mday 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

I didn't have a date or KPI field in my data, so the examples use just the count function and date_mday (day of month) instead.

View solution in original post

dart
Splunk Employee
Splunk Employee

You need to have your rows as the field you want to sort by:

sourcetype=access_combined | chart count by date_hour,date_mday | sort date_hour

Otherwise if you're looking to sort your columns in order, try this:

sourcetype=access_combined | chart count by date_mday,date_hour | table date_mday 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

I didn't have a date or KPI field in my data, so the examples use just the count function and date_mday (day of month) instead.

Aakanksha
Path Finder

No,it is just here in the post. In search query it is like - ... | sort - date_hour

0 Karma

Ayn
Legend

Do you really have a space between "date" and "_hour" in your search or is it just in your post here on splunkbase?

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...