<?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: Adding a Linear Trendline and customizing chart in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Adding-a-Linear-Trendline-and-customizing-chart/m-p/581374#M47635</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232326"&gt;@aquinojason&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To easily summarize values over time, you can use the timechart command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=xxxxxxx sourcetype="xxxxxx" EXPRSSN=IBM4D*
| timechart span=1d avg(MIPS) ```or max(MIPS), p90(MIPS), etc.```&lt;/LI-CODE&gt;&lt;P&gt;Core Splunk does not include a linear trendline command, but you can create one yourself using SPL. See&amp;nbsp;&lt;A href="https://wiki.splunk.com/Community:Plotting_a_linear_trendline" target="_blank"&gt;https://wiki.splunk.com/Community:Plotting_a_linear_trendline&lt;/A&gt;&amp;nbsp;for an old example.&lt;/P&gt;&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/2890/" target="_self"&gt;Splunk Machine Learning Toolkit&lt;/A&gt;&amp;nbsp;&lt;EM&gt;does&lt;/EM&gt; include a linear regression algorithm for the fit command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=xxxxxxx sourcetype="xxxxxx" EXPRSSN=IBM4D*
| timechart span=1d avg(MIPS) as MIPS
| fit LinearRegression MIPS from _time&lt;/LI-CODE&gt;&lt;P&gt;You can visualize your data as an area chart and then configure predicted(MIPS) as an overlay to show a linear trend.&lt;/P&gt;&lt;P&gt;Here's an example using Splunk introspection events:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| tstats max(data.normalized_pct_cpu) as pct_cpu where index=_introspection host=splunk by _time span=10s 
| fit LinearRegression pct_cpu from _time&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aquinojason_linear_regression.png" style="width: 959px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17579iFEEE626A72C3019F/image-size/large?v=v2&amp;amp;px=999" role="button" title="aquinojason_linear_regression.png" alt="aquinojason_linear_regression.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;aquinojason_linear_regression.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what the red line in your chart represents. If you want to add a moving average to your chart, you can use the trendline command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| tstats max(data.normalized_pct_cpu) as pct_cpu where index=_introspection host=splunk by _time span=10s 
| trendline sma6(pct_cpu)
| fit LinearRegression pct_cpu from _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jan 2022 17:59:22 GMT</pubDate>
    <dc:creator>tscroggins</dc:creator>
    <dc:date>2022-01-17T17:59:22Z</dc:date>
    <item>
      <title>Adding a Linear Trendline and customizing chart</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Adding-a-Linear-Trendline-and-customizing-chart/m-p/580657#M47562</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have this on my splunk query&lt;/P&gt;&lt;P&gt;index=xxxxxxx sourcetype="xxxxxx" EXPRSSN=IBM4D* | eval DATE=strftime(strptime(DATE,"%d%b%Y"),"%Y-%m-%d") | table EXPRSSN DATE MIPS | eval _time=strptime(DATE." "."00:00:00","%Y-%m-%d %H:%M:%S") | chart values(MIPS) over _time by EXPRSSN&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to add a linear trendline on my chart. Hoping I could re-create this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aquinojason_0-1641921060830.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17513i8EA071EF03B47AE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aquinojason_0-1641921060830.png" alt="aquinojason_0-1641921060830.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;aquinojason_0-1641921060830.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I customize also the my line chart? I wanted to have the other one filled as well. I am getting the one in below from splunk&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aquinojason_1-1641921179727.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17514iA8FA4549ED10F514/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aquinojason_1-1641921179727.png" alt="aquinojason_1-1641921179727.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;aquinojason_1-1641921179727.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 17:14:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Adding-a-Linear-Trendline-and-customizing-chart/m-p/580657#M47562</guid>
      <dc:creator>aquinojason</dc:creator>
      <dc:date>2022-01-11T17:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a Linear Trendline and customizing chart</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Adding-a-Linear-Trendline-and-customizing-chart/m-p/581374#M47635</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232326"&gt;@aquinojason&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To easily summarize values over time, you can use the timechart command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=xxxxxxx sourcetype="xxxxxx" EXPRSSN=IBM4D*
| timechart span=1d avg(MIPS) ```or max(MIPS), p90(MIPS), etc.```&lt;/LI-CODE&gt;&lt;P&gt;Core Splunk does not include a linear trendline command, but you can create one yourself using SPL. See&amp;nbsp;&lt;A href="https://wiki.splunk.com/Community:Plotting_a_linear_trendline" target="_blank"&gt;https://wiki.splunk.com/Community:Plotting_a_linear_trendline&lt;/A&gt;&amp;nbsp;for an old example.&lt;/P&gt;&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/2890/" target="_self"&gt;Splunk Machine Learning Toolkit&lt;/A&gt;&amp;nbsp;&lt;EM&gt;does&lt;/EM&gt; include a linear regression algorithm for the fit command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=xxxxxxx sourcetype="xxxxxx" EXPRSSN=IBM4D*
| timechart span=1d avg(MIPS) as MIPS
| fit LinearRegression MIPS from _time&lt;/LI-CODE&gt;&lt;P&gt;You can visualize your data as an area chart and then configure predicted(MIPS) as an overlay to show a linear trend.&lt;/P&gt;&lt;P&gt;Here's an example using Splunk introspection events:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| tstats max(data.normalized_pct_cpu) as pct_cpu where index=_introspection host=splunk by _time span=10s 
| fit LinearRegression pct_cpu from _time&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aquinojason_linear_regression.png" style="width: 959px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17579iFEEE626A72C3019F/image-size/large?v=v2&amp;amp;px=999" role="button" title="aquinojason_linear_regression.png" alt="aquinojason_linear_regression.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;aquinojason_linear_regression.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what the red line in your chart represents. If you want to add a moving average to your chart, you can use the trendline command:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| tstats max(data.normalized_pct_cpu) as pct_cpu where index=_introspection host=splunk by _time span=10s 
| trendline sma6(pct_cpu)
| fit LinearRegression pct_cpu from _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 17:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Adding-a-Linear-Trendline-and-customizing-chart/m-p/581374#M47635</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2022-01-17T17:59:22Z</dc:date>
    </item>
  </channel>
</rss>

