<?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 eval with mathematical calculations? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83049#M21097</link>
    <description>&lt;P&gt;I'm trying to do something a little wonky here, so please bear with me. The code below is the &lt;EM&gt;logical&lt;/EM&gt; flow of what I'm trying to accomplish. However I know for a fact it won't work. Can you give me some insight?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval threshold=(outlier action=rm param=10 (stdev(count)))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically I'm trying to create a field, "threshold", which calculates the standard deviation of my results, removing any outliers prior to calculating the standard deviation. (Basically, I don't want that one result of 7,000 skewing my standard deviation upwards when normally it would have been, say, 10).&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2013 15:49:45 GMT</pubDate>
    <dc:creator>tfitzgerald15</dc:creator>
    <dc:date>2013-10-04T15:49:45Z</dc:date>
    <item>
      <title>eval with mathematical calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83049#M21097</link>
      <description>&lt;P&gt;I'm trying to do something a little wonky here, so please bear with me. The code below is the &lt;EM&gt;logical&lt;/EM&gt; flow of what I'm trying to accomplish. However I know for a fact it won't work. Can you give me some insight?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval threshold=(outlier action=rm param=10 (stdev(count)))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically I'm trying to create a field, "threshold", which calculates the standard deviation of my results, removing any outliers prior to calculating the standard deviation. (Basically, I don't want that one result of 7,000 skewing my standard deviation upwards when normally it would have been, say, 10).&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2013 15:49:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83049#M21097</guid>
      <dc:creator>tfitzgerald15</dc:creator>
      <dc:date>2013-10-04T15:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: eval with mathematical calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83050#M21098</link>
      <description>&lt;P&gt;Is this what you're looking for...here's a search that does what I think you are asking for on indexer lag (_indextime-_time).  So if this does what you're looking for you'll just need to modify to fit your search/data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | eval indexer_lag =_indextime - _time 
| eventstats p25(indexer_lag) as q1, p75(indexer_lag) as q3 | eval iqr=q3-q1 | eval threshold=10*iqr 
| where indexer_lag &amp;lt; threshold 
| eventstats stdev(indexer_lag) as threshold_stddev
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'll explain each part:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | eval indexer_lag =_indextime - _time 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;^^^ Calc our index lag for each event&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eventstats p25(indexer_lag) as q1, p75(indexer_lag) as q3 | eval iqr=q3-q1 | eval threshold=10*iqr 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;^^^ Now use eventstats to get our q1, q3 in-line with our events, then calc our interquartile range, and our threshold based on your choosing of 10*iqr from your original post.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where indexer_lag &amp;lt; threshold 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;^^^ Only keep events that have lag less than our threshold.  e.g. remove our 10*iqr outliers&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats stdev(indexer_lag) as threshold_stddev
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;^^^ Finally use eventstats again to calculate the new standard deviation in-line based on our new list of events.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:54:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83050#M21098</guid>
      <dc:creator>jhupka</dc:creator>
      <dc:date>2020-09-28T14:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: eval with mathematical calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83051#M21099</link>
      <description>&lt;P&gt;Awesome, thanks! I do just have one question. I'm not pointing to a specific indexer, I'm looking at a specific sourcetype. Would I still need the indexer_lag, and what does that represent? Apologies for the admitted newbie question there.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2013 15:30:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83051#M21099</guid>
      <dc:creator>tfitzgerald15</dc:creator>
      <dc:date>2013-10-07T15:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: eval with mathematical calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83052#M21100</link>
      <description>&lt;P&gt;So you don't need the indexer_lag field, per se, but your overall search will be similar.  If you're looking at specific sourcetype over all indexes, then your search may start like this:&lt;/P&gt;

&lt;P&gt;index=* sourcetype=tfitzgerald15s_type |&lt;/P&gt;

&lt;P&gt;And the indexer_lag is just a new field I am calculating based on what I want to base my threshold on for the example.  So in your case it might be a calculation you have to do for CPU usage, or HTTP response times, or transaction duration.&lt;/P&gt;

&lt;P&gt;Also, if this answers your question don't forget to accept/up-vote the answer  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2013 16:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-with-mathematical-calculations/m-p/83052#M21100</guid>
      <dc:creator>jhupka</dc:creator>
      <dc:date>2013-10-07T16:13:45Z</dc:date>
    </item>
  </channel>
</rss>

