<?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 do I create a table or other output of total process durations with multiple subprocess durations in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154970#M43588</link>
    <description>&lt;UL&gt;
&lt;LI&gt;You could try with max_match to capture multiple values once the transaction has been created.
Yes!  Thanks!&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;&lt;STRONG&gt;max_match&lt;/STRONG&gt; is the answer!&lt;/P&gt;

&lt;P&gt;Per the &lt;STRONG&gt;rex&lt;/STRONG&gt; documentation page, under &lt;STRONG&gt;Optional Arguments&lt;/STRONG&gt;:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;max_match&lt;/STRONG&gt;&lt;BR /&gt;
&lt;STRONG&gt;Syntax:&lt;/STRONG&gt; max_match=&amp;lt; int &amp;gt;&lt;BR /&gt;
&lt;STRONG&gt;Description:&lt;/STRONG&gt; Controls the number of times the regex is matched. If greater than 1, the resulting fields will be multivalued fields.&lt;BR /&gt;
Defaults to 1, use 0 to mean unlimited.&lt;/P&gt;

&lt;P&gt;As you suggested, define the fields with multiple events AFTER the transaction AND use the max_match argument on those fields:&lt;BR /&gt;
&lt;STRONG&gt;search |&lt;BR /&gt;
use rex to define a common field, CCID |&lt;BR /&gt;
transaction CCID |&lt;BR /&gt;
use rex to define:&lt;BR /&gt;&lt;BR /&gt;
subproccess field names and durations with max_match=0, &lt;BR /&gt;
total process duration and&lt;BR /&gt;&lt;BR /&gt;
a few other identifying fields, URI, RespCode |&lt;BR /&gt;
table URI,Processor,SegDuration,TotalDuration,RespCode&lt;/STRONG&gt; &lt;BR /&gt;
gives me exactly what I want, like in your 1st response.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 19:41:35 GMT</pubDate>
    <dc:creator>wjblazek</dc:creator>
    <dc:date>2020-09-28T19:41:35Z</dc:date>
    <item>
      <title>How do I create a table or other output of total process durations with multiple subprocess durations</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154966#M43584</link>
      <description>&lt;P&gt;I have log data like this:&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.1; Duration: 0 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.2; Duration: 5 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.3; Duration: 10 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.4; Duration: 20204 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.5; Duration: 100 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.6; Duration: 647 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.7; Duration: 899 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.8; Duration: 399 ms;&lt;BR /&gt;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.9; Duration: 411 ms;&lt;BR /&gt;
. . .&lt;BR /&gt;
2015-04-22 14:10:07,590 [ACTIVE] AfNDC [CCID] - Duration: 5239 ms Context: REST  &lt;/P&gt;

&lt;H1&gt;This last statement is the total process duration&lt;/H1&gt;

&lt;P&gt;I would like a table or other output that shows all the subprocess durations for each total process duration.&lt;BR /&gt;
I'm not picky about the format.&lt;BR /&gt;
Something like this:&lt;BR /&gt;
Subprocess Name        Duration(ms)        Total Process Duration(ms)&lt;BR /&gt;
subprocess.name.1                 0                             5239 &lt;BR /&gt;
subprocess.name.2                 5                             5239&lt;BR /&gt;&lt;BR /&gt;
subprocess.name.3               10                             5239 &lt;BR /&gt;
subprocess.name.4        20204                              5239 &lt;BR /&gt;
subprocess.name.5            100                              5239 &lt;BR /&gt;
subprocess.name.6            647                              5239 &lt;BR /&gt;
subprocess.name.7            899                              5239 &lt;BR /&gt;
subprocess.name.8            399                              5239 &lt;BR /&gt;
subprocess.name.9           411                               5239 &lt;BR /&gt;
The spacing above may not show up correctly.&lt;/P&gt;

&lt;P&gt;So far I have this much with no problem:&lt;BR /&gt;
search  |&lt;BR /&gt;
use rex to define a common field, CCID |&lt;BR /&gt;
use rex to define subproccess field names and durations |&lt;BR /&gt;
use rex to define total process duration |&lt;BR /&gt;
use rex to define a few other identifying fields |&lt;BR /&gt;
transaction CCID |&lt;BR /&gt;
table URI,Processor,SegDuration,TotalDuration,RespCode&lt;/P&gt;

&lt;P&gt;This give me nice transactions of&lt;BR /&gt;
all the subprocess events with  names and durations and the total duration event.&lt;BR /&gt;
But all the subprocess names are in alphabetical order, in one field, possibly a multivalue field, and &lt;BR /&gt;
the all the duration values in some other random order, not chronological, increasing or decreasing, &lt;BR /&gt;
also in one field, possibly a multivalue field, &lt;BR /&gt;
so that the names do not match with the duration values&lt;/P&gt;

