<?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: count by percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199374#M57726</link>
    <description>&lt;P&gt;Ah. In that case, replace the &lt;CODE&gt;rename&lt;/CODE&gt; with &lt;CODE&gt;eval ipaddr = if(mod="syn+ack", srv, cli)&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jun 2014 19:32:17 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-06-19T19:32:17Z</dc:date>
    <item>
      <title>count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199369#M57721</link>
      <description>&lt;P&gt;Hi, we're trying to find out windows XP users with some rules:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;if mod=syn, get client ip (cli)&lt;/LI&gt;
&lt;LI&gt;if mod=syn+ack, get server ip (server)&lt;/LI&gt;
&lt;LI&gt;For each ip, regard as Windows XP if over 80% of OS shows os="Windows XP"&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Logs look like following:&lt;/P&gt;

&lt;P&gt;[2014/05/19 10:40:01] mod=syn|cli=192.168.133.251/36360|srv=192.168.188.98/80|subj=cli|os=Windows NT kernel 5.x|dist=5|params=generic fuzzy|raw_sig=4:59+5:0:1460:65535,8:mss,nop,ws,nop,nop,sok:df,id+:0&lt;BR /&gt;
[2014/05/19 10:35:28] mod=syn+ack|cli=192.168.94.71/49771|srv=192.168.11.122/80|subj=srv|os=Windows 7 or 8|dist=3|params=none|raw_sig=4:125+3:0:1460:8192,8:mss,nop,ws,sok,ts:df,id+:0&lt;/P&gt;

&lt;P&gt;I use following search which seems to be a bit clumsy (I'm newbie to Splunk) and I'm finding the way to verify it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search sourcetype=p0f ( mod=syn ) | rename cli AS ipaddr | fields mod, os, ipaddr 
 | append [ search sourcetype=p0f (mod="syn+ack" ) | rename srv AS ipaddr | fields mod, os, ipaddr ] 
  |  rex mode=sed field=ipaddr "s/\/.*//g" 
  | stats count, count(eval(match(os,"Windows XP"))) as XP, count(eval(NOT match(os, "Windows XP"))) as nonXP by ipaddr 
  | eval matched = XP/count * 100 | search matched &amp;gt;= 80 | fields ipaddr ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wonder if this can be achieved more efficiently.  Would anyone please help?  Thanks a lot.&lt;/P&gt;

&lt;P&gt;Rgds&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199369#M57721</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2020-09-28T16:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199370#M57722</link>
      <description>&lt;P&gt;You can get rid of the &lt;CODE&gt;append&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=p0f mode=syn OR mod="syn+ack" | rename cli as ipaddr srv as ipaddr |  rex mode=sed field=ipaddr "s/\/.*//g"
| stats count count(eval(match(os,"Windows XP"))) as XP by ipaddr 
| eval matched = XP/count * 100 | search matched &amp;gt;= 80 | fields ipaddr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've also dropped an unused field off the &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2014 15:40:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199370#M57722</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-06-17T15:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199371#M57723</link>
      <description>&lt;P&gt;We need to count cli of mod=syn and srv of mod=syn+ack, but mod=* have both cli/srv and thus we need to select only one of them depends on mod's value.  Is this okay? &lt;/P&gt;

&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 03:26:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199371#M57723</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2014-06-19T03:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199372#M57724</link>
      <description>&lt;P&gt;Thanks.  We interested in cli of mod=syn and srv of mod="syn+ack", while cli and srv appears in mod=syn and mod=syn+ack.   Seems the modification will stats cli and srv of all entries?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 09:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199372#M57724</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2014-06-19T09:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199373#M57725</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=p0f mode=syn OR mod="syn+ack" | eval ipaddr=if(mod="syn+ack",srv,cli) |  rex mode=sed field=ipaddr "s/\/.*//g" | eventstats count as Total count(eval(match(os,"Windows XP"))) as XP by ipaddr | eval os=if(XP &amp;gt; 0.8*Total,"Windows XP",os) | stats count by ipaddr os
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jun 2014 14:27:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199373#M57725</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-06-19T14:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199374#M57726</link>
      <description>&lt;P&gt;Ah. In that case, replace the &lt;CODE&gt;rename&lt;/CODE&gt; with &lt;CODE&gt;eval ipaddr = if(mod="syn+ack", srv, cli)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 19:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199374#M57726</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-06-19T19:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: count by percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199375#M57727</link>
      <description>&lt;P&gt;That works for me.  Thank you very much.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jun 2014 01:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/count-by-percentage/m-p/199375#M57727</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2014-06-20T01:21:36Z</dc:date>
    </item>
  </channel>
</rss>

