Refine your search:

Hey,

In Splunk, you can sort your search results by field using the sort command.

Is it possible to sort search results by row?

E.g. If I have a search that produces the following table:

Day Total

1 Monday 93

2 Tuedsay 124

3 Thursday 356

4 Weekend 1022

5 Wednesday 248

and what I really want instead is this table below (showing the days in order):

Day Total

1 Monday 93

2 Tuedsay 124

3 Wednesday 248

4 Thursday 356

5 Weekend 1022

How would I be able to do this? Is this possible in Splunk? (Numbers 1-5 are just Splunk default table row numbers)

asked 22 Sep '10, 13:25

Ant1D's gravatar image

Ant1D
8364441
accept rate: 37%


2 Answers:

There is a solution, it's a little complicated though. You would need to create a field that can be sorted on first, since sorting on weekdays would sort in alphabetical order.

<your search> | eval wd=lower(Day) | eval sort_field=case(wd=="monday",1,wd=="tuesday",2,wd=="wednesday",3,wd=="thursday",4,wd=="friday",5,wd=="weekend",6) | sort sort_field | fields - sort_field
link

answered 22 Sep '10, 14:51

ziegfried's gravatar image

ziegfried ♦
10.0k1618
accept rate: 52%

I suspect that you need to use rex to create a field for the total and then sort by that field.

link

answered 22 Sep '10, 14:18

christopherutz's gravatar image

christopherutz
193110
accept rate: 40%

Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1,643
×395
×55
×44

Asked: 22 Sep '10, 13:25

Seen: 2,116 times

Last updated: 22 Sep '10, 14:51

Copyright © 2005-2012 Splunk Inc. All rights reserved.