&lt;P&gt;How do I get the subprocess names to correspond to the correct values?&lt;BR /&gt;
I'm also trying mvzip and mvexpand but without any luck.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2015 23:53:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154966#M43584</guid>
      <dc:creator>wjblazek</dc:creator>
      <dc:date>2015-04-22T23:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table or other output of total process durations with multiple subprocess durations</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154967#M43585</link>
      <description>&lt;P&gt;Going with the info you have provided define the transaction first and then do the Rex for the duration and the subtransaction names. &lt;/P&gt;

&lt;P&gt;search |&lt;BR /&gt;
use rex to define a common field, CCID |&lt;BR /&gt;
transaction CCID |&lt;BR /&gt;
use rex to define subproccess field names and durations |&lt;BR /&gt;
use rex to define total process duration |&lt;BR /&gt;
use rex to define a few other identifying fields &lt;/P&gt;

&lt;P&gt;If this an input to splunk, you should already have them broken into separate fields with input.conf so the  below solution might not apply exactly.&lt;/P&gt;

&lt;P&gt;However. tested out with the sample data you provided...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | stats count| eval text="2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.1; Duration: 0 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.2; Duration: 5 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.3; Duration: 10 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.4; Duration: 20204 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.5; Duration: 100 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.6; Duration: 647 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.7; Duration: 899 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.8; Duration: 399 ms;
2015-04-22 14:10:02,351 [ACTIVE] PerfLogger [CCID] - Message: subprocess.name.9; Duration: 411 ms;
2015-04-22 14:10:07,590 [ACTIVE] AfNDC [CCID] - Duration: 5239 ms Context: REST;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.1; Duration: 0 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.2; Duration: 6 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.3; Duration: 11 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.4; Duration: 20205 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.5; Duration: 101 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.6; Duration: 647 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.7; Duration: 899 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.8; Duration: 399 ms;
2015-04-22 14:10:03,351 [ACTIVE] PerfLogger [CCID11] - Message: subprocess.name.9; Duration: 411 ms;
2015-04-22 14:10:08,690 [ACTIVE] AfNDC [CCID11] - Duration: 5243 ms Context: REST;
"| makemv text delim=";
" | mvexpand text| rex field=text "^(?&amp;lt;time&amp;gt;\S+\s\S+)" | eval _time = strptime(time, "%Y-%m-%d %H:%M:%S,%3N") | rex field=text ".*\s\[(?&amp;lt;proc&amp;gt;\S+)\]\s\-.*" | transaction proc | rex field=text ".*Message:\s(?&amp;lt;sname&amp;gt;\S+)\;.*" | rex field=text ".*\;\sDuration\:\s(?&amp;lt;sdur&amp;gt;\d+)\s.*" | rex field=text "\]\s\-\sDuration\:\s(?&amp;lt;tdur&amp;gt;\d+)\s.*" | table proc,sname,sdur,duration,tdur
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives me &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Output"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/325i9DB25585F4F41BCD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Output" alt="Output" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2015 03:09:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154967#M43585</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-04-23T03:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table or other output of total process durations with multiple subprocess durations</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154968#M43586</link>
      <description>&lt;P&gt;Thanks much!&lt;BR /&gt;
More ??s.&lt;/P&gt;

&lt;P&gt;1st, that is an elegant way to input sample data to a search:&lt;BR /&gt;
just assign it to a variable and then operate on that variable:&lt;BR /&gt;
eval text="..." ...&lt;BR /&gt;
A great example in and of itself.&lt;/P&gt;

&lt;P&gt;I can cut/paste your example and get your exact results but &lt;BR /&gt;
when I try to apply it to my scenario, it doesn't.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;define the transaction first and then do the Rex for the duration and the subprocess names.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;That is actually what I initially tried:&lt;BR /&gt;
&lt;STRONG&gt;search |&lt;BR /&gt;
use rex to define a common field, CCID |&lt;BR /&gt;
transaction CCID |&lt;BR /&gt;
use rex to define subproccess field names and durations, &lt;BR /&gt;
total process duration and a few other identifying fields, URI, RespCode |&lt;BR /&gt;
table URI,Processor,SegDuration,TotalDuration,RespCode&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;But this is only listing the &lt;BR /&gt;
1st subprocess name and duration for each total duration,&lt;BR /&gt;
not all the subprocess names and durations for each total duration.&lt;/P&gt;

