<?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: Optimization of a 6minute+ search while using inline sparkline with  tstats in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436795#M28821</link>
    <description>&lt;P&gt;In order to see differences in search speeds and their reasons, do run both variants and post the performance graph from the top section of the job inspector.&lt;/P&gt;

&lt;P&gt;Pay attention to field naming in the tstats searches, I see cables.id and cable.Id - it's likely that only one of those two is correct.&lt;/P&gt;

&lt;P&gt;As for sparklines in tstats, these two searches do the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | stats sparkline(count)

| tstats count where index=_internal by _time span=1m | stats sparkline(sum(count))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The tstats loads the underlying data, a count by minute. The stats formats the data as a sparkline.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2019 12:24:00 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2019-08-15T12:24:00Z</dc:date>
    <item>
      <title>Optimization of a 6minute+ search while using inline sparkline with  tstats</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436794#M28820</link>
      <description>&lt;P&gt;I have a search that I have almost optimized, the current search is 6+ minutes, and I have it down to about 16 seconds. &lt;BR /&gt;
Inspecting the job is showing that most of the job is due to the join, which is needed for the spark line. &lt;/P&gt;

&lt;P&gt;The idea is that we can monitor bandwidth for 2 days,  and then flag if any outliers are found. If an outlier is found, I need to show a sparkline within a field for the last 4 hours. &lt;/P&gt;

&lt;P&gt;This search takes about 16 seconds, I wish I could make it faster, but I cannot figure out how to make the sparkline work inside the tstats. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="cables" source="bandwidth" earliest=-4h latest=now() | stats sparkline(avg(bandwidthMbps)) as "4HR" by cableId
| join cableId [| tstats count from datamodel=prod.cables by cables.bandwidth, cables.name,  cable.Id, _time span=1m 
| rename cable.id as cableId, cable.bandwidth as bandwidth, cable.name as name

| lookup allcables.csv cableId output zipcode,active | where active="true" | search zipcode!=*90210* 
| eventstats avg(bandwidth) as avg, stdev(bandwidth) as stdev by cableId | eval lowerBound=(avg-stdev*exact(2)), upperBound=(avg+stdev*exact(2)) | eval isOutlier=if(bandwidth &amp;lt; lowerBound OR bandwidth &amp;gt; upperBound, 1, 0) | sort - _time | dedup cableId | where isOutlier=1 | where _time &amp;gt; (now() - 360) ] 
| lookup network.csv ipName  | eval IP_lookup=coalesce(ip_name, alt_ip_name) | lookup Regions.csv range as IP_lookup output address | table cableId, avg, "4HR"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the original search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="cables" source="bandwidth" earliest=-4h latest=now() | stats sparkline(avg(bandwidthMbps)) as "4HR" by cableId
| join cableId [| tstats latest(cables.bandwidth) as bandwidth, cables.name as name from datamodel=prod.cables by cables.id,  _time span=1m 
    | rename cable.id as cableId
    | lookup allcables.csv cableId output zipcode,active | where active="true" | search zipcode!=*90210* 
    | eventstats avg(bandwidth) as avg, stdev(bandwidth) as stdev by cableId | eval lowerBound=(avg-stdev*exact(2)), upperBound=(avg+stdev*exact(2)) | eval isOutlier=if(bandwidth &amp;lt; lowerBound OR bandwidth &amp;gt; upperBound, 1, 0) | sort - _time | dedup cableId | where isOutlier=1 | where _time &amp;gt; (now() - 360) ] 
    | lookup network.csv ipName  | eval IP_lookup=coalesce(ip_name, alt_ip_name) | lookup Regions.csv range as IP_lookup output address | table cableId, avg, "4HR"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Differences: &lt;BR /&gt;
1. the faster search uses count, instead of latest. &lt;BR /&gt;
2. I tried using avg(bandwidth) within the tstats, but I was getting different results from the original search. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;My two questions:&lt;/STRONG&gt; &lt;BR /&gt;
1. why is tstats count so much faster when I list everything I want within the by clause. &lt;BR /&gt;
2. how can I get correct sparkline within the tstats without needing to do a double search. The tstats search is a range of 48hours, but the sparkline is the 4 hours. &lt;/P&gt;

&lt;P&gt;I have a lot of searches like this, that take 6 minutes, and would love to optimize it all. &lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 02:37:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436794#M28820</guid>
      <dc:creator>wrussell12</dc:creator>
      <dc:date>2019-08-09T02:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Optimization of a 6minute+ search while using inline sparkline with  tstats</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436795#M28821</link>
      <description>&lt;P&gt;In order to see differences in search speeds and their reasons, do run both variants and post the performance graph from the top section of the job inspector.&lt;/P&gt;

&lt;P&gt;Pay attention to field naming in the tstats searches, I see cables.id and cable.Id - it's likely that only one of those two is correct.&lt;/P&gt;

&lt;P&gt;As for sparklines in tstats, these two searches do the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | stats sparkline(count)

| tstats count where index=_internal by _time span=1m | stats sparkline(sum(count))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The tstats loads the underlying data, a count by minute. The stats formats the data as a sparkline.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 12:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436795#M28821</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2019-08-15T12:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Optimization of a 6minute+ search while using inline sparkline with  tstats</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436796#M28822</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;You can replace join by append, but you should use stats by . &lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Optimization-of-a-6minute-search-while-using-inline-sparkline/m-p/436796#M28822</guid>
      <dc:creator>Kawtar</dc:creator>
      <dc:date>2019-08-15T19:34:42Z</dc:date>
    </item>
  </channel>
</rss>

