<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Why is the substr function not working for JSON logs in Splunk 6.5.2? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346764#M63669</link>
    <description>&lt;P&gt;The &lt;CODE&gt;substr&lt;/CODE&gt; function is not working for json logs for us in 6.5.2 for Dev version. Whereas the Prod version of the Splunk seems to be supporting the same.&lt;/P&gt;

&lt;P&gt;I checked the builds as well, both have the same. Log format is consistent across the two environments as well. Any clue as to what the case be here ?&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2017 20:49:25 GMT</pubDate>
    <dc:creator>pimco_rgoyal</dc:creator>
    <dc:date>2017-06-14T20:49:25Z</dc:date>
    <item>
      <title>Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346764#M63669</link>
      <description>&lt;P&gt;The &lt;CODE&gt;substr&lt;/CODE&gt; function is not working for json logs for us in 6.5.2 for Dev version. Whereas the Prod version of the Splunk seems to be supporting the same.&lt;/P&gt;

&lt;P&gt;I checked the builds as well, both have the same. Log format is consistent across the two environments as well. Any clue as to what the case be here ?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 20:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346764#M63669</guid>
      <dc:creator>pimco_rgoyal</dc:creator>
      <dc:date>2017-06-14T20:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346765#M63670</link>
      <description>&lt;P&gt;"not working" covers a lot of ground.  Please describe the symptoms as closely as possible, so we can help.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 01:41:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346765#M63670</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-15T01:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346766#M63671</link>
      <description>&lt;P&gt;I have a field under the name of message that contains the content describing each of the log level. For the alert I have used the substr function to extract the first 300 characters of the message to avoid making email content heavy. However using the same just gives me a blank field. Below is the query to give you more idea.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="web_rev3" _index_earliest=-15m@m _index_latest=now (level=ERROR OR level=FATAL) | eval Service=substr(index, 5)  | eval Time=strftime(_time, "%m/%d %H:%M:%S") | eval msg=substr(msg,1, 300) | eval msg= msg . "..."  | table Time, Service,  msg | head 20
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 05:50:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346766#M63671</guid>
      <dc:creator>pimco_rgoyal</dc:creator>
      <dc:date>2017-06-15T05:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346767#M63672</link>
      <description>&lt;P&gt;Have you checked that &lt;CODE&gt;msg&lt;/CODE&gt; exists in both cases?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 02:18:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346767#M63672</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-16T02:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346768#M63673</link>
      <description>&lt;P&gt;Okay, so first I'd answer woodcock's question - get rid of all the evals and see if msg exists&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="web_rev3" _index_earliest=-15m@m _index_latest=now (level=ERROR OR level=FATAL) 
| head 1 | table _time index msg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... if it doesn't exist, then try this and see if it's spelled some other way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| head 1 | table _time index m*s*g* M*s*g*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 03:04:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346768#M63673</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-16T03:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346769#M63674</link>
      <description>&lt;P&gt;Yes, message field is very much there and it has valid content as well. Also field name casing is the same that I used as part of my query.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 06:24:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346769#M63674</guid>
      <dc:creator>pimco_rgoyal</dc:creator>
      <dc:date>2017-06-16T06:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346770#M63675</link>
      <description>&lt;P&gt;OK so the msg field is present is it the substr that's failing or is it the concatenating of the '...' that's failing? What does the following produce?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="web_rev3" _index_earliest=-15m@m _index_latest=now (level=ERROR OR level=FATAL) 
 | head 1 | eval msg=substr(msg,1, 300) | table _time index msg
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 09:43:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346770#M63675</guid>
      <dc:creator>davebrooking</dc:creator>
      <dc:date>2017-06-16T09:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346771#M63676</link>
      <description>&lt;P&gt;I agree; strip down your search to the bare minimum failure stuff and get rid of all the cruft that is noise for us.  Also, as a long shot, try running in &lt;CODE&gt;verbose&lt;/CODE&gt; mode.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 15:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346771#M63676</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-16T15:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346772#M63677</link>
      <description>&lt;P&gt;Check if the msg field is a multivalued field as substr will not work on multivalued field. &lt;/P&gt;

&lt;P&gt;If it is, something like this can be done,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="web_rev3" _index_earliest=-15m@m _index_latest=now (level=ERROR OR level=FATAL) | eval Service=substr(index, 5)  | eval Time=strftime(_time, "%m/%d %H:%M:%S") | eval msg=if(mvcount(msg)&amp;gt;1, substr(mvindex(msg,0),1, 300), substr(msg,1,300)) | eval msg= msg . "..."  | table Time, Service,  msg | head 20
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346772#M63677</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-16T17:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346773#M63678</link>
      <description>&lt;P&gt;Awesome ! Looks like this to be the issue. I will dig more into why we have multivalue fields as part of our logs.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:40:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346773#M63678</guid>
      <dc:creator>pimco_rgoyal</dc:creator>
      <dc:date>2017-06-16T17:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the substr function not working for JSON logs in Splunk 6.5.2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346774#M63679</link>
      <description>&lt;P&gt;Cool... you may want to look at this post as well to ensure this is not the case with yours&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/174939/why-are-my-json-fields-extracted-twice.html"&gt;https://answers.splunk.com/answers/174939/why-are-my-json-fields-extracted-twice.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:44:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-substr-function-not-working-for-JSON-logs-in-Splunk-6/m-p/346774#M63679</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-16T17:44:09Z</dc:date>
    </item>
  </channel>
</rss>

