Splunk Search

I want to create a subsearch that will abbreviate all but the first 30 characters of the result.

NanSplk01
Communicator
index=replicate category=* action=* Message=*
  [search index=replicate
   | eval Msg=substr(Message,1,30)]
| stats count by action category Msg

| dedup action

 

This is what I'm trying to do.  The Message field is very large and I only need the first sentence of the Message.  How can I do this?  We want it in a sub-search to show the sub-search function for our users.

This is Splunk Cloud implementation.

Labels (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @NanSplk01 ,

why do you want to use the subsearch?

if I correctly understand you need only to truncate the Message field to the first 3 chars, is it correct?

index=replicate category=* action=* Message=*
| eval Msg=substr(Message,1,30)
| stats 
     values(category) AS category 
     values(Msg) AS Msg 
     BY action 

Ciao.

Giuseppe

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Recall that subsearches run first and replace themselves with their results.  That means the search is looking only for Msg field (which may not exist in the index) values of 30 characters or fewer (longer values are missed without a wildcard).

Perhaps you only need to truncate the Message for display purposes.  If so, drop the subsearch and run the eval as a separate command.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...