<?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: Calculate average on two different times in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483529#M135367</link>
    <description>&lt;P&gt;Hi aohls,&lt;BR /&gt;
At first, I suggest to insert always index=my_index in your searches because they are faster!&lt;/P&gt;

&lt;P&gt;Then, there's a limit of 50,000 results in subsearches, are you sure that you don't exceed this limit in this case?&lt;/P&gt;

&lt;P&gt;Then, join command isn't a very performant command, in addition you have also a transaction in subsearch, this means that probably you have a very very slow search.&lt;BR /&gt;
Could you share the full search to try to rebuild it?&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2019 12:26:47 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-09-18T12:26:47Z</dc:date>
    <item>
      <title>Calculate average on two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483528#M135366</link>
      <description>&lt;P&gt;I want to get a 7 day and 30 day average in a single search. &lt;BR /&gt;
&lt;CODE&gt;sourcetype="businessService" OR sourcetype="bpmservice-2"  JobName &lt;BR /&gt;
| eval host = lower(host)&lt;BR /&gt;
| lookup client-mapping.csv hostname as host OUTPUT clientename as clientName&lt;BR /&gt;
| transaction unifyends=true  GUID maxspan=12h&lt;BR /&gt;
| eval duration=round(duration/60, 2)&lt;BR /&gt;
| lookup JobStatsData.csv codeName as codeName,JobName as JobName OUTPUT avgRunTimeMinutes as avgRunTimeMinutes, stdDevDuration as stdDevDuration, jobHasFTPDownload as FTPDownload&lt;BR /&gt;
| join JobName&lt;BR /&gt;
    [search sourcetype="businessService"  JobName earliest=-7d@d&lt;BR /&gt;
    | eval host = lower(host)&lt;BR /&gt;
    | lookup client-mapping.csv hostname as host OUTPUT clientname as clientName&lt;BR /&gt;
    | transaction unifyends=true  GUID maxspan=12h&lt;BR /&gt;
    | eval duration=round(duration/60, 2)&lt;BR /&gt;
    | stats avg(duration) as AverageRunTime7Days by JobName&lt;BR /&gt;
    | fields + AverageRunTime7Days]&lt;BR /&gt;
| stats avg(duration) as AverageRunTime30Days, avg(avgRunTimeMinutes) as historicalRunTime, avg(stdDevDuration) as historicalStdDev,values(FTPDownload) as FTPDownload by JobName&lt;BR /&gt;
| eval OneStdDevOfAvg = historicalRunTime + (historicalStdDev)&lt;BR /&gt;
| eval Action = if(AverageRunTime30Days &amp;gt; OneStdDevOfAvg, if(FTPDownload=="Yes","Potential Review Needed","Review Needed"), "No Issues")&lt;BR /&gt;
| rename JobName as BPMJob&lt;BR /&gt;
| table BPMJob,FTPDownload, AverageRunTime30Days, AverageRunTime7Days, OneStdDevOfAvg, Action&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have a lookup with historical statistics data and I want to compare that to a 30 day and 7 day run time. I am not getting any results right now; but if I remove the above code I get the 30 day average. I want to pass the 7 day average and JobName into my main search, so I can include it in my table output.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 11:57:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483528#M135366</guid>
      <dc:creator>aohls</dc:creator>
      <dc:date>2019-09-18T11:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average on two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483529#M135367</link>
      <description>&lt;P&gt;Hi aohls,&lt;BR /&gt;
At first, I suggest to insert always index=my_index in your searches because they are faster!&lt;/P&gt;

&lt;P&gt;Then, there's a limit of 50,000 results in subsearches, are you sure that you don't exceed this limit in this case?&lt;/P&gt;

&lt;P&gt;Then, join command isn't a very performant command, in addition you have also a transaction in subsearch, this means that probably you have a very very slow search.&lt;BR /&gt;
Could you share the full search to try to rebuild it?&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 12:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483529#M135367</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-09-18T12:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average on two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483530#M135368</link>
      <description>&lt;P&gt;@gcusello I added my full search. I also noticed I had a typo in why the search did not generate. I now have it working but, I am not getting data back for my 7 day average in the subsearch. I am also unsure of if there is a better way to do this.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 12:34:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483530#M135368</guid>
      <dc:creator>aohls</dc:creator>
      <dc:date>2019-09-18T12:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average on two different times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483531#M135369</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpeciryAnIndex" AND (sourcetype="businessService" OR sourcetype="bpmservice-2") AND JobName  earliest=-30d
| eval host = lower(host) 
| lookup client-mapping.csv hostname AS host OUTPUT clientename AS clientName
| stats list(*) AS * count range(_time) AS duration BY GUID
| eval duration=round(duration/60, 2) 
| lookup JobStatsData.csv codeName AS codeName, JobName AS JobName OUTPUT avgRunTimeMinutes AS avgRunTimeMinutes, stdDevDuration AS stdDevDuration, jobHasFTPDownload AS FTPDownload 
| eval which=if(_time&amp;gt;=relative_time(now(), "-7d@d"), mvappend("last7days", "last30days"), "last30days")
| stats avg(duration) as AverageRunTime30Days, avg(avgRunTimeMinutes) as historicalRunTime, avg(stdDevDuration) as historicalStdDev,values(FTPDownload) as FTPDownload by JobName which
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You will have to do some more stuff after this, but this solves the essence of your problem.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2019 00:57:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-on-two-different-times/m-p/483531#M135369</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-26T00:57:19Z</dc:date>
    </item>
  </channel>
</rss>

