Splunk Search

Sort values of a field with double digit

bleung93
Path Finder

How do I sort this single field properly? I already tried | sort - field_name. I tried creating a rex and then sorting that field, but no changes.

field_name

value_1_asdfasdfasdf
value_10_asdfasdfasdf
Value_11_asdfasdfasdf
Value_12_asdfasdfasdf
value_2_asdfasdfasdf
value_3_asdfasdfasdf
value_4_asdfasdfasdf
value_5_asdfasdfasdf
value_6_asdfasdfasdf
value_7_asdfasdfasdf
value_8_asdfasdfasdf
value_9_asdfasdfasdf

I want the results as follows

value_1_asdfasdfasdf
value_2_asdfasdfasdf
value_3_asdfasdfasdf
value_4_asdfasdfasdf
value_5_asdfasdfasdf
value_6_asdfasdfasdf
value_7_asdfasdfasdf
value_8_asdfasdfasdf
value_9_asdfasdfasdf
value_10_asdfasdfasdf
value_11_asdfasdfasdf
value_12_asdfasdfasdf

Tags (2)
0 Karma
1 Solution

linu1988
Champion

Try to extract all the digits from the data and then sort it.

....|rex field="field_name" "_(?P<dummy>[\d]+)_"|table field_name,dummy|sort +dummy

OR

....|eval dummy=replace(field_name,"\D","")|table fild_name,dummy|sort dummy

Thanks

View solution in original post

0 Karma

linu1988
Champion

Try to extract all the digits from the data and then sort it.

....|rex field="field_name" "_(?P<dummy>[\d]+)_"|table field_name,dummy|sort +dummy

OR

....|eval dummy=replace(field_name,"\D","")|table fild_name,dummy|sort dummy

Thanks

0 Karma

bleung93
Path Finder

Oh, extract just the numbers.... okay I will test this soon and get back. Probably will work.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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