<?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 Stdev against Null Time Bucket- How to create a rule alert on internal IP scanning? in Deployment Architecture</title>
    <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460001#M24183</link>
    <description>&lt;P&gt;I've read quite a few forum posts about this but honestly didn't find a great solution for my use case (note that is probably because I didn't fully understand some of the items going on).&lt;/P&gt;
&lt;P&gt;I'm trying to create a rule to alert on internal IP scanning. Below is my current logic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;index="firewall*"
| bucket _time span=15m@m
| stats dc(dest_ip) as num_dest_ips values(dest_ip) as dest_ips dc(dest_port) as num_dest_ports values(dest_port) as dest_ports count by src_ip, _time
| eventstats avg(num_dest_ips) as avg stdev(num_dest_ips) as stdev by src_ip | eval avg = round(avg,2) | eval stdev = round(stdev,2)
| lookup dnslookup clientip AS src_ip OUTPUT clienthost as src_dns
| eval temp=split(src_dns,".") | eval src_dns=mvindex(temp,0)
| eval src_system = coalesce(src_dns, src_ip)
| search NOT src_system=dns*
| eval lower_bound = avg-(stdev*.3) | eval lower_bound = round(lower_bound,2)
| eval upper_bound = avg+(stdev*.3) | eval upper_bound = round(upper_bound,2)
| eval isOutlier = if(dest_ips&amp;gt;upper_bound OR dest_ips&amp;lt;lower_bound,1,0)
| eval difference = upper_bound-lower_bound | eval different = round(different,2)
| table _time, src_ip, src_system, dest_ips, num_dest_ips, dest_ports, num_dest_ports, count, avg, lower_bound, upper_bound, difference, stdev, isOutlier
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works very well but as I mentioned, if 192.168.1.1 has no entries during a 15 min time bucket, then no entries will show up and therefore the math won't occur.&lt;/P&gt;
&lt;P&gt;I've seen some posts where they append data and make the bucket command work but this is a fairly large index and I'd prefer not to double up on the search. I've seen others that recommend using timechart but my confusion on that front is how I would get all of my various stats commands to work with it.&lt;/P&gt;
&lt;P&gt;Overall, I Just want something like the table below to occur and the 9:15 line be populated to zero if there are truly no entries. Unless there is a better way to do this entire setup, which I'm definitely open to.&lt;/P&gt;
&lt;P&gt;_time src_ip num_dest_ips avg&lt;BR /&gt;9:00 192.168.1.1 30 15&lt;BR /&gt;9:15 192.168.1.1 0 15&lt;/P&gt;
&lt;P&gt;Any hep would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;Below is what I would like to see.&lt;IMG src="https://community.splunk.com/storage/temp/276722-splunk-int-scan.png" border="0" alt="alt text" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 May 2022 15:17:07 GMT</pubDate>
    <dc:creator>ericl42</dc:creator>
    <dc:date>2022-05-16T15:17:07Z</dc:date>
    <item>
      <title>Stdev against Null Time Bucket- How to create a rule alert on internal IP scanning?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460001#M24183</link>
      <description>&lt;P&gt;I've read quite a few forum posts about this but honestly didn't find a great solution for my use case (note that is probably because I didn't fully understand some of the items going on).&lt;/P&gt;
&lt;P&gt;I'm trying to create a rule to alert on internal IP scanning. Below is my current logic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;index="firewall*"
| bucket _time span=15m@m
| stats dc(dest_ip) as num_dest_ips values(dest_ip) as dest_ips dc(dest_port) as num_dest_ports values(dest_port) as dest_ports count by src_ip, _time
| eventstats avg(num_dest_ips) as avg stdev(num_dest_ips) as stdev by src_ip | eval avg = round(avg,2) | eval stdev = round(stdev,2)
| lookup dnslookup clientip AS src_ip OUTPUT clienthost as src_dns
| eval temp=split(src_dns,".") | eval src_dns=mvindex(temp,0)
| eval src_system = coalesce(src_dns, src_ip)
| search NOT src_system=dns*
| eval lower_bound = avg-(stdev*.3) | eval lower_bound = round(lower_bound,2)
| eval upper_bound = avg+(stdev*.3) | eval upper_bound = round(upper_bound,2)
| eval isOutlier = if(dest_ips&amp;gt;upper_bound OR dest_ips&amp;lt;lower_bound,1,0)
| eval difference = upper_bound-lower_bound | eval different = round(different,2)
| table _time, src_ip, src_system, dest_ips, num_dest_ips, dest_ports, num_dest_ports, count, avg, lower_bound, upper_bound, difference, stdev, isOutlier
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works very well but as I mentioned, if 192.168.1.1 has no entries during a 15 min time bucket, then no entries will show up and therefore the math won't occur.&lt;/P&gt;
&lt;P&gt;I've seen some posts where they append data and make the bucket command work but this is a fairly large index and I'd prefer not to double up on the search. I've seen others that recommend using timechart but my confusion on that front is how I would get all of my various stats commands to work with it.&lt;/P&gt;
&lt;P&gt;Overall, I Just want something like the table below to occur and the 9:15 line be populated to zero if there are truly no entries. Unless there is a better way to do this entire setup, which I'm definitely open to.&lt;/P&gt;
&lt;P&gt;_time src_ip num_dest_ips avg&lt;BR /&gt;9:00 192.168.1.1 30 15&lt;BR /&gt;9:15 192.168.1.1 0 15&lt;/P&gt;
&lt;P&gt;Any hep would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;Below is what I would like to see.&lt;IMG src="https://community.splunk.com/storage/temp/276722-splunk-int-scan.png" border="0" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 15:17:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460001#M24183</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2022-05-16T15:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Stdev against Null Time Bucket</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460002#M24184</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; index="firewall*"
 | bucket _time span=15m@m
 | timechart limit=0 cont=f dc(dest_ip) as num_dest_ips values(dest_ip) as dest_ips dc(dest_port) as num_dest_ports values(dest_port) as dest_ports count by src_ip
 | eventstats avg(num_dest_ips) as avg stdev(num_dest_ips) as stdev by src_ip | eval avg = round(avg,2) | eval stdev = round(stdev,2)
 | lookup dnslookup clientip AS src_ip OUTPUT clienthost as src_dns
 | eval temp=split(src_dns,".") | eval src_dns=mvindex(temp,0)
 | eval src_system = coalesce(src_dns, src_ip)
 | search NOT src_system=dns*
 | eval lower_bound = avg-(stdev*.3) | eval lower_bound = round(lower_bound,2)
 | eval upper_bound = avg+(stdev*.3) | eval upper_bound = round(upper_bound,2)
 | eval isOutlier = if(dest_ips&amp;gt;upper_bound OR dest_ips&amp;lt;lower_bound,1,0)
 | eval difference = upper_bound-lower_bound | eval different = round(different,2)
 | table _time, src_ip, src_system, dest_ips, num_dest_ips, dest_ports, num_dest_ports, count, avg, lower_bound, upper_bound, difference, stdev, isOutlier
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I changed it a little.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 12:09:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460002#M24184</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-11T12:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Stdev against Null Time Bucket</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460003#M24185</link>
      <description>&lt;P&gt;Thanks for your response. I tried your query and the only thing I got was two rows that did a 9:00 and 9:15 bucket but no other data is in any of the other columns. &lt;/P&gt;

&lt;P&gt;Attaching a screenshot to my initial question of what I would like to see and then I'll only alert where outLier&amp;gt;0.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 14:30:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460003#M24185</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-12-11T14:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Stdev against Null Time Bucket</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460004#M24186</link>
      <description>&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Standard_deviation"&gt;Standard_deviation&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;the time has only one ip, so stdev is 0. &lt;BR /&gt;
It can't be helped.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval isOutlier = if(stdev !=0 AND (dest_ips&amp;gt;upper_bound OR dest_ips&amp;lt;lower_bound),1,0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How about changing the conditions?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 17:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460004#M24186</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-11T17:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Stdev against Null Time Bucket</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460005#M24187</link>
      <description>&lt;P&gt;I like the concept of potentially changing the logic if I can't make the other time show num_dest_ips as 0. However, I could see there being issues where if two hosts have the same amount of IPs during both buckets (e.g. 20), then the stdev is going to be 0 there too.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:18:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460005#M24187</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2020-09-30T03:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Stdev against Null Time Bucket</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460006#M24188</link>
      <description>&lt;P&gt;I finally found a solution using a combination of timechart which instantly adds 0 to empty bucks and then untabling it so I can then format it however I want.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=5m limit=0 dc(dest_ip) as num_dest_ips by src_ip
| untable _time, src_ip, num_dest_ips
| eventstats avg(num_dest_ips) as avg stdev(num_dest_ips) as stdev by src_ip | eval avg = round(avg,2) | eval stdev = round(stdev,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 19:09:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/460006#M24188</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-12-12T19:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Stdev against Null Time Bucket</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/597953#M25621</link>
      <description>&lt;P&gt;Yes, this worked for me as well. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 14:18:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Stdev-against-Null-Time-Bucket-How-to-create-a-rule-alert-on/m-p/597953#M25621</guid>
      <dc:creator>ErikA</dc:creator>
      <dc:date>2022-05-16T14:18:20Z</dc:date>
    </item>
  </channel>
</rss>

