Splunk Search

what is the use of substr in my macro?

pavanae
Builder

I have defined a field extraction in a macro as below

my_search | eval field_A="EventCode: " + EventCode + "; EventType: " + EventType + "; Message: " + substr(Message,1,100)
iseval = 0

What is meant by that? could anyone explain please.

0 Karma
1 Solution

micahkemp
Champion
substr(X,Y,Z)   Returns a substring from X based on the starting position Y and the length Z.

In the search above substr returns the first 100 characters of the Message field.

View solution in original post

cmerriman
Super Champion

The substr command grabs a section of text beginning at the first indicated index number Until the number of characters is reached (second number indicated). In your example, it is grabbing the first 100 characters of the field Message.
http://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/TextFunctions

micahkemp
Champion
substr(X,Y,Z)   Returns a substring from X based on the starting position Y and the length Z.

In the search above substr returns the first 100 characters of the Message field.

Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...