Splunk Search

How to use substr in an eval with if

phamxuantung
Communicator

I try to use the query

 

eval ID = if(ORG="MC",ID=substr(ID,-6),0)

 

Basically, I want in my result, if ORG="MC", I want to extract the last 6 characters of the field ID that go with it, otherwise stay the same. But the result table always show ID as False if ORG="MC"

How do I fix my query or have to go the other way?

Labels (2)
0 Karma

manjunathmeti
Champion

hi @phamxuantung,

Fixed the query:

| eval ID=if(ORG="MC", substr(ID, -6), ID)

 

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...