Splunk Search

How to sort field values alphanumerically?

pgadhari
Builder

I have a field called Rack which has the values as Rack-1 Rack-2 Rack-3....Rack-10. When I do sort on Rack field, it shows the values like below :

Rack-1
Rack-10
Rack-2
...
...
Rack-9

I want to show the values as : This is the requirement ?

Rack-1
Rack-2
Rack-3
...
...
Rack-10

By default, sort is showing Rack-10 after Rack-1 and then so on. How do I sort it alphanumeric to show the values as required above ?

Thanks
PG

0 Karma
1 Solution

renjith_nair
SplunkTrust
SplunkTrust

@pgadhari,

Try

Your current search | rex field=Rack "Rack-(?<_RackNo>\d+)"| sort _RackNo
Happy Splunking!

View solution in original post

0 Karma

harshpatel
Contributor

Hi @pgadhari,

You can use mvsort eval function like:

| eval Rack=mvsort(Rack)

pgadhari
Builder

I will check this and revert. Thanks.

0 Karma

pgadhari
Builder

This also works. Hence, upvoting the post. Thanks for your reply too.

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@pgadhari,

Try

Your current search | rex field=Rack "Rack-(?<_RackNo>\d+)"| sort _RackNo
Happy Splunking!
0 Karma

pgadhari
Builder

Thanks. This is working.

0 Karma

pgadhari
Builder

I will check this and revert. Thanks.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...