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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...