<?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: project trendlines into future in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39333#M8967</link>
    <description>&lt;P&gt;Wow, that's pretty intense.  Looks like this may be a good candidate for a macro; I'd hate to have to retype that several times.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;  Nice work.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2011 02:09:00 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2011-02-08T02:09:00Z</dc:date>
    <item>
      <title>project trendlines into future</title>
      <link>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39331#M8965</link>
      <description>&lt;P&gt;Is there a way to make trendline project moving averages into the future?&lt;/P&gt;</description>
      <pubDate>Sat, 05 Feb 2011 01:25:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39331#M8965</guid>
      <dc:creator>ddholstadz</dc:creator>
      <dc:date>2011-02-05T01:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: project trendlines into future</title>
      <link>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39332#M8966</link>
      <description>&lt;P&gt;There actually is no easy way, I fear. You'd need to:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;compute the trendline equation to do that (y = m * _time + b) see &lt;A href="http://www.tutorvista.com/content/math/geometry/straightlines/two-point-form.php" rel="nofollow"&gt;http://www.tutorvista.com/content/math/geometry/straightlines/two-point-form.php&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;extend the time field into future&lt;/LI&gt;
&lt;LI&gt;compute the new y over time (the easy part...just an eval)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;But.... which is the best window to compute your trendline upon? 5, 20, 30, 1000 events? That totally depends on the case...  &lt;/P&gt;

&lt;P&gt;Ok, let's move on...here's my approach, in bullet point (I'll use _time as x axis, y as y axis): &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;You need to compute the best trendline you see fit your data and produce a field "y"&lt;/LI&gt;
&lt;LI&gt;To compute the equation of a line you need 2 (x,y) couples, which you can produce by moving the previous event's y and _time values to the current event. I'll use autoregress and name the two points as (curr_time,curr_y) (prev_time,prev_y)&lt;/LI&gt;
&lt;LI&gt;You do the math and compute slope (m) and y-intercept (b) -&amp;gt; here's your equation!&lt;/LI&gt;
&lt;LI&gt;Now, you said you want the future...so you don't have data for it. You'll have to "gentimes", and then put your slope and intercept into each event. &lt;/LI&gt;
&lt;LI&gt;You compute the predicted value of y&lt;/LI&gt;
&lt;LI&gt;You chart y over time&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Here's my try.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=01/01/11 end=02/28/11 increment=6h 
| eval jf=1 
| join jf [
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Get a time span and prepare to join the m and b values to all the results: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search &amp;lt;you search and computation of y here&amp;gt;
| autoregress y as prev_y  
| autoregress _time as prev_time 
| rename y as curr_y 
| eval curr_time=_time 
| head 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Head 1 gets the latest event only, which now has data for the 2 points the prediction line will pass through. Now I'll do the math&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval m=(curr_y - prev_y)/(curr_time - prev_time) 
| eval b=(prev_y * curr_time - curr_y * prev_time) / (curr_time - prev_time) 
| eval jf=1 
| fields + m b jf
] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I now have a single result with three fields only, jf (join field) is just for the join operation. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval y= m*starttime + b
| eval _time=starttime
| chart values(y) over _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your predicted y value for the future.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2011 06:20:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39332#M8966</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2011-02-07T06:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: project trendlines into future</title>
      <link>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39333#M8967</link>
      <description>&lt;P&gt;Wow, that's pretty intense.  Looks like this may be a good candidate for a macro; I'd hate to have to retype that several times.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;  Nice work.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 02:09:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39333#M8967</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2011-02-08T02:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: project trendlines into future</title>
      <link>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39334#M8968</link>
      <description>&lt;P&gt;It felt like secondary school, solving line equations...just funnier. Thanks Lowell, much appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 06:09:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/project-trendlines-into-future/m-p/39334#M8968</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2011-02-08T06:09:40Z</dc:date>
    </item>
  </channel>
</rss>

