<?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: Is using count over streamstats time_window not timechart span possible? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215516#M63175</link>
    <description>&lt;P&gt;Try using &lt;STRONG&gt;first&lt;/STRONG&gt;() and &lt;STRONG&gt;last&lt;/STRONG&gt;() statistical functions:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="security" interface=igb0  direction=in source_ip=* destination_port=*
| streamstats time_window=2m count as "attacks" dc(source_ip) as "attackers", dc(destination_port) as "attacked ports" first(_time) as FirstTime last(_time) as LastTime 
| search attacks&amp;gt;150 
| eval FirstTime=strftime(FirstTime,"%c")
| eval LastTime=strftime(LastTime,"%c")
| table attacks attackers "attacked ports" FirstTime LastTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I have added source_ip=* and destination_port=* assuming they are always present. If not remove that from the base search. I have used strftime to convert to String Date Format.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:18:17 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2020-09-29T12:18:17Z</dc:date>
    <item>
      <title>Is using count over streamstats time_window not timechart span possible?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215515#M63174</link>
      <description>&lt;P&gt;Hello splunkfans,&lt;/P&gt;

&lt;P&gt;i'm kind of running out of ideas and this is my first contact to streamstats. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;
I am working on a statistic of botnet portscans on my firewalllogs. The goal is based on the firewallevents on a specific interface and direction, to show how many different public IPs have scanned how many dest_ports, events=attacks, and in what timerange.&lt;BR /&gt;
The break where i assume it is a botnet portscan is when i get over 150 events in a 2 min flow.&lt;/P&gt;

&lt;P&gt;Here is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="security" interface=igb0  direction=in | streamstats time_window=2min count(_raw) as "attacks" distinct_count(source_ip) as "attackers", distinct_count(destination_port) as "attacked ports"  | search attacks&amp;gt;150
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What i am looking at due to my search is a nice timeline over the last 3 days with &lt;STRONG&gt;3&lt;/STRONG&gt; peaks that represent the time_window=2min of my streamstats.&lt;BR /&gt;
My goal is just to get a table of these peaks and the timerange they occured.&lt;BR /&gt;
Like this: table attacks, attackers, "attacked ports", //"timerange first and last event"//&lt;/P&gt;

&lt;P&gt;Problem i have is that this table without time (as i have no solution for that), shows me all streamstats events like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;attacks     attackers       attacked ports  
151            34             9
152            34             9
153            34             9
154            34             10
155            34             10
156            34             10
157            34             10 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Searchresult of just the streamstats is of cause the events themselfs that are relevant in the time_window.&lt;/P&gt;

&lt;P&gt;How can i get just the peaks of this and the timerange between the first and last event of these?&lt;BR /&gt;
I tried so many combos with max() and top, but as i dont know how many peaks will occure, i cant regulate the top.&lt;BR /&gt;
A timechart seams to be a dirty solution with a span=2min but a portscan can happen between 00:01:45 and 00:02:15 and would be split in half and not recognised.&lt;/P&gt;

&lt;P&gt;Anyone can guide me in the right direction on how to get the tops of this stream? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 19:38:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215515#M63174</guid>
      <dc:creator>RayLio</dc:creator>
      <dc:date>2017-01-05T19:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Is using count over streamstats time_window not timechart span possible?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215516#M63175</link>
      <description>&lt;P&gt;Try using &lt;STRONG&gt;first&lt;/STRONG&gt;() and &lt;STRONG&gt;last&lt;/STRONG&gt;() statistical functions:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="security" interface=igb0  direction=in source_ip=* destination_port=*
