Splunk Search

field extract OR substr ?

khyoung7410
Communicator

Field name is FLOW.
FLOW field value is 123 OR 123456 OR 123456789 OR ...

FLOW=123 ===> FLOW=null

FLOW=123456 ===> FLOW=123

FLOW=123456789 ===> FLOW=456

.

.

.

I only need a three-digit in the end.
Help me ....

Tags (2)
0 Karma

strive
Influencer

Try this

Your search..| eval FLOW=if(len(FLOW)=3,null,substr(FLOW,len(FLOW)-2,3))

If you need 3 digits leaving last 3 digits then try this

Your search..| eval FLOW=if(len(FLOW)=3,null,substr(FLOW,len(FLOW)-5,3))

strive
Influencer

Good to know that it worked...

khyoung7410
Communicator

strive
Thank you for helping me out.
Have a good day ^^

0 Karma

strive
Influencer

If i understand it right.. you need 3 digits leaving last 3 digits is that right?

0 Karma

strive
Influencer

You said you need last 3 digits. In that case for 100100135139 last 3 digits are 139 right?

0 Karma

khyoung7410
Communicator

Yes.. I need FLOW value is 135

0 Karma

strive
Influencer

Thats what you need right. FLOW=139. My answer did not work for you?

0 Karma

khyoung7410
Communicator

um.. Tried..FLOW value is 100100135139 but FLOW=139

0 Karma

tom_frotscher
Builder

I think instead of substr(FLOW,len(FLOW)-2,len(FLOW)) you can just write substr(FLOW,-3), which is basically the same, but might be easier to understand later.

0 Karma

khyoung7410
Communicator

All right !

0 Karma

strive
Influencer

Ok. you are saying FLOW is a field in log file with possible values as 123, 123456, 123456789 and etc.
Raw logs will be:
FLOW
123
123456
123456789

When you extract, you need
FLOW
null
456
789

Is this right?

0 Karma

khyoung7410
Communicator

Sorry FLOW=789 example.. cancel

0 Karma

strive
Influencer

You said you only need 3 digit in the end. In that case your second example should be FLOW=456, third example should be FLOW=789 and so on.. right?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...

Upgrade Prep for 10.4, Network Observability Deep Dives, and More from Splunk Lantern

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...