<?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 Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113677#M29989</link>
    <description>&lt;P&gt;Thank You.  I've tried that and many other combinations but still no results. &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| stats eval(round(sum(bytes_in)/1024/1024, 0)) as MB, user_id as BRANCH by MB | eval BRANCH=substr(user_id,1,3) | sort -MB head 20&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:47:39 GMT</pubDate>
    <dc:creator>chq_alanf</dc:creator>
    <dc:date>2020-09-28T18:47:39Z</dc:date>
    <item>
      <title>How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113674#M29986</link>
      <description>&lt;P&gt;I'm not sure I asked the right question, but I'd like to use substr to extract the first 3 letters of a field and use it as a grouping field.  My query is as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; * | stats sum(bytes_in) as MB by user_id as substr(user_id,1,3) | eval MB=round(MB/1024/1024,2) | sort -MB head 20
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The syntax validates, however, no results are returned.  Taking the substr out returns results, but of every user, not grouped by branch code.&lt;/P&gt;

&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 16:51:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113674#M29986</guid>
      <dc:creator>chq_alanf</dc:creator>
      <dc:date>2015-01-28T16:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113675#M29987</link>
      <description>&lt;P&gt;I would use &lt;CODE&gt;| eval branch_code=substr(user_id,1,3) |&lt;/CODE&gt; to transform user_id to the 3 letter value before stats&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:02:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113675#M29987</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-28T17:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113676#M29988</link>
      <description>&lt;P&gt;Hi @chq_alanf&lt;/P&gt;

&lt;P&gt;I'm not a search expert, but from looking at Splunk documentation, it looks like "substr" is a function of &lt;STRONG&gt;eval&lt;/STRONG&gt; and &lt;STRONG&gt;where&lt;/STRONG&gt;, not stats.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 17:02:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113676#M29988</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2015-01-28T17:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113677#M29989</link>
      <description>&lt;P&gt;Thank You.  I've tried that and many other combinations but still no results. &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| stats eval(round(sum(bytes_in)/1024/1024, 0)) as MB, user_id as BRANCH by MB | eval BRANCH=substr(user_id,1,3) | sort -MB head 20&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:47:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113677#M29989</guid>
      <dc:creator>chq_alanf</dc:creator>
      <dc:date>2020-09-28T18:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113678#M29990</link>
      <description>&lt;P&gt;The problem with the above is that your stats gives you BRANCH and MB, then you try to transform a non existent field (user_id). Stats only gives you the fields that you ask for stats on.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 18:28:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113678#M29990</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-28T18:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113679#M29991</link>
      <description>&lt;P&gt;Yeah I think stats is simply seeing that as a new field name in the above case.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 18:40:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113679#M29991</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-28T18:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113680#M29992</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;* | eval branch_id=substr(user_id,1,3) | stats sum(bytes_in) as MB by branch_id | eval MB=round(MB/1024/1024,2) | sort -MB | head 20
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jan 2015 18:44:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113680#M29992</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-28T18:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113681#M29993</link>
      <description>&lt;P&gt;Also, see my latest example below which might help. It looks like by leaving out a pipe you told sort to use the non-existent field "head". &lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 19:16:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113681#M29993</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-28T19:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113682#M29994</link>
      <description>&lt;P&gt;That worked.. Thank you very much!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 19:21:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/113682#M29994</guid>
      <dc:creator>chq_alanf</dc:creator>
      <dc:date>2015-01-28T19:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use substr to extract the first 3 letters of a field and use it as a grouping field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/616152#M214132</link>
      <description>&lt;P&gt;Tell me, what should I do in my case, I need from the field: 1.SAPS-SIS.TO.LSP.SEND, or: "12.SAPS-SIS.TO.LSP.RECEIVE&lt;BR /&gt;Get field: "routepointIDnum": "1" or "routepointIDnum": "12"&lt;/P&gt;&lt;P&gt;I tried like this and it almost works:&lt;BR /&gt;index="main" sourcetype="testsystem-script333"&lt;BR /&gt;| eval routepointID_num=substr(routepointID,1,2)&lt;BR /&gt;| table routepointID_num&lt;/P&gt;&lt;P&gt;Almost because I get:&lt;BR /&gt;"routepointIDnum": "1." or "routepointIDnum": "12"&lt;BR /&gt;And I need:&lt;BR /&gt;"routepointIDnum": "1" or "routepointIDnum": "12"&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 10:44:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-substr-to-extract-the-first-3-letters-of-a-field-and/m-p/616152#M214132</guid>
      <dc:creator>metylkinandrey</dc:creator>
      <dc:date>2022-10-06T10:44:13Z</dc:date>
    </item>
  </channel>
</rss>

