<?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 do I count by a field and then use that count to sort by in a table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71849#M17961</link>
    <description>&lt;P&gt;I would say this is the most direct way of implementing what you are looking for:&lt;/P&gt;

&lt;P&gt;sourcetype=suricata* NOT tag=dev_profiler severity="high" signature="ET SHELLCODE Possible Call with No Offset UDP Shellcode" | top severity,signature,src,src_port,dest,dest_port limit=50&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 13:35:04 GMT</pubDate>
    <dc:creator>krugger</dc:creator>
    <dc:date>2020-09-28T13:35:04Z</dc:date>
    <item>
      <title>How do I count by a field and then use that count to sort by in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71848#M17960</link>
      <description>&lt;P&gt;I'm new to Splunk we just started using it recently so please forgive the newbie question.&lt;/P&gt;

&lt;P&gt;Current search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=suricata* NOT tag=dev_profiler severity="high" signature="ET SHELLCODE Possible Call with No Offset UDP Shellcode" | table severity signature src src_port dest dest_port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results in:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;severity     signature     src     src_port     dest     dest_port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;I want to modify the search to provide a summary of the number of events comming from each src IP to the dest IP and be able to sort by that count.&lt;/P&gt;

&lt;P&gt;Desired:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;severity     signature     src     dest     dest_port     count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;I've tried a few different searches such as this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=suricata* NOT tag=dev_profiler severity="high" signature="ET SHELLCODE Possible Call with No Offset UDP Shellcode" | stats count by src | sort -num(count) | table severity signature src dest dest_port count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However this only populates the src and count column.  I'm not quite sure what I'm missing.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 15:46:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71848#M17960</guid>
      <dc:creator>digital_alchemy</dc:creator>
      <dc:date>2013-03-22T15:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count by a field and then use that count to sort by in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71849#M17961</link>
      <description>&lt;P&gt;I would say this is the most direct way of implementing what you are looking for:&lt;/P&gt;

&lt;P&gt;sourcetype=suricata* NOT tag=dev_profiler severity="high" signature="ET SHELLCODE Possible Call with No Offset UDP Shellcode" | top severity,signature,src,src_port,dest,dest_port limit=50&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71849#M17961</guid>
      <dc:creator>krugger</dc:creator>
      <dc:date>2020-09-28T13:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count by a field and then use that count to sort by in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71850#M17962</link>
      <description>&lt;P&gt;This works?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your search |  stats count by severity src dest dest_port signature
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 15:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71850#M17962</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-03-22T15:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count by a field and then use that count to sort by in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71851#M17963</link>
      <description>&lt;P&gt;If you use a stats, only the fields and results that are in the stats will exists after.&lt;/P&gt;

&lt;P&gt;the basic search will be &lt;BR /&gt;
&lt;CODE&gt;sourcetype=suricata* NOT tag=dev_profiler severity="high" signature="ET SHELLCODE Possible Call with No Offset UDP Shellcode" &lt;BR /&gt;
| stats count by  severity signature src dest dest_port &lt;BR /&gt;
| sort -num(count)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and if you just want the count per src and dest, you can group the others fields in a multiline result&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=suricata* NOT tag=dev_profiler severity="high" signature="ET SHELLCODE Possible Call with No Offset UDP Shellcode" &lt;BR /&gt;
| stats count  values(severity) AS list_severity values(signature) AS list_signature values(dest_port) AS list_dest_port  by src dest &lt;BR /&gt;
| sort -num(count)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 15:55:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71851#M17963</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-03-22T15:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count by a field and then use that count to sort by in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71852#M17964</link>
      <description>&lt;P&gt;Works perfectly... thanks for such a quick reply.  I didn't even think of the top command I was stuck on using count and sort.&lt;/P&gt;

&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2013 15:57:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-count-by-a-field-and-then-use-that-count-to-sort-by-in/m-p/71852#M17964</guid>
      <dc:creator>digital_alchemy</dc:creator>
      <dc:date>2013-03-22T15:57:59Z</dc:date>
    </item>
  </channel>
</rss>

