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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...