<?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 do you add the average and the standard deviation as a new field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425922#M172653</link>
    <description>&lt;P&gt;You need to do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=RAS AND (EventCode=20272) AND ConnectionID!="NA" AND UserID="XYZ" 
| dedup ConnectionID 
| bucket _time span=1mon@mon 
| stats sum(Data_Sent) as Monthly_Total_Sent stdev(Data_Sent) as Monthly_Sent_Stdev by _time UserID 
| eval 'Monthly_Avg_Sent(MB)'=round(Monthly_Avg_Sent/(1024*1024),2), 'Monthly_Sent_Stdev(MB)'=round(Monthly_Sent_Stdev/(1024*1024),1),'Abnormal_Sent_Limit(MB)'= 2 * 'Monthly_Sent_Stdev(MB)' + 'Monthly_Avg_Sent(MB)'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As a general rule, its a good idea to keep your field names very simple. and then just &lt;CODE&gt;rename&lt;/CODE&gt; to proper names at the very end. That way you don't need to worry about single quoting fields.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Mar 2019 23:35:39 GMT</pubDate>
    <dc:creator>chrisyounger</dc:creator>
    <dc:date>2019-03-07T23:35:39Z</dc:date>
    <item>
      <title>How do you add the average and the standard deviation as a new field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425921#M172652</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;This might be trivial question, but I am having a hard time to figure it out. Any help is greatly appreciated.&lt;/P&gt;

&lt;P&gt;Here is the problem:&lt;/P&gt;

&lt;P&gt;I have logs from remote VPN servers reporting the sent and received data in each session for each user.&lt;/P&gt;

&lt;P&gt;I am trying to calculate the average of the data sent, and standard deviation over a month, then add the average and twice the calculated standard deviation together as the alerting threshold for the user. &lt;BR /&gt;
However, I cannot add the value of the average and the stddev !!&lt;/P&gt;

&lt;P&gt;Here is the SPL I have developed for this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=RAS AND (EventCode=20272) AND ConnectionID!="NA" AND UserID="XYZ"
| dedup ConnectionID
| bucket _time span=1mon@mon
| stats sum(Data_Sent) as Monthly_Total_Sent stdev(Data_Sent) as Monthly_Sent_Stdev by _time UserID
| eval Monthly_Avg_Sent(MB)=round(Monthly_Avg_Sent/(1024*1024),2), Monthly_Sent_Stdev(MB)=round(Monthly_Sent_Stdev/(1024*1024),1),Abnormal_Sent_Limit(MB)=2*Monthly_Sent_Stdev(MB)+Monthly_Avg_Sent(MB)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, Splunk errors out on the Abnormal_Sent_Limit(MB) calculation!!&lt;/P&gt;

&lt;P&gt;The error i see is: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'eval' command: The&lt;BR /&gt;
'monthly_sent_stdev' function is&lt;BR /&gt;
unsupported or undefined.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I also have tried Values() but with the same results. I mean :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Abnormal_Sent_Limit(MB)=2*values(Monthly_Sent_Stdev(MB))+values(Monthly_Avg_Sent(MB))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am pretty sure i am doing something wrong, but I don't know what that is!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:36:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425921#M172652</guid>
      <dc:creator>mpasha</dc:creator>
      <dc:date>2020-09-29T23:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add the average and the standard deviation as a new field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425922#M172653</link>
      <description>&lt;P&gt;You need to do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=RAS AND (EventCode=20272) AND ConnectionID!="NA" AND UserID="XYZ" 
| dedup ConnectionID 
| bucket _time span=1mon@mon 
| stats sum(Data_Sent) as Monthly_Total_Sent stdev(Data_Sent) as Monthly_Sent_Stdev by _time UserID 
| eval 'Monthly_Avg_Sent(MB)'=round(Monthly_Avg_Sent/(1024*1024),2), 'Monthly_Sent_Stdev(MB)'=round(Monthly_Sent_Stdev/(1024*1024),1),'Abnormal_Sent_Limit(MB)'= 2 * 'Monthly_Sent_Stdev(MB)' + 'Monthly_Avg_Sent(MB)'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As a general rule, its a good idea to keep your field names very simple. and then just &lt;CODE&gt;rename&lt;/CODE&gt; to proper names at the very end. That way you don't need to worry about single quoting fields.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 23:35:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425922#M172653</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-03-07T23:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add the average and the standard deviation as a new field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425923#M172654</link>
      <description>&lt;P&gt;i changed the variable names but still nothing shows up!! here is what i have done again:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=RAS AND (EventCode=20272) AND ConnectionID!="NA" AND UserID="XYZ"
| dedup ConnectionID
| bucket _time span=1mon@mon
| stats sum(Data_Sent) as MTSent stdev(Data_Sent) as MSStdev avg(Data_Sent) as MAvgSent by _time UserID
| eval MTSentMB=round(MTSent/(1024*1024),2), MAvgSentMB=round(MAvgSent/(1024*1024),2),  MSentStdevMB=round(MSStdev/(1024*1024),1)
| eval  AbSentLimMB=2*(MSStdevMB)
| sort 0 -_time
| table _time UserID MTSentMB MAvgSentMB MMaxSentMB MSentStdevMB  AbSentLimMB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;all but the AbSentLimMB return values!!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 19:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-the-average-and-the-standard-deviation-as-a-new/m-p/425923#M172654</guid>
      <dc:creator>mpasha</dc:creator>
      <dc:date>2019-03-08T19:10:49Z</dc:date>
    </item>
  </channel>
</rss>

