<?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: How to aggregate the results based on the results of the transforming command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421037#M120968</link>
    <description>&lt;P&gt;How about:&lt;BR /&gt;
index=main&lt;BR /&gt;
| ...&lt;BR /&gt;
| stats earliest(cpu) as total_cpu earliest(start_time) as start_time sum(cpu) as MB by job&lt;BR /&gt;
| eval pct = ...&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:15:40 GMT</pubDate>
    <dc:creator>whrg</dc:creator>
    <dc:date>2020-09-29T22:15:40Z</dc:date>
    <item>
      <title>How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421030#M120961</link>
      <description>&lt;P&gt;I'm trying to calculate the percentage of resources that are consumed by a job based on the start time of the job.&lt;BR /&gt;
Each job has more than one event and startTime could vary in the events. So I'm considering the earliest start time of the job.&lt;BR /&gt;
Using eventstats is not producing the events which im looking at.&lt;/P&gt;

&lt;P&gt;stats earliest(start_time) as start_time by job, If this is replaced in the place of eventstats im getting the results what I want.&lt;/P&gt;

&lt;P&gt;Can someone assist me on this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main 
| search trainId=acggalladks"
| eventstats earliest(start_time) as start_time by job
| stats first(cpu) as total_cpu sum(cpu) as MB by start_time, job
| eval pct = round((MB/total_cpu)*100, 2)
| table pct job
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421030#M120961</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421031#M120962</link>
      <description>&lt;P&gt;Just to clarify: Let us assume your events are (please add any missing fields):&lt;BR /&gt;
job,start_time,cpu&lt;BR /&gt;
Job A, 6am, 25&lt;BR /&gt;
Job A, 7am, 35&lt;BR /&gt;
Job A, 8am, 30&lt;BR /&gt;
Job B, 8am, 10&lt;BR /&gt;
Then what output do you want from the search?&lt;BR /&gt;
And how do you calculate total_cpu?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421031#M120962</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2020-09-29T22:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421032#M120963</link>
      <description>&lt;P&gt;The total_cpu is the common for all the events.&lt;/P&gt;

&lt;P&gt;I'm adding another row for job B which is job B 6am&lt;BR /&gt;
I want output to be as below.&lt;BR /&gt;
Job A, 6am, 25 pct_value&lt;BR /&gt;
job B, 6am, 10 pct_value&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:16:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421032#M120963</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421033#M120964</link>
      <description>&lt;P&gt;I tried this query and it's giving me the output what im looking at. But is it possible to get the output without join command?&lt;/P&gt;

&lt;P&gt;index=main &lt;BR /&gt;
| search trainId="somevalue" &lt;BR /&gt;
| join start_time&lt;BR /&gt;
    [ search index=main &lt;BR /&gt;
    | search trainId="somevalue" &lt;BR /&gt;
    | stats earliest(start_time) as start_time by job &lt;BR /&gt;
    | table start_time ] &lt;BR /&gt;
| stats first(cpu) as total_cpu sum(cpu) as MB by start_time, job&lt;BR /&gt;
| eval pct = round((MB/total_cpu)*100, 2)&lt;BR /&gt;
| table start_time pct job&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:17:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421033#M120964</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421034#M120965</link>
      <description>&lt;P&gt;remove join and see you get the same results (why you are using join),&lt;/P&gt;

&lt;P&gt;try this, I think you are expecting below the search&lt;BR /&gt;
index=main &lt;BR /&gt;
 | search trainId=acggalladks"&lt;BR /&gt;
  | stats earliest(cpu) as total_cpu sum(cpu) as MB by  job&lt;BR /&gt;
 | eval pct = round((MB/total_cpu)*100, 2)&lt;BR /&gt;
 | table pct job&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:15:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421034#M120965</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2020-09-29T22:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421035#M120966</link>
      <description>&lt;P&gt;index=main &lt;BR /&gt;
| search trainId="somevalue" &lt;BR /&gt;
| stats earliest(start_time) as start_time by job&lt;/P&gt;

&lt;P&gt;Whatever the output that returns by the field start_time from the above search need to be used in the by clause for the below query.&lt;/P&gt;

&lt;P&gt;index=main &lt;BR /&gt;
| search trainId="somevalue" &lt;BR /&gt;
 stats first(cpu) as total_cpu sum(cpu) as MB by start_time, job&lt;BR /&gt;
| eval pct = round((MB/total_cpu)*100, 2)&lt;BR /&gt;
| table start_time pct job&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421035#M120966</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421036#M120967</link>
      <description>&lt;P&gt;use map command&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 07:23:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421036#M120967</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2018-12-04T07:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421037#M120968</link>
      <description>&lt;P&gt;How about:&lt;BR /&gt;
index=main&lt;BR /&gt;
| ...&lt;BR /&gt;
| stats earliest(cpu) as total_cpu earliest(start_time) as start_time sum(cpu) as MB by job&lt;BR /&gt;
| eval pct = ...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421037#M120968</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2020-09-29T22:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate the results based on the results of the transforming command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421038#M120969</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/151987"&gt;@whrg&lt;/a&gt;, That way it won't work because i want the values of the start_time to be used in the by clause.&lt;BR /&gt;
I got it solved without join but looking for an optimal way.&lt;/P&gt;

&lt;P&gt;index=main &lt;BR /&gt;
| search trainId="somevalue" &lt;BR /&gt;
[ search index=main &lt;BR /&gt;
| search trainId="somevalue" &lt;BR /&gt;
| stats earliest(start_time) as start_time by job &lt;BR /&gt;
| table start_time ] &lt;BR /&gt;
| stats first(cpu) as total_cpu sum(cpu) as MB by start_time, job&lt;BR /&gt;
| eval pct = round((MB/total_cpu)*100, 2)&lt;BR /&gt;
| table start_time pct job&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:17:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-aggregate-the-results-based-on-the-results-of-the/m-p/421038#M120969</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:17:07Z</dc:date>
    </item>
  </channel>
</rss>

