<?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 improve the performance of my search to find new opened ports in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292847#M35005</link>
    <description>&lt;P&gt;Do you mean, "Which have been running every hour for the past 24 hours"? or "Which I have been monitoring for at least 24 hours?"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=Unix:ListeningPorts 
| table  _time, host, dest_port 
| bin _time span=1h 
| eventstats dc(_time) as OpHours, min(_time) as FirstHostEvent by host
| stats min(_time) as FirstPortEvent, max(OpHours) as OpHours, max(FirstHostEvent) as FirstHostEvent by host, dest_port
| table host, FirstHostEvent, OpHours, dest_port, FirstPortEvent
| sort 0 host dest_port
| where FirstHostEvent &amp;lt; relative_time(now(),"-1d") AND  FirstPortEvent &amp;gt; relative_time(now(),"-1h") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The last comparison assuming an hourly scan.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 21:05:40 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-02-09T21:05:40Z</dc:date>
    <item>
      <title>How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292841#M34999</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to find new ports that are opened up on a system where I have 24 hours of existing data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=Unix:ListeningPorts | join host [search sourcetype=Unix:ListeningPorts | bucket span=1h _time | dedup _time,host | stats count AS hostcount by host | table host,hostcount] | bucket span=1h _time | dedup host,dest_port,_time | stats values(hostcount) AS hostcount count as num_data_samples by host,dest_port | where hostcount = 24 AND num_data_samples = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search takes few minutes to complete and i'm trying to get the time down to run as an alert.  I believe the subsearch is causing the delay, but i'm not sure how to get the number of times a host reported in a 24 hour period.  If I don't use the subsearch then I can't do the dedup to remove the multiple entries per hour (multiple dest_port) for a host. &lt;/P&gt;

&lt;P&gt;Does anyone have any suggestions on how to make this better?&lt;/P&gt;

&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:21:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292841#M34999</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2017-02-09T17:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292842#M35000</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=Unix:ListeningPorts | bucket span=1h _time | dedup host,dest_port,_time | stats dc(_time) AS hostcount count as num_data_samples by host,dest_port | where hostcount = 24 AND num_data_samples = 1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:26:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292842#M35000</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-09T17:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292843#M35001</link>
      <description>&lt;P&gt;so simple!!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 18:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292843#M35001</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2017-02-09T18:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292844#M35002</link>
      <description>&lt;P&gt;Yep, same conclusion I came to.  &lt;/P&gt;

&lt;P&gt;The inner query was not calculating a hostcount, but an hourcount for how many hours a host was active over the time period.&lt;/P&gt;

&lt;P&gt;However, I'm not sure what the business meaning of "I have 24 hours of data " is.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 20:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292844#M35002</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T20:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292845#M35003</link>
      <description>&lt;P&gt;This is an awesome idea!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 20:54:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292845#M35003</guid>
      <dc:creator>tred23</dc:creator>
      <dc:date>2017-02-09T20:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292846#M35004</link>
      <description>&lt;P&gt;I wanted to avoid false positives for systems being turned up in an active environment. &lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:00:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292846#M35004</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2017-02-09T21:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292847#M35005</link>
      <description>&lt;P&gt;Do you mean, "Which have been running every hour for the past 24 hours"? or "Which I have been monitoring for at least 24 hours?"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=Unix:ListeningPorts 
| table  _time, host, dest_port 
| bin _time span=1h 
| eventstats dc(_time) as OpHours, min(_time) as FirstHostEvent by host
| stats min(_time) as FirstPortEvent, max(OpHours) as OpHours, max(FirstHostEvent) as FirstHostEvent by host, dest_port
| table host, FirstHostEvent, OpHours, dest_port, FirstPortEvent
| sort 0 host dest_port
| where FirstHostEvent &amp;lt; relative_time(now(),"-1d") AND  FirstPortEvent &amp;gt; relative_time(now(),"-1h") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The last comparison assuming an hourly scan.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:05:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292847#M35005</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T21:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292848#M35006</link>
      <description>&lt;P&gt;Have been monitored for at least 24 hours.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:08:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292848#M35006</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2017-02-09T21:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292849#M35007</link>
      <description>&lt;P&gt;I believe you missed field OpHours and FirstHostEvent  to be included in stats.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:08:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292849#M35007</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-09T21:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292850#M35008</link>
      <description>&lt;P&gt;crud, you're right.&lt;/P&gt;

&lt;P&gt;Hey, I added them using eventstats, so they're scrolled off to the right in my head from all the other fields.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292850#M35008</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T21:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292851#M35009</link>
      <description>&lt;P&gt;This strategy is going to throw an alert whenever the last use of a port scrolls off the time horizon that you are searching.  Might want to merge in an inputcsv and send out an outputcsv with the known hosts and ports.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:17:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292851#M35009</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T21:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292852#M35010</link>
      <description>&lt;P&gt;Ugh, good point.  I'll have to think that through.&lt;/P&gt;

&lt;P&gt;Thanks again!!!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292852#M35010</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2017-02-09T21:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve the performance of my search to find new opened ports</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292853#M35011</link>
      <description>&lt;P&gt;I believe this approach would account for systems where applications are being decommissioned.   Here i'm only looking for ports = 1 and the last recorded time was within the last hour from the end of the search.  Does this look right?&lt;/P&gt;

&lt;P&gt;|pivot SecOps__Listening_Ports Unix_Listening_Ports SPLITROW _time, SPLITROW host, SPLITROW dest_port | eventstats last(_time) AS maxtime | bucket span=1h _time | dedup host,dest_port,_time,maxtime | stats values(maxtime) AS maxtime last(_time) AS lasttime dc(_time) AS hostcount count as portcount by host,dest_port | where hostcount &amp;gt;= 24 AND portcount = 1 AND lasttime &amp;gt;= relative_time(maxtime, "-1h")&lt;/P&gt;

&lt;P&gt;Sorry, also switched it to a pivot table.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:49:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-to-improve-the-performance-of-my-search-to-find-new-opened/m-p/292853#M35011</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2020-09-29T12:49:45Z</dc:date>
    </item>
  </channel>
</rss>

