Splunk Search

How to remove first 8 numbers of a field

adrianrepublic
Explorer

I have a set of devices that are identified by a very long 15 number.

 

The first 8 numbers are just a prefix which we would like to hide and only display last 7 numbers

 

867723030939341 is an example

 

index=index1 sourcetype=devices | stats count by device....

 

Is there a ay to rem

Labels (1)
Tags (1)
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=device mode=sed "s/^\d{8}//g"

or

| eval device=substr(device,9)

View solution in original post

adrianrepublic
Explorer

Worked a treat!

0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @adrianrepublic 

| makeresults | eval device=867723030939341 
|rex field=device "\d{8}(?<deviceid>.*)"
| table device deviceid

 

rex-digits.jpg

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=device mode=sed "s/^\d{8}//g"

or

| eval device=substr(device,9)
Get Updates on the Splunk Community!

ATTENTION!! We’re MOVING (not really)

Hey, all! In an effort to keep this Slack workspace secure and also to make our new members' experience easy, ...

Splunk Admins: Build a Smarter Stack with These Must-See .conf25 Sessions

  Whether you're running a complex Splunk deployment or just getting your bearings as a new admin, .conf25 ...

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...