Splunk Search

issue with sort command

krish318
New Member

Hi,

index="testdb" sourcetype="audt" | table Command, Duration | sort Duration | search Duration>=60. This search command is not working until i put the desc near "sort Duration"

So i have changed it with following command. then it is working fine
index="testdb" sourcetype="audt" | table Command, Duration | search Duration>=60| sort Duration

The objective here is to get the results for execution time taken (Duration) for the SQL commands (command) to execute.

My question is why the "sort Duration" is not working while "sort Duration desc" is working when i place it in the same location that is in the middle of the search command. is this some kind of glitch in the APP? Kindly help me on this.

Tags (1)
0 Karma

amiftah
Communicator

Can you add | convert num(Duration) before | sort Duration and see if it solves the problem?

0 Karma

niketn
Legend

@krish318 what does the data in Duration field look like? Do they always follow specific format like HH:MM:SS etc?

Would it be possible that sort is working on Alphabetic order rather than numeric based on data in the Duration field?

One of the possibilities would be to convert Duration to seconds to ensure that they sort in numerical order. We would be able to assist further only if you can share the current data Sample for the rows which are not sorting as expected.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

krish318
New Member

Hi loglogananthan,

I tried the query you provided, but it is not working either unless i put desc near "sort" command

0 Karma

logloganathan
Motivator

Could you please try this query

index="testdb" sourcetype="audt" | sort Duration | table Command, Duration | search Duration>=60

because we have to sort and then table it

0 Karma

krish318
New Member

if i type below
index="testdb" sourcetype="audt" | sort Duration desc|table Command, Duration | search Duration>=60

i am getting results with values in descending order and that is fine. But i am trying to get the same results in accessing order now with the following command which is not working. (no resulsts)

index="testdb" sourcetype="audt" | sort Duration |table Command, Duration | search Duration>=60

0 Karma

krish318
New Member

Hi logloganathan,

Thank you for your feedback.
I tried your search query but this is not working either unless i put desc near "sort" command. please advice

0 Karma

krish318
New Member

if i type below
index="testdb" sourcetype="audt" | sort Duration desc|table Command, Duration | search Duration>=60

i am getting results with values in descending order and that is fine. But i am trying to get the same results in accessing order now with the following command which is not working. (no resulsts)

index="testdb" sourcetype="audt" | sort Duration |table Command, Duration | search Duration>=60

0 Karma
Get Updates on the Splunk Community!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...