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!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...