<?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: search string query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357727#M165923</link>
    <description>&lt;P&gt;Hi francly,&lt;BR /&gt;
I'm not sure to have understood you request: do you want to create a new query or use the same to have a subdivision of RULES by NAMEs?&lt;/P&gt;

&lt;P&gt;If the first you already have the solution.&lt;/P&gt;

&lt;P&gt;If the second you can use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data sourcetype="data1" host=HOSTA Name=SRV1 | stats count by NAME RULE | sort -count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and take the first 3.&lt;/P&gt;

&lt;P&gt;Remeber that if you want a stats by one field (e.g.  stats count by NAME) it's easier to use top command.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2017 09:31:43 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-09-26T09:31:43Z</dc:date>
    <item>
      <title>search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357726#M165922</link>
      <description>&lt;P&gt;Hi I can use the search string to get the statistics output &lt;/P&gt;

&lt;P&gt;index=data sourcetype="data1" host=HOSTA | stats count by NAME | sort -count | head 3&lt;/P&gt;

&lt;P&gt;Name  Count&lt;BR /&gt;
SRV1    800&lt;BR /&gt;
SRV2    600&lt;BR /&gt;
SRV6    700&lt;/P&gt;

&lt;P&gt;Question is how I continue use string to query each of the output "Name" to display a new field "RULE" under "Name"&lt;/P&gt;

&lt;P&gt;Example&lt;/P&gt;

&lt;P&gt;index=data sourcetype="data1" host=HOSTA Name=SRV1 | stats count by RULE | sort -count &lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 02:37:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357726#M165922</guid>
      <dc:creator>francly</dc:creator>
      <dc:date>2017-09-26T02:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357727#M165923</link>
      <description>&lt;P&gt;Hi francly,&lt;BR /&gt;
I'm not sure to have understood you request: do you want to create a new query or use the same to have a subdivision of RULES by NAMEs?&lt;/P&gt;

&lt;P&gt;If the first you already have the solution.&lt;/P&gt;

&lt;P&gt;If the second you can use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data sourcetype="data1" host=HOSTA Name=SRV1 | stats count by NAME RULE | sort -count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and take the first 3.&lt;/P&gt;

&lt;P&gt;Remeber that if you want a stats by one field (e.g.  stats count by NAME) it's easier to use top command.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 09:31:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357727#M165923</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-26T09:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357728#M165924</link>
      <description>&lt;P&gt;Hi Giuseppe, &lt;/P&gt;

&lt;P&gt;I want to know based on my output &lt;/P&gt;

&lt;P&gt;index=data sourcetype="data1" host=HOSTA | stats count by NAME | sort -count | head 3&lt;/P&gt;

&lt;P&gt;Name Count&lt;BR /&gt;
SRV1 800&lt;BR /&gt;
SRV2 600&lt;BR /&gt;
SRV6 700&lt;/P&gt;

&lt;P&gt;it's any string of script will automatically take "Name" from the output in this 3 name or potentially more name to get the top "Rule" &lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 09:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357728#M165924</guid>
      <dc:creator>francly</dc:creator>
      <dc:date>2017-09-26T09:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357729#M165925</link>
      <description>&lt;P&gt;Hi francly,&lt;BR /&gt;
you can add values(RULE) AS RULE to have a list of all rules for each host, is it what you like?&lt;BR /&gt;
something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data sourcetype="data1" host=HOSTA 
| stats values(RULE) AS RULE count by NAME 
| sort -count 
| head 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 11:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357729#M165925</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-26T11:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357730#M165926</link>
      <description>&lt;P&gt;Hi Giuseppe, it's possible to break down the count for all the rule? right now I'm only getting 1 rule per Name&lt;/P&gt;

&lt;P&gt;Name     Total Count&lt;BR /&gt;
SRV1       800&lt;BR /&gt;
  Rule1    500&lt;BR /&gt;
  Rule2   200&lt;BR /&gt;
  Rule3   100&lt;/P&gt;

&lt;P&gt;SRV2   600&lt;BR /&gt;
SRV6 700&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 03:34:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357730#M165926</guid>
      <dc:creator>francly</dc:creator>
      <dc:date>2017-09-27T03:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357731#M165927</link>
      <description>&lt;P&gt;Hi francly,&lt;BR /&gt;
try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data sourcetype="data1" host=HOSTA 
| stats count by NAME, RULE
| search [ search 
   index=data sourcetype="data1" host=HOSTA 
   | stats count by NAME 
   | head 3 
   | fields NAME 
   ]
| eventstats sum(count) as rank by NAME
| appendpipe  [ stats values(rank) AS rank sum(count) AS Total by NAME ] 
| sort 0 -rank NAME -Total -count
| fields - rank
| eval NAME=if(Total&amp;gt;0,NAME,"")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 11:02:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357731#M165927</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-27T11:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357732#M165928</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;I getting this not relevant output&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lh3.googleusercontent.com/8maKmwAIlQhgQYmhQ6_sxX2P9N9OBfDXl03AupVS1PJVXKOxR2xjl58TfvukXR4qCyHJxeSoZEBbpujsCydgK8D82WU=s480" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 03:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357732#M165928</guid>
      <dc:creator>francly</dc:creator>
      <dc:date>2017-09-28T03:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357733#M165929</link>
      <description>&lt;P&gt;You can try something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data sourcetype="data1" host=HOSTA Name=SRV1 
| stats count by NAME RULE 

| rename COMMENT as "Chew all the records up again to get the top 3 names"
| appendpipe [| stats sum(count) as totcount by NAME | sort 3 - totcount]

| rename COMMENT as "Roll the top 3 totcount onto all records with that NAME, then drop all records without totcount"
| eventstats values(totcount) as totcount by NAME
| where isnotnull(totcount)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2017 05:48:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357733#M165929</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-28T05:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: search string query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357734#M165930</link>
      <description>&lt;P&gt;Sorry I cannot see your output.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 07:44:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-string-query/m-p/357734#M165930</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-28T07:44:41Z</dc:date>
    </item>
  </channel>
</rss>

