<?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 write a search to join these two lines of data and output results in a table with three columns? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148317#M41489</link>
    <description>&lt;P&gt;You will want to place the eval statement before the &lt;STRONG&gt;transaction&lt;/STRONG&gt; command.&lt;BR /&gt;
    | eval JobProcessStarted=if(Event=="JobProcessStarted",DateTime,null()) | eval VariantProcessCompleted=if(Event=="VariantProcessCompleted",DateTime,null()) | transaction JobId | table ProductionId JobProcessStarted VariantProcessCompleted | sort by DateTime desc&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jul 2015 19:45:21 GMT</pubDate>
    <dc:creator>bmacias84</dc:creator>
    <dc:date>2015-07-30T19:45:21Z</dc:date>
    <item>
      <title>How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148312#M41484</link>
      <description>&lt;P&gt;Hi Splunk heads,&lt;/P&gt;

&lt;P&gt;Can you please help me with a really tricky search? I am trying to join the following two lines that have one common field &lt;CODE&gt;JobId&lt;/CODE&gt; so I can table the results in 3 columns like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ProductionId      JobProcessStarted     VariantProcessCompleted
2/3709/0115#001   2015-07-30T13:10:33   2015-07-30T13:21:54
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Line1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DateTime=2015-07-30T13:10:33  Event=JobProcessStarted  JobId=3AFBD168-D5C9-4E06-B6A8-62FFFE4BCD26 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Line2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DateTime=2015-07-30T13:21:54  Event=VariantProcessCompleted  JobId=3AFBD168-D5C9-4E06-B6A8-62FFFE4BCD26  ProductionId=2/3709/0115#001 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
F&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 14:53:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148312#M41484</guid>
      <dc:creator>Fergal111</dc:creator>
      <dc:date>2015-07-30T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148313#M41485</link>
      <description>&lt;P&gt;try &lt;CODE&gt;... | transaction JobId | spath | table ProductionId JobProcessStarted VariantProcessCompleted&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 15:59:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148313#M41485</guid>
      <dc:creator>jnussbaum_splun</dc:creator>
      <dc:date>2015-07-30T15:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148314#M41486</link>
      <description>&lt;P&gt;I think you want to create new fields called JobProcessStarted and VariantProcessCompleted which contain DateTime.  Then you can use transaction and table to make a single row.  Not sure if spath is needed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval JobProcessedStarted=if(Event=="JobProcessStarted", DateTime, null()) | eval VariantProcessCompleted=if(Event=="VariantProcessCompleted", DateTime, null() | spath | table ProductionId JobProcessStarted VariantProcessCompleted
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 16:16:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148314#M41486</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2015-07-30T16:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148315#M41487</link>
      <description>&lt;P&gt;Thanks Bernardo!&lt;/P&gt;

&lt;P&gt;I am great progress here. &lt;/P&gt;

&lt;P&gt;| transaction JobId | eval JobProcessStarted=if(Event=="JobProcessStarted",DateTime,null()) | eval VariantProcessCompleted=if(Event=="VariantProcessCompleted",DateTime,null()) | table ProductionId JobProcessStarted VariantProcessCompleted | sort by DateTime desc&lt;/P&gt;

&lt;P&gt;The result currently looks like below. There just lies just two little problems as you can see. &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;The DateTime from JobProcessStarted  and  VariantProcessCompleted are logged under both columns instead of their respective headers. Im not quiet sure how to solve this.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;There are more than 2 DateTime values per JobId as you can see below (the 5 line below are actually 1 line/event, 1 value under ProductionId, 5 DateTime values under each of the last two columns) They have lines that do not contain EventId=JobProcessStarted  or Event=VariantProcessCompleted in the field. They have Event=Error which i do not want to report on. Can I eliminate these timestamps by not searching the lines that contain something like Event=Error or a line that contains something like ID=NONE ?&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;ProductionId      JobProcessStarted     VariantProcessCompleted&lt;BR /&gt;
 2/3709/0115#001   2015-07-30T13:10:32   2015-07-30T13:10:32&lt;BR /&gt;
                                    2015-07-30T13:10:33   2015-07-30T13:10:33&lt;BR /&gt;
                                    2015-07-30T13:10:43   2015-07-30T13:10:43&lt;BR /&gt;
                                    2015-07-30T13:21:26   2015-07-30T13:21:26&lt;BR /&gt;
                                    2015-07-30T13:21:54   2015-07-30T13:21:54&lt;/P&gt;

&lt;P&gt;Thanks very much for your help so far:)&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
F&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 18:49:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148315#M41487</guid>
      <dc:creator>Fergal111</dc:creator>
      <dc:date>2015-07-30T18:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148316#M41488</link>
      <description>&lt;P&gt;Try one of the options&lt;/P&gt;