| streamstats time_window=2m count as "attacks" dc(source_ip) as "attackers", dc(destination_port) as "attacked ports" first(_time) as FirstTime last(_time) as LastTime 
| search attacks&amp;gt;150 
| eval FirstTime=strftime(FirstTime,"%c")
| eval LastTime=strftime(LastTime,"%c")
| table attacks attackers "attacked ports" FirstTime LastTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I have added source_ip=* and destination_port=* assuming they are always present. If not remove that from the base search. I have used strftime to convert to String Date Format.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215516#M63175</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T12:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is using count over streamstats time_window not timechart span possible?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215517#M63176</link>
      <description>&lt;P&gt;If you are looking for just the peaks, and not the individual events, then you probably want to use timechart instead.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="security" interface=igb0  direction=in 
| timechart span=2min count as "attacks", dc(source_ip) as "attackers", dc(destination_port) as "attacked ports", min(_time) as "start Time", max(_time) as "End Time"  | search attacks&amp;gt;150
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;fix formatting&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 21:28:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215517#M63176</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-05T21:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Is using count over streamstats time_window not timechart span possible?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215518#M63177</link>
      <description>&lt;P&gt;We are getting close, thanks for the replies!&lt;/P&gt;

&lt;P&gt;I tried this like niketnilay answered with modifications. It is very close, just have to get rid of the overlaps, see below. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="security" interface=igb0  direction=in
| streamstats time_window=2min count as "attacks" dc(source_ip) as "attackers", dc(destination_port) as "attacked ports" first(_time) as FirstTime last(_time) as LastTime
| search attacks&amp;gt;150 
| eval FirstTime=strftime(FirstTime,"%c") 
| eval LastTime=strftime(LastTime,"%c") 
| table attacks attackers "attacked ports" FirstTime LastTime 
| sort -attacks 
| dedup FirstTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Got me this:&lt;/P&gt;

&lt;P&gt;attacks     attackers       attacked ports      FirstTime       LastTime&lt;BR /&gt;&lt;BR /&gt;
902     90      106     Tue Jan 3 16:34:06 2017     Tue Jan 3 16:32:12 2017&lt;BR /&gt;
693     69      81  Tue Jan 3 00:15:08 2017     Tue Jan 3 00:13:19 2017&lt;BR /&gt;
691     68      79  Tue Jan 3 00:14:26 2017     Tue Jan 3 00:12:30 2017&lt;BR /&gt;
565     91      22  Tue Jan 3 16:34:31 2017     Tue Jan 3 16:32:34 2017&lt;BR /&gt;
426     70      14  Tue Jan 3 00:15:41 2017     Tue Jan 3 00:13:42 2017&lt;BR /&gt;
371     70      13  Tue Jan 3 00:15:46 2017     Tue Jan 3 00:13:47 2017&lt;BR /&gt;
339     34      44  Wed Jan 4 23:23:57 2017     Wed Jan 4 23:22:16 2017&lt;BR /&gt;
264     33      41  Wed Jan 4 23:23:03 2017     Wed Jan 4 23:21:04 2017&lt;BR /&gt;
262     91      19  Tue Jan 3 16:34:54 2017     Tue Jan 3 16:32:55 2017&lt;BR /&gt;
248     34      41  Wed Jan 4 23:22:59 2017     Wed Jan 4 23:21:01 2017&lt;BR /&gt;
239     35      12  Wed Jan 4 23:24:32 2017     Wed Jan 4 23:22:33 2017&lt;BR /&gt;
202     35      41  Wed Jan 4 23:22:50 2017     Wed Jan 4 23:20:51 2017 &lt;/P&gt;

&lt;P&gt;Yes DalJeanis i'm just looking for the peaks, but a timechart isn't accurate if the attack is cut into two time spans. Am i wrong?&lt;/P&gt;

&lt;P&gt;I'm wondering why these dont have the same firsttime... There are overlaps in the timeranges. This is due to the search attacks&amp;gt;150 after the streamline.&lt;BR /&gt;
Any chance to get this into the stream as a condition?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 23:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-using-count-over-streamstats-time-window-not-timechart-span/m-p/215518#M63177</guid>
      <dc:creator>RayLio</dc:creator>
      <dc:date>2017-01-05T23:14:52Z</dc:date>
    </item>
  </channel>
</rss>

