<?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 Table of monthly (or weekly) averages using epoch time in field (not _time) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480319#M134627</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I'm trying to build a table showing the monthly averages of a calculation for "OEE" by a Machine field.&lt;BR /&gt;
I then want to drill down on the month selected to show worst offending machine and the downtime reasons (both fields in the data).&lt;/P&gt;

&lt;P&gt;The data is coming from DBX and therefore the date is contained in two fields "StartTime" and "StopTime" the events and not _time.&lt;/P&gt;

&lt;P&gt;This search provides the table I need for &lt;STRONG&gt;August&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dbx MachID=oven* | where StartTime&amp;gt;=1564617600 AND StopTime&amp;lt;1567296000 AND StopTime&amp;gt;0
          | lookup machines.csv MachID OUTPUTNEW Machine
| eval StartTime_Human=strftime(StartTime,"%a %B %d %Y %H:%M:%S"), StopTime_Human=strftime(StopTime,"%a %B %d %Y %H:%M:%S"), TotTimeHrs=TotTime/3600, DownTimeHrs=(DownTime/3600), SchedHrs=(SchedQty/ExpCycTm)/60+3
| eval OEE-A-ROTO=((TotTimeHrs)-(DownTimeHrs))/(TotTimeHrs)
| stats avg(SchedHrs) AS SchedHrsAvg, avg(OEE-A-ROTO) AS OEE-A-ROTO, sum(TotTimeHrs) AS TotTimeHrsSum BY JobID, Machine
| eval OEE-P-ROTO=SchedHrsAvg/TotTimeHrsSum
| eval OEE-ROTO=('OEE-A-ROTO'*'OEE-P-ROTO'*0.97)
| stats avg(OEE-ROTO) AS OEE by Machine
| eval OEE=round(OEE*100)."%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which provides this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Machine OEE
Oven2   86%
Oven3   88%
Oven4   84%
Oven5   80%
Oven6   88%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would actually like this to be is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Machine      JAN    FEB    MAR    APR    MAY    JUN    JUL    AUG
Oven2   86%    86%    86%    86%    86%    86%    86%    86%
Oven3   88%    84%    86%    86%    86%    86%    86%    86%
Oven4   84%    86%    86%    86%    86%    86%    86%    80%
Oven5   80%    86%    86%    86%    86%    86%    86%    80%
Oven6   88%    86%    86%    86%    86%    86%    86%    80%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for the help!&lt;BR /&gt;
Cheers&lt;BR /&gt;
John&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2019 16:07:57 GMT</pubDate>
    <dc:creator>johnansett</dc:creator>
    <dc:date>2019-09-12T16:07:57Z</dc:date>
    <item>
      <title>Table of monthly (or weekly) averages using epoch time in field (not _time)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480319#M134627</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;I'm trying to build a table showing the monthly averages of a calculation for "OEE" by a Machine field.&lt;BR /&gt;
I then want to drill down on the month selected to show worst offending machine and the downtime reasons (both fields in the data).&lt;/P&gt;

&lt;P&gt;The data is coming from DBX and therefore the date is contained in two fields "StartTime" and "StopTime" the events and not _time.&lt;/P&gt;

&lt;P&gt;This search provides the table I need for &lt;STRONG&gt;August&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dbx MachID=oven* | where StartTime&amp;gt;=1564617600 AND StopTime&amp;lt;1567296000 AND StopTime&amp;gt;0
          | lookup machines.csv MachID OUTPUTNEW Machine
| eval StartTime_Human=strftime(StartTime,"%a %B %d %Y %H:%M:%S"), StopTime_Human=strftime(StopTime,"%a %B %d %Y %H:%M:%S"), TotTimeHrs=TotTime/3600, DownTimeHrs=(DownTime/3600), SchedHrs=(SchedQty/ExpCycTm)/60+3
| eval OEE-A-ROTO=((TotTimeHrs)-(DownTimeHrs))/(TotTimeHrs)
| stats avg(SchedHrs) AS SchedHrsAvg, avg(OEE-A-ROTO) AS OEE-A-ROTO, sum(TotTimeHrs) AS TotTimeHrsSum BY JobID, Machine
| eval OEE-P-ROTO=SchedHrsAvg/TotTimeHrsSum
| eval OEE-ROTO=('OEE-A-ROTO'*'OEE-P-ROTO'*0.97)
| stats avg(OEE-ROTO) AS OEE by Machine
| eval OEE=round(OEE*100)."%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which provides this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Machine OEE
Oven2   86%
Oven3   88%
Oven4   84%
Oven5   80%
Oven6   88%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would actually like this to be is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Machine      JAN    FEB    MAR    APR    MAY    JUN    JUL    AUG
Oven2   86%    86%    86%    86%    86%    86%    86%    86%
Oven3   88%    84%    86%    86%    86%    86%    86%    86%
Oven4   84%    86%    86%    86%    86%    86%    86%    80%
Oven5   80%    86%    86%    86%    86%    86%    86%    80%
Oven6   88%    86%    86%    86%    86%    86%    86%    80%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for the help!&lt;BR /&gt;
Cheers&lt;BR /&gt;
John&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 16:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480319#M134627</guid>
      <dc:creator>johnansett</dc:creator>
      <dc:date>2019-09-12T16:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Table of monthly (or weekly) averages using epoch time in field (not _time)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480320#M134628</link>
      <description>&lt;P&gt;Hi  johnansett,&lt;BR /&gt;
your search is probably very slow because in the main search you haven't _time field, it could be useful to create the _time field in the extraction query in DBX (obviously in epochtime format).&lt;/P&gt;

&lt;P&gt;At first, you don't need the first where command: you can put the filters in the main search that is better!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dbx MachID=oven* StartTime&amp;gt;=1564617600 AND StopTime&amp;lt;1567296000 AND StopTime&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, the following fields are in the main search results? TotTime, DownTime, SchedQty, ExpCycTm ; otherwise I don't understand how you calculate them.&lt;/P&gt;

&lt;P&gt;Anyway, you can use bin and chart commands to have something near timechart, e.g.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| bin StartTime span=1d
| chart sum(TotTimeHrs) AS TotTimeHrs OVER StartTime BY Machine
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Adapting it to your search.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 17:14:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480320#M134628</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-09-12T17:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Table of monthly (or weekly) averages using epoch time in field (not _time)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480321#M134629</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;Thanks for the input.  I will try that.  I'm not sure it will work with the data but I will test and see.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 17:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480321#M134629</guid>
      <dc:creator>johnansett</dc:creator>
      <dc:date>2019-09-12T17:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Table of monthly (or weekly) averages using epoch time in field (not _time)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480322#M134630</link>
      <description>&lt;P&gt;good work!&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 17:51:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-of-monthly-or-weekly-averages-using-epoch-time-in-field/m-p/480322#M134630</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-09-12T17:51:38Z</dc:date>
    </item>
  </channel>
</rss>

