<?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 Calculating a baseline in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculating-a-baseline/m-p/573247#M199785</link>
    <description>&lt;P&gt;Warning: Splunk noob question.&lt;BR /&gt;&lt;BR /&gt;I have a base search:&lt;/P&gt;&lt;PRE&gt;source="Administrator_logs" name="An account failed to log on"&lt;/PRE&gt;&lt;P&gt;Using&amp;nbsp;&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Getting-Average-Number-of-Requests-Per-Hour/m-p/73506" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/Getting-Average-Number-of-Requests-Per-Hour/m-p/73506&lt;/A&gt;&amp;nbsp;I can calculate hourly averages:&lt;/P&gt;&lt;PRE&gt;source="Administrator_logs"name="An account failed to log on" | eval reqs = 1 | timechart span=1h per_hour(reqs) as AvgReqPerHour&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;What I would like to do is calculate a baseline. Having never done this before my thought is to calculate the hourly average and either standard deviation and/or some percentile, e.g. 90th, for all events as apposed to the last day/week/month although that would be interesting too.&lt;BR /&gt;&lt;BR /&gt;Eventually, this baseline calculation will be the basis for an alert, e.g. create alert if hourly count is outside 1 stddev or 90th percentile.&lt;BR /&gt;&lt;BR /&gt;Q1: How do I calculate the hourly average for all events?&lt;/P&gt;&lt;P&gt;Q2: How do I calculate the hourly standard deviation for all events?&lt;/P&gt;&lt;P&gt;Q3: How do I calculate the hourly 90th percentile for all events?&lt;/P&gt;</description>
    <pubDate>Mon, 01 Nov 2021 22:40:45 GMT</pubDate>
    <dc:creator>aenagy</dc:creator>
    <dc:date>2021-11-01T22:40:45Z</dc:date>
    <item>
      <title>Calculating a baseline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-a-baseline/m-p/573247#M199785</link>
      <description>&lt;P&gt;Warning: Splunk noob question.&lt;BR /&gt;&lt;BR /&gt;I have a base search:&lt;/P&gt;&lt;PRE&gt;source="Administrator_logs" name="An account failed to log on"&lt;/PRE&gt;&lt;P&gt;Using&amp;nbsp;&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Getting-Average-Number-of-Requests-Per-Hour/m-p/73506" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/Getting-Average-Number-of-Requests-Per-Hour/m-p/73506&lt;/A&gt;&amp;nbsp;I can calculate hourly averages:&lt;/P&gt;&lt;PRE&gt;source="Administrator_logs"name="An account failed to log on" | eval reqs = 1 | timechart span=1h per_hour(reqs) as AvgReqPerHour&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;What I would like to do is calculate a baseline. Having never done this before my thought is to calculate the hourly average and either standard deviation and/or some percentile, e.g. 90th, for all events as apposed to the last day/week/month although that would be interesting too.&lt;BR /&gt;&lt;BR /&gt;Eventually, this baseline calculation will be the basis for an alert, e.g. create alert if hourly count is outside 1 stddev or 90th percentile.&lt;BR /&gt;&lt;BR /&gt;Q1: How do I calculate the hourly average for all events?&lt;/P&gt;&lt;P&gt;Q2: How do I calculate the hourly standard deviation for all events?&lt;/P&gt;&lt;P&gt;Q3: How do I calculate the hourly 90th percentile for all events?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 22:40:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-a-baseline/m-p/573247#M199785</guid>
      <dc:creator>aenagy</dc:creator>
      <dc:date>2021-11-01T22:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating a baseline</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculating-a-baseline/m-p/573922#M200008</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/240316"&gt;@aenagy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This assumes your data is normally distributed. If it is not, you may need to transform your data before calculating statistics.&lt;/P&gt;&lt;P&gt;The timechart count aggregation should be sufficient for counting by hour.&lt;/P&gt;&lt;P&gt;Following that, you can extract the hour from _time and use the stats command to calculate the average, standard deviation, and 90th percentile by hour.&lt;/P&gt;&lt;P&gt;Here's an example using random counts:&lt;/P&gt;&lt;P&gt;| makeresults count=10000&lt;BR /&gt;| eval _time=_time-_time%3600-604800*random()/2147483647 ```uniformly distributed over 7 days```&lt;BR /&gt;| timechart fixedrange=f span=1h count&lt;BR /&gt;| eval date_hour=strftime(_time, "%H")&lt;BR /&gt;| stats avg(count) as avg_count stdev(count) as sd_count p90(count) as p90_count by date_hour&lt;/P&gt;&lt;P&gt;Using your source:&lt;/P&gt;&lt;P&gt;source="Administrator_logs" name="An account failed to log on" earliest=-7d@h latest=@h&lt;BR /&gt;| timechart span=1h count&lt;BR /&gt;| eval date_hour=strftime(_time, "%H")&lt;BR /&gt;| stats avg(count) as avg_count stdev(count) as sd_count p90(count) as p90_count by date_hour&lt;/P&gt;</description>
      <pubDate>Sat, 06 Nov 2021 20:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculating-a-baseline/m-p/573922#M200008</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2021-11-06T20:54:10Z</dc:date>
    </item>
  </channel>
</rss>

