<?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: subsearch to combine multiple queries and sum up in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456029#M128941</link>
    <description>&lt;P&gt;add this after  the table command, that is after all the code above&lt;BR /&gt;
    | addtotals&lt;BR /&gt;
    |eval Total=Total-job_id&lt;BR /&gt;
    | eval Totalinmins=round((Total/60),2)&lt;/P&gt;

&lt;P&gt;I have subtracted the job_id as it is a numerical field in the dummy data,please double check&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2019 10:27:24 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2019-08-19T10:27:24Z</dc:date>
    <item>
      <title>subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456021#M128933</link>
      <description>&lt;P&gt;example log data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;project_name=abc category=xyz job_id=1 stage_begin=compile time=2019-08-16 15:00:00
project_name=abc category=xyz job_id=1 stage_end=compile   time=2019-08-16 15:03:00
project_name=abc category=xyz job_id=1 stage_begin=build     time=2019-08-16 15:03:00
project_name=abc category=xyz job_id=1 stage_end=build         time=2019-08-16 15:06:00
project_name=abc category=xyz job_id=1 stage_begin=artifacts time=2019-08-16 15:07:00
project_name=abc category=xyz job_id=1 stage_end=artifacts    time=2019-08-16 15:12:00
project_name=abc category=xyz job_id=1 stage_begin=upload    time=2019-08-16 15:13:00
project_name=abc category=xyz job_id=1 stage_end=upload       time=2019-08-16 15:14:00
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Need a output table like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;project_name Category job_id compile_time build_time . artifacts_time  upload_time
abc                         xyz         1                3mins .     3 mins .          5 mins .           1min
...
...
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i tried to have a query to do &lt;CODE&gt;stage begin&lt;/CODE&gt; and then &lt;CODE&gt;join&lt;/CODE&gt; with &lt;CODE&gt;job_id&lt;/CODE&gt; and get a query for &lt;CODE&gt;stage_end&lt;/CODE&gt; which I can do only for 1 stage so I am not sure how to get all &lt;CODE&gt;stages&lt;/CODE&gt; for a given &lt;CODE&gt;job_id&lt;/CODE&gt;.  I tried &lt;CODE&gt;appendcols&lt;/CODE&gt; but it messes up when some &lt;CODE&gt;job_id&lt;/CODE&gt;s don't have one of the fields or it fails after &lt;CODE&gt;build&lt;/CODE&gt;, etc.&lt;/P&gt;

&lt;P&gt;Need help to get a report similar to the sample &lt;BR /&gt;
Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 04:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456021#M128933</guid>
      <dc:creator>vanakkam</dc:creator>
      <dc:date>2019-08-18T04:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456022#M128934</link>
      <description>&lt;P&gt;why are you trying to use a join command? are these events from different sources / indexes&lt;BR /&gt;
Also, can a different job id have more stages than compile,build,upload and artifact?&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 15:17:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456022#M128934</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-18T15:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456023#M128935</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;Did you try this: &lt;BR /&gt;
                  index=* .... | appendpipe [ search index=* ...]&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 18:27:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456023#M128935</guid>
      <dc:creator>Kawtar</dc:creator>
      <dc:date>2019-08-18T18:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456024#M128936</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval raw="project_name=abc,category=xyz,job_id=1,stage_begin=compile,time=2019-08-16T15:00:00:::project_name=abc,category=xyz,job_id=1,stage_end=compile,time=2019-08-16T15:03:00:::project_name=abc,category=xyz,job_id=1,stage_begin=build,time=2019-08-16T15:03:00:::project_name=abc,category=xyz,job_id=1,stage_end=build,time=2019-08-16T15:06:00:::project_name=abc,category=xyz,job_id=1,stage_begin=artifacts,time=2019-08-16T15:07:00:::project_name=abc,category=xyz,job_id=1,stage_end=artifacts,time=2019-08-16T15:12:00:::project_name=abc,category=xyz,job_id=1,stage_begin=upload,time=2019-08-16T15:13:00:::project_name=abc,category=xyz,job_id=1,stage_end=upload,time=2019-08-16T15:14:00"
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw
| kv
| eval _time = strptime(time, "%Y-%m-%dT%H:%M:%S")

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| eval stage = coalesce(stage_begin, stage_end)
| fields - stage_begin stage_end
| stats range(_time) AS duration BY project_name category job_id stage
| eval {stage}_time = duration
| fields - stage duration
| stats values(*) AS * BY project_name category job_id
| table project_name category job_id compile_time build_time . artifacts_time upload_time *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Aug 2019 20:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456024#M128936</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-18T20:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456025#M128937</link>
      <description>&lt;P&gt;Thanks a lot Woodcock! that worked perfectly !&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 22:36:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456025#M128937</guid>
      <dc:creator>vanakkam</dc:creator>
      <dc:date>2019-08-18T22:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456026#M128938</link>
      <description>&lt;P&gt;One follow up question. can you explain this query for a new splunker like me. I can then build on top of it for future queries like this. &lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 22:40:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456026#M128938</guid>
      <dc:creator>vanakkam</dc:creator>
      <dc:date>2019-08-18T22:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456027#M128939</link>
      <description>&lt;P&gt;The trick is to remove pipes from the end on back until you completely understand it and then add commands/pipes back one-by-one and see what each one does.  The only tricky thing is the curly-brace line which takes the cale of the braces field and make it the name of a new field.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 02:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456027#M128939</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-19T02:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456028#M128940</link>
      <description>&lt;P&gt;Thanks Woodcock for the explanation. I need one last column the total time for each job. i am not sure i i tried to remove table command line and replace that line with &lt;BR /&gt;
| stats sum(compile_time+build_time+artifacts_time+upload_time) as TotalTime BY project_name category job_id&lt;BR /&gt;
i got a table with project_name category  job_id  all with value and Empty column TotalTime for each row.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:49:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456028#M128940</guid>
      <dc:creator>vanakkam</dc:creator>
      <dc:date>2020-09-30T01:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456029#M128941</link>
      <description>&lt;P&gt;add this after  the table command, that is after all the code above&lt;BR /&gt;
    | addtotals&lt;BR /&gt;
    |eval Total=Total-job_id&lt;BR /&gt;
    | eval Totalinmins=round((Total/60),2)&lt;/P&gt;

&lt;P&gt;I have subtracted the job_id as it is a numerical field in the dummy data,please double check&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 10:27:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456029#M128941</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-19T10:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456030#M128942</link>
      <description>&lt;P&gt;That worked Thanks Sukisen&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:26:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456030#M128942</guid>
      <dc:creator>vanakkam</dc:creator>
      <dc:date>2019-08-19T17:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch to combine multiple queries and sum up</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456031#M128943</link>
      <description>&lt;P&gt;glad it worked @vanakkam &lt;BR /&gt;
Please upvote my comment if it helped you significantly&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-to-combine-multiple-queries-and-sum-up/m-p/456031#M128943</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-19T17:36:00Z</dc:date>
    </item>
  </channel>
</rss>

