<?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 Top value of a previuos  Top Result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80236#M20287</link>
    <description>&lt;P&gt;Just a quick check - I edited my answer shortly after posting it. My first search had a problem much like this.  Are you using the unedited answer that probably generated an email to you, or the edited one on the site?&lt;/P&gt;</description>
    <pubDate>Sun, 30 Jun 2013 16:29:00 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2013-06-30T16:29:00Z</dc:date>
    <item>
      <title>Search Top value of a previuos  Top Result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80232#M20283</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to create a table of data which draws upon a subsearch and a join in order to have more completely representation of my data. &lt;/P&gt;

&lt;P&gt;first, I created a table that shows  the TOP 5 Destination IP, Destination IP Country, Destination Port, and Protocol. My search is something like this:&lt;/P&gt;

&lt;P&gt;sourcetype="cisco_asa" (host="11.11.11.11" OR host="10.10.10.10" OR host="12.12.12.12" OR host="13.13.13.14") (actual_action="Deny" OR actual_action="Denied" OR actual_action="denied") dest_dom="Outside" | geoip dest_ip | eval protocol=lower(protocol) | top limit=5 dest_ip,dest_ip_country_name,dest_port,protocol&lt;/P&gt;

&lt;P&gt;And my result is something like:&lt;BR /&gt;
        dest_ip         dest_ip_country_name    dest_port   protocol    count   percent&lt;BR /&gt;
1   aaa.aaa.aaa.aaa          China          161     udp     336834  10.501823&lt;BR /&gt;
2   bb.bbb.bbb.bbb           United Kingdom     16386       udp     184701  5.758615&lt;BR /&gt;
3   ccc.ccc.ccc.ccc          United Kingdom     3544        udp     182193  5.680420&lt;BR /&gt;
4   dd.ddd.ddd.ddd           United Kingdom     16385       udp     180451  5.626108&lt;BR /&gt;
5   ee.eee.eee.eee           United Kingdom     16384       udp     180332  5.622398&lt;/P&gt;

&lt;P&gt;If I drill down, I'll be able to find for each one of my results the TOP Source IP.&lt;/P&gt;

&lt;P&gt;What I'm trying to do, is to eliminate to drill down in order to find out what is the Source IP on each result. so my table should look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_ip          dest_ip         dest_ip_country_name    dest_port   protocol    count   percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1   xxx.xxx.xxx.xxx         aaa.aaa.aaa.aaa          China          161     udp     336834  10.501823&lt;BR /&gt;
2   yy.yyy.yyy.yyy          bb.bbb.bbb.bbb           United Kingdom     16386       udp     184701  5.758615&lt;BR /&gt;
3   zz.zzz.zzz.zzz          ccc.ccc.ccc.ccc          United Kingdom     3544        udp     182193  5.680420&lt;BR /&gt;
4   &lt;A href="http://www.www.www.www" target="_blank"&gt;www.www.www.www&lt;/A&gt;         dd.ddd.ddd.ddd           United Kingdom     16385       udp     180451  5.626108&lt;BR /&gt;
5   uu.uuu.uuu.uuu          ee.eee.eee.eee           United Kingdom     16384       udp     180332  5.622398&lt;/P&gt;

&lt;P&gt;I've tried changing the join parameters a few times and in a few ways, but I'm missing something about the logic of what I'm doing, so I'm obviously going about it in the wrong way.&lt;/P&gt;

&lt;P&gt;I just want to find TOP 5 Destination IP, Destination IP Country, Destination Port, and Protocol., then look for them TOP Source IP for each one, and create a nice table of information...&lt;/P&gt;

&lt;P&gt;any Ideas..... I need more coffee....&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:12:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80232#M20283</guid>
      <dc:creator>acedeno</dc:creator>
      <dc:date>2020-09-28T14:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Search Top value of a previuos  Top Result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80233#M20284</link>
      <description>&lt;P&gt;Don't use join.  This query should work. &lt;/P&gt;

&lt;P&gt;sourcetype="cisco_asa" (host="11.11.11.11" OR host="10.10.10.10" OR host="12.12.12.12" OR host="13.13.13.14") (actual_action="Deny" OR actual_action="Denied" OR actual_action="denied") dest_dom="Outside" | geoip dest_ip | eval protocol=lower(protocol) | stats count by dest_ip,dest_ip_country_name,dest_port,protocol,src_ip | sort - count | streamstats count as src_ip_index by dest_ip,dest_ip_country_name,dest_port,protocol | where src_ip_index=1 | fields - src_ip_index&lt;/P&gt;

