<?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: transaction creates multi value field help to get just the most recent when out of order in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378530#M110964</link>
    <description>&lt;P&gt;dedup isn't 100% since my data from DB Connect can have more than one of the same task. BUT it's close. &lt;/P&gt;

&lt;P&gt;I LOVE the the first one that doesn't use transaction at all.  Thank you @somesoni2!&lt;/P&gt;</description>
    <pubDate>Tue, 01 May 2018 19:34:31 GMT</pubDate>
    <dc:creator>kmaron</dc:creator>
    <dc:date>2018-05-01T19:34:31Z</dc:date>
    <item>
      <title>transaction creates multi value field help to get just the most recent when out of order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378528#M110962</link>
      <description>&lt;P&gt;I'm trying to create a timeline of events and I'm running into an issue when certain steps are repeated and the data is out of order.&lt;/P&gt;

&lt;P&gt;My data originally comes from DB Connect so this is the format:&lt;BR /&gt;
Batch# Step# StartTime EndTime&lt;/P&gt;

&lt;P&gt;I'm trying to combine them into a transaction so I can get times between each step as well as duration of each step.  It works great when I only have a single Step1 but when I have more than one I'm running into issues.  &lt;/P&gt;

&lt;P&gt;Since the data is coming from DBConnect the records don't show up in the order of actual time they happened.&lt;/P&gt;

&lt;P&gt;This is essentially how things show up out of order:&lt;BR /&gt;
_time  Batch      Start_Time&lt;BR /&gt;
2018-04-30 20:01:21.100 Batch1  Step1   2018-04-30 19:00:18.0&lt;BR /&gt;
2018-04-30 21:01:20.939 Batch1  Step1   2018-04-30 20:00:58.0&lt;BR /&gt;
2018-04-30 21:01:20.939 Batch1  Step3   2018-04-30 20:53:05.0&lt;BR /&gt;
2018-04-30 21:01:20.939 Batch1  Step1   2018-04-30 20:52:18.0&lt;BR /&gt;
2018-04-30 21:01:20.939 Batch1  Step2   2018-04-30 20:52:20.0&lt;/P&gt;

&lt;P&gt;I can get things together but then I have a multivalue field with any number of values.&lt;BR /&gt;
Step1   2018-04-30 19:00:18.0    Step2  2018-04-30 20:52:20.0    Step3  2018-04-30 20:53:05.0&lt;BR /&gt;
Step1   2018-04-30 20:00:58.0&lt;BR /&gt;
Step1   2018-04-30 20:52:18.0&lt;/P&gt;

&lt;P&gt;This is what I want:&lt;BR /&gt;
Step1 2018-04-30 20:52:18.0 Step2 2018-04-30 20:52:20.0 Step3 2018-04-30 20:53:05.0&lt;/P&gt;

&lt;P&gt;I have my search set up which captures all of the data but I still end up with 3 start times for step 1.  When I try to add a startswith to my transaction it breaks things apart incorrectly and I can't use an endswith to fix it because the end changes.  &lt;/P&gt;

&lt;P&gt;This is the search I have currently:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo source=bar 
| eval Step1_Start = case(Task_Name="Step1",Start_Time)
| eval Step2_Start = case(Task_Name="Step2",Start_Time)
| eval Step3_Start = case(Task_Name="Step3",Start_Time)
| transaction Batch_Id 
| table Batch_Id Task_Name Step1_Start Step2_Start Step3_Start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure if I need to collect the data differently or work from the multi-value field. Any help/guidance would be appreciated. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378528#M110962</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2020-09-29T19:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: transaction creates multi value field help to get just the most recent when out of order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378529#M110963</link>
      <description>&lt;P&gt;Assuming a Batch_Id - Task_Name combination is uniq, give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo source=bar 
| eval Start_Time=strptime(Start_Time,"%Y-%m-%d %H:%M:%S.%N")
 | eval Step1_Start = case(Task_Name="Step1",Start_Time)
 | eval Step2_Start = case(Task_Name="Step2",Start_Time)
 | eval Step3_Start = case(Task_Name="Step3",Start_Time)
 | stats max(*_Start) as *_Start by Batch_Id Task_Name
| foreach *_Start [| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=strftime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%Y-%m-%d %H:%M:%S.%N")]
 | stats list(*) as * by Batch_Id 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo source=bar 
| dedup Batch_Id Task_Name
 | eval Step1_Start = case(Task_Name="Step1",Start_Time)
 | eval Step2_Start = case(Task_Name="Step2",Start_Time)
 | eval Step3_Start = case(Task_Name="Step3",Start_Time)
 | transaction Batch_Id 
 | table Batch_Id Task_Name Step1_Start Step2_Start Step3_Start
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:23:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378529#M110963</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T19:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: transaction creates multi value field help to get just the most recent when out of order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378530#M110964</link>
      <description>&lt;P&gt;dedup isn't 100% since my data from DB Connect can have more than one of the same task. BUT it's close. &lt;/P&gt;

&lt;P&gt;I LOVE the the first one that doesn't use transaction at all.  Thank you @somesoni2!&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 19:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transaction-creates-multi-value-field-help-to-get-just-the-most/m-p/378530#M110964</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-05-01T19:34:31Z</dc:date>
    </item>
  </channel>
</rss>

