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!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...