<?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: Comparing field with weekly average in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542446#M153659</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230290"&gt;@sk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Is it possible that you missed setting time range for more than one week?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="n" earliest=-8d
| streamstats avg(Duration) as Weekly_Avg by Job time_window=7d global=f current=t
| dedup Job
| table Job Duration Weekly_Avg Status&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 05 Mar 2021 05:05:18 GMT</pubDate>
    <dc:creator>scelikok</dc:creator>
    <dc:date>2021-03-05T05:05:18Z</dc:date>
    <item>
      <title>Comparing field with weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542262#M153601</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to compare a field (Job duration) with its weekly average. Something is wrong with my join. It is returning only the first row's values from the main search.&lt;/P&gt;&lt;P&gt;Here is the query:&lt;/P&gt;&lt;P&gt;index="n"&lt;BR /&gt;| stats values(Job) by Date, Duration, Status&lt;BR /&gt;| join lower(Job) max=0&lt;BR /&gt;[ search&lt;BR /&gt;index="n" earliest=-8d&lt;BR /&gt;| stats count(eval(if( Date&amp;gt;relative_time(now(),"-d"),NULL,1))) as weekly_total, sum(eval(if(Date&amp;gt;relative_time(now(),"-d"), 0,Duration))) AS total_duration by Job&lt;BR /&gt;| eval Weekly_Avg=(total_duration/weekly_total)&lt;BR /&gt;]&lt;BR /&gt;| table Job, Duration, Weekly_Avg, Status&lt;BR /&gt;| dedup Job&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;Job&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Duration&amp;nbsp; &amp;nbsp; &amp;nbsp; Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Status&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021-03-03&amp;nbsp; &amp;nbsp; &amp;nbsp;Success&lt;BR /&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021-03-03&amp;nbsp; &amp;nbsp; &amp;nbsp;Failed&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021-03-02&amp;nbsp; &amp;nbsp; &amp;nbsp;Success&lt;BR /&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021-03-02&amp;nbsp; &amp;nbsp; &amp;nbsp;Success&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021-03-01&amp;nbsp; &amp;nbsp; &amp;nbsp;Success&lt;BR /&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2021-03-01&amp;nbsp; &amp;nbsp; &amp;nbsp;Success&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want:&lt;/P&gt;&lt;P&gt;Job&amp;nbsp; &amp;nbsp; Duration&amp;nbsp; &amp;nbsp; &amp;nbsp;Weekly Avg&amp;nbsp; &amp;nbsp; &amp;nbsp;Status&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Success&lt;BR /&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Failed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I get:&lt;/P&gt;&lt;P&gt;Job&amp;nbsp; &amp;nbsp; Duration&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Weekly Avg&amp;nbsp; &amp;nbsp; &amp;nbsp;Status&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Success&lt;BR /&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 (from JobA)&amp;nbsp; &amp;nbsp;7.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Success (from Job A)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;** Edit: I am finding&amp;nbsp; there are duplicate rows in my data (exactly same data) which is also not helping.&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 00:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542262#M153601</guid>
      <dc:creator>sk</dc:creator>
      <dc:date>2021-03-04T00:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing field with weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542303#M153616</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230290"&gt;@sk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Can you try below streamstats?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="n"
| streamstats avg(Duration) as Weekly_Avg by Job time_window=7d global=f current=t
| dedup Job
| table Job Duration Weekly_Avg Status&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 07:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542303#M153616</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-04T07:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing field with weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542412#M153652</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;Thanks for the info about streamstats.&lt;/P&gt;&lt;P&gt;This reports the duration and weekly_avg as the same value so it's as if the time_window is being ignored, for some reason. Any clue?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 20:52:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542412#M153652</guid>
      <dc:creator>sk</dc:creator>
      <dc:date>2021-03-04T20:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing field with weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542446#M153659</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/230290"&gt;@sk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Is it possible that you missed setting time range for more than one week?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="n" earliest=-8d
| streamstats avg(Duration) as Weekly_Avg by Job time_window=7d global=f current=t
| dedup Job
| table Job Duration Weekly_Avg Status&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Mar 2021 05:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542446#M153659</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-05T05:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing field with weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542611#M153707</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I was missing the "earliest=-8d" but no difference in the result. I had to use global=t since the error says false can only be used with windows not time_window's. I'll continue to play around. Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 17:37:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-with-weekly-average/m-p/542611#M153707</guid>
      <dc:creator>sk</dc:creator>
      <dc:date>2021-03-05T17:37:31Z</dc:date>
    </item>
  </channel>
</rss>

