<?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 Why is timechart with where and streamstat not retrieving same results as where and stats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613392#M213178</link>
    <description>&lt;P&gt;I am running a query where the following fetches the latency above 1000 milliseconds:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-09-16 at 1.25.29 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21503iC881C5985AC0345D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-09-16 at 1.25.29 PM.png" alt="Screen Shot 2022-09-16 at 1.25.29 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see the query uses stats and a where clause to yield approximately 60 results&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to timechart this data-replacing stats with streamstats:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-09-16 at 1.24.46 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21504i63036BCEC16DB220/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-09-16 at 1.24.46 PM.png" alt="Screen Shot 2022-09-16 at 1.24.46 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am now getting 26K+ events. Why is my timechart not reflecting the 60 results I was fetching when using the stats command?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 17:50:32 GMT</pubDate>
    <dc:creator>kimsej</dc:creator>
    <dc:date>2022-09-16T17:50:32Z</dc:date>
    <item>
      <title>Why is timechart with where and streamstat not retrieving same results as where and stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613392#M213178</link>
      <description>&lt;P&gt;I am running a query where the following fetches the latency above 1000 milliseconds:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-09-16 at 1.25.29 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21503iC881C5985AC0345D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-09-16 at 1.25.29 PM.png" alt="Screen Shot 2022-09-16 at 1.25.29 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see the query uses stats and a where clause to yield approximately 60 results&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to timechart this data-replacing stats with streamstats:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-09-16 at 1.24.46 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21504i63036BCEC16DB220/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-09-16 at 1.24.46 PM.png" alt="Screen Shot 2022-09-16 at 1.24.46 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am now getting 26K+ events. Why is my timechart not reflecting the 60 results I was fetching when using the stats command?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 17:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613392#M213178</guid>
      <dc:creator>kimsej</dc:creator>
      <dc:date>2022-09-16T17:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with where and streamstat not retrieving same results as where and stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613408#M213183</link>
      <description>&lt;P&gt;The reason for that is in how streamstats works. Consider this example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| makeresults
| eval data = "a,1;a,1;a,1;b,2;a,1;b,2;a,1;b,2"
| makemv data delim=";"
| mvexpand data
| makemv data delim=","
| eval req_id = mvindex(data,0)
| eval diff = mvindex(data,1)
| streamstats sum(diff) by req_id
| fields - _time data&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This produces the following table:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;diff&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;req_id&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;sum(diff)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;a&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;a&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;a&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;b&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;a&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;b&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;a&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;b&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If now the condition&lt;/P&gt;&lt;P&gt;where sum(diff) &amp;gt; 3&amp;nbsp;&lt;/P&gt;&lt;P&gt;is applied, multiple rows for each req_id will match.&lt;/P&gt;&lt;P&gt;If you want to do a timechart from your initial SPL query, you can try the following (replacing the last line of your query)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;| bin _time span=5m&lt;BR /&gt;| stats sum(diff) as FinalDiff by X_Request_ID, _time&lt;BR /&gt;| eval seriesName="Baxter&amp;lt;-&amp;gt;Saturn"&lt;BR /&gt;| timechart count by seriesName&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 14:26:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613408#M213183</guid>
      <dc:creator>JacekF</dc:creator>
      <dc:date>2022-09-16T14:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with where and streamstat not retrieving same results as where and stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613428#M213194</link>
      <description>&lt;P&gt;So using your example I get:&lt;/P&gt;&lt;P&gt;index=cards_prod component="card-notification-service" eventCategory=transactions eventType=auth AND ("is going to process" OR ("to POST &lt;A href="https://apay-partner-api.apple.com/ccs/v1/users/eventNotification/transactions/auth" target="_blank" rel="noopener"&gt;https://apay.com&lt;/A&gt;" AND status=204))&lt;BR /&gt;| eval diff=if(searchmatch("is going to process") and isnull(diff), _time*-1, diff)&lt;BR /&gt;| eval diff=if(searchmatch("is going to process") and diff &amp;gt; 0, _time*-1 + diff, diff)&lt;BR /&gt;| eval diff=if(searchmatch("to POST &lt;A href="https://apay-partner-api.apple.com/ccs/v1/users/eventNotification/transactions/auth" target="_blank" rel="noopener"&gt;https://apay.com&lt;/A&gt;") and isnull(diff), _time, diff)&lt;BR /&gt;| eval diff=if(searchmatch("to POST &lt;A href="https://apay-partner-api.apple.com/ccs/v1/users/eventNotification/transactions/auth" target="_blank" rel="noopener"&gt;https://apay.com&lt;/A&gt;") and diff &amp;lt; 0 , diff+_time, diff)&lt;BR /&gt;&lt;STRONG&gt;| bin span=5m&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| stats sum(diff) as FinalDiff by X_Request_ID, _time&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| eval seriesName="Baxter&amp;lt;-&amp;gt;Saturn"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| timechart count by seriesName&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;This gives me the error:&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Error in 'bin' command: You must specify a field to discretize.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Furthermore is there no way to include the comparison operator?-&lt;SPAN&gt;where sum(diff) &amp;gt; 3&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Sep 2022 14:20:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613428#M213194</guid>
      <dc:creator>kimsej</dc:creator>
      <dc:date>2022-09-16T14:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with where and streamstat not retrieving same results as where and stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613429#M213195</link>
      <description>&lt;P&gt;My bad, sorry, below is the correct version&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;| bin _time span=5m&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| stats sum(diff) as FinalDiff by X_Request_ID, _time&lt;BR /&gt;| where FinalDiff &amp;gt; 1000&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| eval seriesName="Baxter&amp;lt;-&amp;gt;Saturn"&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| timechart count by seriesName&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Sep 2022 14:25:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613429#M213195</guid>
      <dc:creator>JacekF</dc:creator>
      <dc:date>2022-09-16T14:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with where and streamstat not retrieving same results as where and stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613445#M213202</link>
      <description>&lt;P&gt;Worked like a charm thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 16:20:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-timechart-with-where-and-streamstat-not-retrieving-same/m-p/613445#M213202</guid>
      <dc:creator>kimsej</dc:creator>
      <dc:date>2022-09-16T16:20:09Z</dc:date>
    </item>
  </channel>
</rss>