&lt;P&gt;That first stats command is the same as yours except that it also calculates count by src_ip.   Then we sort by the overall count, then we use streamstats to basically paint little numbers so the first row for a given combination of all the other fields will have src_ip_index of 1, and the second row will have 2, etc...   because the "by" clause of the streamstats matches the "by" clause of the stats,   and because of our sort command, it turns out that all the rows painted with "1" will represent the highest count src_ip for that combination of dest_ip,dest_ip_country_name,dest_port,protocol. &lt;BR /&gt;
Which means we can then use &lt;CODE&gt;where&lt;/CODE&gt; to filter to the set of top results.&lt;/P&gt;

&lt;P&gt;Admittedly the count values are not the same as they are in your report, but it's quick and simple.&lt;/P&gt;

&lt;P&gt;If you care about the counts being correct, you can stitch in one more eventstats command. &lt;/P&gt;

&lt;P&gt;sourcetype="cisco_asa" (host="11.11.11.11" OR host="10.10.10.10" OR host="12.12.12.12" OR host="13.13.13.14") (actual_action="Deny" OR actual_action="Denied" OR actual_action="denied") dest_dom="Outside" | geoip dest_ip | eval protocol=lower(protocol) | stats count by dest_ip,dest_ip_country_name,dest_port,protocol,src_ip | sort - count | streamstats count as src_ip_index by dest_ip,dest_ip_country_name,dest_port,protocol | eventstats sum(count) as totalCount by dest_ip,dest_ip_country_name,dest_port,protocol | where src_ip_index=1 | fields - src_ip_index`&lt;/P&gt;

&lt;P&gt;This will end up with a &lt;CODE&gt;totalCount&lt;/CODE&gt; field which will have the overall count values that you had in your original results.   Hope this helps.&lt;/P&gt;

&lt;P&gt;Between eval, stats, streamstats and eventstats you can usually eliminate join and append. Although I'll admit join and append are super intuitive, whereas these faster more efficient "splunk-style" searches can feel pretty weird until you get used to them. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:12:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80233#M20284</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T14:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Search Top value of a previuos  Top Result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80234#M20285</link>
      <description>&lt;P&gt;Thanks! works but I still need to remove some duplicates. Here what I'm getting with your help:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dest_ip         Country port    protocol    src_ip          count   totalCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1   124.124.124.1   Japan   161     udp         10.10.10.9      53051   135377&lt;BR /&gt;
4   178.178.178.87  UK      843     tcp         10.10.10.75     18632   20345&lt;BR /&gt;
5   124.124.124.1   Japan   161     udp         10.10.10.161    8648    135377&lt;/P&gt;

&lt;P&gt;And I would like to get this:&lt;BR /&gt;
    dest_ip         Country port    protocol    src_ip          count   totalCount&lt;BR /&gt;
1   124.124.124.1   Japan   161     udp         10.10.10.9      53051   135377&lt;BR /&gt;
4   178.178.178.87  UK      843     tcp         10.10.10.75     18632   20345&lt;/P&gt;

&lt;P&gt;How can I remove the duplicates and keep the higher ones?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80234#M20285</guid>
      <dc:creator>acedeno</dc:creator>
      <dc:date>2020-09-28T14:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Search Top value of a previuos  Top Result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80235#M20286</link>
      <description>&lt;P&gt;I believe I'm on the right path... &lt;BR /&gt;
I add at the end of the search:&lt;BR /&gt;
... |dedup dest_ip,dest_ip_country_name,dest_port,protocol&lt;/P&gt;

&lt;P&gt;But, in some cases the count values are not the same as they are in my report. any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80235#M20286</guid>
      <dc:creator>acedeno</dc:creator>
      <dc:date>2020-09-28T14:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Search Top value of a previuos  Top Result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80236#M20287</link>
      <description>&lt;P&gt;Just a quick check - I edited my answer shortly after posting it. My first search had a problem much like this.  Are you using the unedited answer that probably generated an email to you, or the edited one on the site?&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jun 2013 16:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-Top-value-of-a-previuos-Top-Result/m-p/80236#M20287</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-06-30T16:29:00Z</dc:date>
    </item>
  </channel>
</rss>

