<?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: Use predict with dynamic values in MLTK in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504635#M140929</link>
    <description>&lt;P&gt;Hello &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222543"&gt;@Deniz_Oe&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You have a syntax issue with the predict command.&amp;nbsp; The &lt;STRONG&gt;period&lt;/STRONG&gt; predict command option requires a number to be present after it, it will not accept values from another field per the documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.4/SearchReference/Predict" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.4/SearchReference/Predict&lt;/A&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;period&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;Syntax:&lt;/STRONG&gt; period=&lt;U&gt;&lt;STRONG&gt;&amp;lt;num&amp;gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;&lt;STRONG&gt;Description:&lt;/STRONG&gt; Specifies the length of the time period, or recurring cycle, in the time series data. The number must be at least 2. The LLP and LLP5 algorithms attempt to compute the length of time period if no value is specified. If you specify the span argument with the timechart command, the unit that you specify for span is the unit used for period. For example, if your search is ...|timechart span=1d foo2| predict foo2 period=3. The spans are 1 day and the period for the predict is 3 days. Otherwise, the unit for the time period is a data point. For example, if there are a thousand events, then each event is a unit. If you specify period=7, that means the data recycles after every 7 data points, or events.&lt;BR /&gt;&lt;STRONG&gt;Default:&lt;/STRONG&gt; None&lt;/P&gt;&lt;P&gt;What you are trying to do still can be accomplished, but you need to use the map command to execute your query so it passes a token of the numeric value from your macro to execute your query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index = cisco_prod 
| timechart span=1h count as logins_hour 
| fit ACF logins_hour k=200 fft=true conf_interval=95 as corr 
| top limit=2 acf(corr),Lag 
| stats max(Lag) as corr_lag 
| map search="index = cisco_prod | timechart span=1h count as logins_hour | predict \"logins_hour\" as prediction algorithm=LLP holdback=200 future_timespan=368 period=$corr_lag$ upper95=upper95 lower95=lower95"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jun 2020 15:36:13 GMT</pubDate>
    <dc:creator>dmarling</dc:creator>
    <dc:date>2020-06-16T15:36:13Z</dc:date>
    <item>
      <title>Use predict with dynamic values in MLTK</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504602#M140914</link>
      <description>&lt;P&gt;Hey!&lt;/P&gt;&lt;P&gt;So I am trying to hand the Kalman filter in Splunk's MLTK a dynamic value for the period which I first find through Auto correlation Function in the sub search and is named corr_lag:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = cisco_prod | timechart span=1h count as logins_hour |eval corr_lag= [`ACF_Correlation_Lag`]| predict "logins_hour" as prediction algorithm=LLP holdback=200 future_timespan=368 period=corr_lag upper95=upper95 lower95=lower95 | `forecastviz(368, 200, "logins_hour", 95)`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the sub search looks as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search index = cisco_prod | timechart span=1h count as logins_hour | fit ACF logins_hour k=200 fft=true conf_interval=95 as corr | top limit=2 acf(corr),Lag | stats max(Lag) as corr_lag | return $corr_lag&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somehow I must do something wrong because I always get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;command="predict", Invalid period : 'corr_lag'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the subsearch actually works fine and gives me the right period back.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help me find the right way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 13:03:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504602#M140914</guid>
      <dc:creator>Deniz_Oe</dc:creator>
      <dc:date>2020-06-16T13:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Use predict with dynamic values in MLTK</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504635#M140929</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222543"&gt;@Deniz_Oe&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You have a syntax issue with the predict command.&amp;nbsp; The &lt;STRONG&gt;period&lt;/STRONG&gt; predict command option requires a number to be present after it, it will not accept values from another field per the documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.4/SearchReference/Predict" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.4/SearchReference/Predict&lt;/A&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;period&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;Syntax:&lt;/STRONG&gt; period=&lt;U&gt;&lt;STRONG&gt;&amp;lt;num&amp;gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;&lt;STRONG&gt;Description:&lt;/STRONG&gt; Specifies the length of the time period, or recurring cycle, in the time series data. The number must be at least 2. The LLP and LLP5 algorithms attempt to compute the length of time period if no value is specified. If you specify the span argument with the timechart command, the unit that you specify for span is the unit used for period. For example, if your search is ...|timechart span=1d foo2| predict foo2 period=3. The spans are 1 day and the period for the predict is 3 days. Otherwise, the unit for the time period is a data point. For example, if there are a thousand events, then each event is a unit. If you specify period=7, that means the data recycles after every 7 data points, or events.&lt;BR /&gt;&lt;STRONG&gt;Default:&lt;/STRONG&gt; None&lt;/P&gt;&lt;P&gt;What you are trying to do still can be accomplished, but you need to use the map command to execute your query so it passes a token of the numeric value from your macro to execute your query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index = cisco_prod 
| timechart span=1h count as logins_hour 
| fit ACF logins_hour k=200 fft=true conf_interval=95 as corr 
| top limit=2 acf(corr),Lag 
| stats max(Lag) as corr_lag 
| map search="index = cisco_prod | timechart span=1h count as logins_hour | predict \"logins_hour\" as prediction algorithm=LLP holdback=200 future_timespan=368 period=$corr_lag$ upper95=upper95 lower95=lower95"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 15:36:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504635#M140929</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2020-06-16T15:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use predict with dynamic values in MLTK</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504741#M140964</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215385"&gt;@dmarling&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;thanks for the quick answer! However, if I now run the query&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = cisco_prod 
| timechart span=1h count as logins_hour 
| fit ACF logins_hour k=200 fft=true conf_interval=95 as corr 
| top limit=2 acf(corr),Lag 
| stats max(Lag) as corr_lag 
| map search="index = cisco_prod | timechart span=1h count as logins_hour | predict \"logins_hour\" as prediction algorithm=LLP holdback=200 future_timespan=368 period=$corr_lag$ upper95=upper95 lower95=lower95"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It returns no results. I have not worked yet with map search, so I don't know if I have to do anything additional for it to work.&lt;/P&gt;&lt;P&gt;Would be grateful for further advice, thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: adding a "search=" into the map search did the trick, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 06:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-predict-with-dynamic-values-in-MLTK/m-p/504741#M140964</guid>
      <dc:creator>Deniz_Oe</dc:creator>
      <dc:date>2020-06-17T06:48:45Z</dc:date>
    </item>
  </channel>
</rss>