&lt;P&gt;I'm still working on understanding how and why your example works and &lt;BR /&gt;
why my real search doesn't.&lt;BR /&gt;&lt;BR /&gt;
What does this do in your example:&lt;BR /&gt;
rex field=text "^(?\S+\s\S+)" | eval _time = strptime(time, "%Y-%m-%d %H:%M:%S,%3N")&lt;BR /&gt;
It doesn't look like it does anything but it doesn't work without it.&lt;/P&gt;

&lt;P&gt;It looks like your 1st part:&lt;BR /&gt;
&lt;STRONG&gt;index=_internal | stats count| eval text="...&lt;BR /&gt;
"| makemv text delim=";&lt;BR /&gt;
 " | mvexpand text|&lt;/STRONG&gt;&lt;BR /&gt;
should be equivalent to &lt;BR /&gt;
&lt;STRONG&gt;search |&lt;BR /&gt;
use rex to define a common field, CCID |&lt;BR /&gt;
transaction CCID |&lt;/STRONG&gt;&lt;BR /&gt;
Then define the fields and table.&lt;BR /&gt;
But I only get the 1st subprocess name/duration, not all.&lt;BR /&gt;
Still trying!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 16:29:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154968#M43586</guid>
      <dc:creator>wjblazek</dc:creator>
      <dc:date>2015-04-24T16:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table or other output of total process durations with multiple subprocess durations</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154969#M43587</link>
      <description>&lt;P&gt;Unfortunately, this is the disadvantage of not having access to the same data/sources which you have..&lt;/P&gt;

&lt;P&gt;Reg your question, the reason I am doing the rex is to capture the _time field and converting it into a format which Splunk can understand i.e. timestamp value.&lt;BR /&gt;
I am guessing my example works because it is trying to generate the fields after the trasnaction is created whereas your data has them created already which is why you are getting only the first transaction name.&lt;BR /&gt;
You could try with max_match to capture multiple values once the transaction has been created.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=text ".*\s\[(?&amp;lt;proc&amp;gt;\S+)\]\s\-.*" | transaction proc | rex field=text ".*Message:\s(?&amp;lt;sname&amp;gt;\S+)\;.*"  max_match=10| rex field=text ".*\;\sDuration\:\s(?&amp;lt;sdur&amp;gt;\d+)\s.*" max_match=10 | rex field=text "\]\s\-\sDuration\:\s(?&amp;lt;tdur&amp;gt;\d+)\s.*" max_match=10 | table proc,sname,sdur,duration,tdur
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154969#M43587</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2020-09-28T19:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a table or other output of total process durations with multiple subprocess durations</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154970#M43588</link>
      <description>&lt;UL&gt;
&lt;LI&gt;You could try with max_match to capture multiple values once the transaction has been created.
Yes!  Thanks!&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;&lt;STRONG&gt;max_match&lt;/STRONG&gt; is the answer!&lt;/P&gt;

&lt;P&gt;Per the &lt;STRONG&gt;rex&lt;/STRONG&gt; documentation page, under &lt;STRONG&gt;Optional Arguments&lt;/STRONG&gt;:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;max_match&lt;/STRONG&gt;&lt;BR /&gt;
&lt;STRONG&gt;Syntax:&lt;/STRONG&gt; max_match=&amp;lt; int &amp;gt;&lt;BR /&gt;
&lt;STRONG&gt;Description:&lt;/STRONG&gt; Controls the number of times the regex is matched. If greater than 1, the resulting fields will be multivalued fields.&lt;BR /&gt;
Defaults to 1, use 0 to mean unlimited.&lt;/P&gt;

&lt;P&gt;As you suggested, define the fields with multiple events AFTER the transaction AND use the max_match argument on those fields:&lt;BR /&gt;
&lt;STRONG&gt;search |&lt;BR /&gt;
use rex to define a common field, CCID |&lt;BR /&gt;
transaction CCID |&lt;BR /&gt;
use rex to define:&lt;BR /&gt;&lt;BR /&gt;
subproccess field names and durations with max_match=0, &lt;BR /&gt;
total process duration and&lt;BR /&gt;&lt;BR /&gt;
a few other identifying fields, URI, RespCode |&lt;BR /&gt;
table URI,Processor,SegDuration,TotalDuration,RespCode&lt;/STRONG&gt; &lt;BR /&gt;
gives me exactly what I want, like in your 1st response.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:41:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-table-or-other-output-of-total-process/m-p/154970#M43588</guid>
      <dc:creator>wjblazek</dc:creator>
      <dc:date>2020-09-28T19:41:35Z</dc:date>
    </item>
  </channel>
</rss>

