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!

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 ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...