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

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!

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...