&lt;P&gt;Using  transaction command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search giving only events with JobProcessStarted OR VariantProcessCompleted| transaction JobId startswith="Event=JobProcessStarted" endswith="Event=VariantProcessCompleted" | eval JobProcessStarted=mvindex(DateTime,0) | eval VariantProcessCompleted=mvindex(DateTime,1) | table ProductionId JobProcessStarted VariantProcessCompleted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using stats&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search giving only events with JobProcessStarted OR VariantProcessCompleted | fields DateTime JobId Event ProductionId | stats values(*) as * by JobId | where mvcount(Event)&amp;gt;1 | eval JobProcessStarted=mvindex(DateTime,0) | eval VariantProcessCompleted=mvindex(DateTime,1) | table ProductionId JobProcessStarted VariantProcessCompleted
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148316#M41488</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-30T19:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148317#M41489</link>
      <description>&lt;P&gt;You will want to place the eval statement before the &lt;STRONG&gt;transaction&lt;/STRONG&gt; command.&lt;BR /&gt;
    | eval JobProcessStarted=if(Event=="JobProcessStarted",DateTime,null()) | eval VariantProcessCompleted=if(Event=="VariantProcessCompleted",DateTime,null()) | transaction JobId | table ProductionId JobProcessStarted VariantProcessCompleted | sort by DateTime desc&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148317#M41489</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2015-07-30T19:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148318#M41490</link>
      <description>&lt;P&gt;Mind voting the question up if it helped you.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:51:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148318#M41490</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2015-07-30T19:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148319#M41491</link>
      <description>&lt;P&gt;Thanks very much Somesuni2. Top answer!&lt;/P&gt;

&lt;P&gt;Using your stats search, do you think to output the time difference between VariantProcessCompleted and JobProcessStarted and output to a forth column?&lt;/P&gt;

&lt;P&gt;Thanks a million for your help!&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Fergal&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 20:58:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148319#M41491</guid>
      <dc:creator>Fergal111</dc:creator>
      <dc:date>2015-07-30T20:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148320#M41492</link>
      <description>&lt;P&gt;Just add following to end of stats search to get that.&lt;/P&gt;

&lt;P&gt;| eval Duration=strptime(VariantProcessCompleted,"%Y-%m-%dT%H:%M:%S") -strptime(JobProcessStarted,"%Y-%m-%dT%H:%M:%S") &lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 21:31:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148320#M41492</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-30T21:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to join these two lines of data and output results in a table with three columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148321#M41493</link>
      <description>&lt;P&gt;Nice one!&lt;/P&gt;

&lt;P&gt;Just added a little extra to output Duration in  h:m:s instead of seconds&lt;/P&gt;

&lt;P&gt;eval Duration=strptime(VariantProcessCompleted,"%Y-%m-%dT%H:%M:%S") -strptime(JobProcessStarted,"%Y-%m-%dT%H:%M:%S") | eval Duration=strftime(Duration,"%H:%M:%S")&lt;/P&gt;

&lt;P&gt;Thanks very much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 22:11:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-a-search-to-join-these-two-lines-of-data-and/m-p/148321#M41493</guid>
      <dc:creator>Fergal111</dc:creator>
      <dc:date>2015-07-30T22:11:28Z</dc:date>
    </item>
  </channel>
</rss>

