<?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: Creating End_Loading_Time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398248#M174463</link>
    <description>&lt;P&gt;Thank you very much @FrankVl much appreciated mate. I had to update the next regex command to match the criteria for them and it is working as I was expecting.&lt;/P&gt;

&lt;P&gt;While I will accept your solution as correct I was wondering to know if you can post me some good sites where I can learn more about Regex specifically the one that teaches the " | rex field=event mode=sed"&lt;BR /&gt;
I have known the regex101 and &lt;A href="http://www.udemy.com"&gt;www.udemy.com&lt;/A&gt; but never thought regex will have this functionality. &lt;/P&gt;

&lt;P&gt;Once again thank you and Regards,&lt;/P&gt;</description>
    <pubDate>Mon, 26 Nov 2018 01:09:08 GMT</pubDate>
    <dc:creator>kakarsu</dc:creator>
    <dc:date>2018-11-26T01:09:08Z</dc:date>
    <item>
      <title>Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398244#M174459</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;I am faced with another problem where the logs I have contain only 3 fields with Start_Loading_Time, _Event_Reference, Event_Name.&lt;BR /&gt;
An example of this log is shown below in the dummy data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11:00:31:800,3200,ABCDeposit;11:00:33:940,3201,ABCSelectAmount;11:00:35:320,3202,ABCSelectAccount;11:00:42:670,3203,ABCConfirm;11:00:50:350,3204,ACBSuccessfulEnd
.......
.......
.......
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have used the split function to split the above record by ";", which will give me below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11:00:31:800,3200,ABCDeposit
11:00:33:940,3201,ABCSelectAmount
11:00:35:320,3202,ABCSelectAccount
11:00:42:670,3203,ABCConfirm
11:00:50:350,3204,ACBSuccessfulEnd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have then used the below regex to capture the two fields I'm after:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?Start_Loading_Time[^\,]+)\,\d*\,(?Event_Name\w+[^\n]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am trying to create is to get "11:00:33:940" -1milisecond as End_Loading_Time for ABCDeposit and use "11:00:33:940" as Start_Loading_Time for ABCSelectAmount similarly I want to capture "11:00:35:320" -1milisecond as End_Loading_Time for ABCSelectAmount and use "11:00:35:320" Start_Loading_Time for ABCSelectAccount and so on.&lt;/P&gt;

&lt;P&gt;Any suggestion or help would be much appreciated.&lt;/P&gt;

&lt;P&gt;Many Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398244#M174459</guid>
      <dc:creator>kakarsu</dc:creator>
      <dc:date>2020-09-29T22:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398245#M174460</link>
      <description>&lt;P&gt;So basically, you want to take the start time of the next step (minus 1 ms) as the end time of the current step? One thing you could do is duplicate the timestamp before splitting. So (first 2 lines are just to generate a sample event):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval event = "11:00:31:800,3200,ABCDeposit;11:00:33:940,3201,ABCSelectAmount;11:00:35:320,3202,ABCSelectAccount;11:00:42:670,3203,ABCConfirm;11:00:50:350,3204,ACBSuccessfulEnd"
| rex field=event mode=sed "s/;([^,]+)/,\1;\1/g"
| eval event = split(event,";")
| mvexpand event
| rex field=event "(?&amp;lt;Start_Loading_Time&amp;gt;[^,]+),\d*,(?&amp;lt;Event_Name&amp;gt;[^,]+),?(?&amp;lt;End_Loading_Time&amp;gt;.+)?"
| eval End_Loading_Time = strftime(strptime(End_Loading_Time,"%H:%M:%S:%3N")-0.001,"%H:%M:%S:%3N")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The rex sed command on line 3 changes your data into: &lt;CODE&gt;11:00:31:800,3200,ABCDeposit,11:00:33:940;11:00:33:940,3201,ABCSelectAmount,11:00:35:320;11:00:35:320,3202,ABCSelectAccount,11:00:42:670;11:00:42:670,3203,ABCConfirm,11:00:50:350;11:00:50:350,3204,ACBSuccessfulEnd&lt;/CODE&gt; effectively duplicating the timestamp from the next step as an extra field to the previous step.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 09:30:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398245#M174460</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-11-20T09:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398246#M174461</link>
      <description>&lt;P&gt;Thank you very much for the quick response, one should have mentioned that within this log I have another pair of logs that contains as below (Please bear in mind that below data is dummy, the time and action names vary):&lt;BR /&gt;
"11:00:31:800,3200,ABCDeposit, Selected_Action;11:00:33:940,3201,ABCSelectAmount,Selected_Amount;11:00:35:320,3202,ABCSelectAccount,Selected_Account,;11:00:42:670,3203,ABCConfirm,Selected_Button;11:00:50:350,3204,ACBSuccessfulEnd,Confirmed"&lt;/P&gt;

&lt;P&gt;And another one:&lt;/P&gt;

&lt;P&gt;"11:00:31:800,3200,ABCDeposit, Selected_Action;11:00:33:940,3201,ABCSelectAmount,0;11:00:35:320,3202,ABCSelectAccount,0;11:00:42:670,3203,ABCConfirm,0;11:00:50:350,3204,ACBSuccessfulEnd,0"&lt;/P&gt;

&lt;P&gt;How do I get the | rex field=event mode=sed for the above logs?&lt;/P&gt;

&lt;P&gt;I tried to analyse your code but failed. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks a million in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398246#M174461</guid>
      <dc:creator>kakarsu</dc:creator>
      <dc:date>2020-09-29T22:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398247#M174462</link>
      <description>&lt;P&gt;The code I gave should apply just fine to those other logs as well, right? All it does, is find each &lt;CODE&gt;;&lt;/CODE&gt;, captures any tekst that follows, until the first &lt;CODE&gt;,&lt;/CODE&gt; (ie. captures the timestamp). And then replaces that by a &lt;CODE&gt;,&lt;/CODE&gt;, followed by a copy of the timestamp, followed by the &lt;CODE&gt;;&lt;/CODE&gt; followed by the captured timestamp again. So it just duplicates the timestamp to the left side of the &lt;CODE&gt;;&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;As an example, it replaces &lt;CODE&gt;;11:00:33:940&lt;/CODE&gt; by &lt;CODE&gt;,11:00:33:940;11:00:33:940&lt;/CODE&gt;. That way, when you then split the data by &lt;CODE&gt;;&lt;/CODE&gt;, you have the timestamp from the next item also as an extra field at the end of the previous item.&lt;/P&gt;

&lt;P&gt;It basically (after splitting) changes this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11:00:31:800,3200,ABCDeposit
11:00:33:940,3201,ABCSelectAmount
11:00:35:320,3202,ABCSelectAccount
11:00:42:670,3203,ABCConfirm
11:00:50:350,3204,ACBSuccessfulEnd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Into this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11:00:31:800,3200,ABCDeposit,11:00:33:940
11:00:33:940,3201,ABCSelectAmount,11:00:35:320
11:00:35:320,3202,ABCSelectAccount,11:00:42:670
11:00:42:670,3203,ABCConfirm,11:00:50:350
11:00:50:350,3204,ACBSuccessfulEnd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Did you try it and ran into issues?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 13:20:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398247#M174462</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-11-21T13:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398248#M174463</link>
      <description>&lt;P&gt;Thank you very much @FrankVl much appreciated mate. I had to update the next regex command to match the criteria for them and it is working as I was expecting.&lt;/P&gt;

&lt;P&gt;While I will accept your solution as correct I was wondering to know if you can post me some good sites where I can learn more about Regex specifically the one that teaches the " | rex field=event mode=sed"&lt;BR /&gt;
I have known the regex101 and &lt;A href="http://www.udemy.com"&gt;www.udemy.com&lt;/A&gt; but never thought regex will have this functionality. &lt;/P&gt;

&lt;P&gt;Once again thank you and Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 01:09:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398248#M174463</guid>
      <dc:creator>kakarsu</dc:creator>
      <dc:date>2018-11-26T01:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398249#M174464</link>
      <description>&lt;P&gt;It is not so much a feature of regular expressions. It is using the sed utility to perform string manipulations. Generic info on the sed utility: &lt;A href="https://linux.die.net/man/1/sed"&gt;https://linux.die.net/man/1/sed&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Note: Splunk only supports a very limited set of sed functionalities, namely replace (s) and character substitution (y). See also props.conf spec:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-&amp;lt;class&amp;gt; = &amp;lt;sed script&amp;gt;
* Only used at index time.
* Commonly used to anonymize incoming data at index time, such as credit
  card or social security numbers. For more information, search the online
  documentation for "anonymize data."
* Used to specify a sed script which Splunk software applies to the _raw 
  field.
* A sed script is a space-separated list of sed commands. Currently the
  following subset of sed commands is supported:
    * replace (s) and character substitution (y).
* Syntax:
    * replace - s/regex/replacement/flags
      * regex is a perl regular expression (optionally containing capturing
        groups).
      * replacement is a string to replace the regex match. Use \n for back
        references, where "n" is a single digit.
      * flags can be either: g to replace all matches, or a number to
        replace a specified match.
    * substitute - y/string1/string2/
      * substitutes the string1[i] with string2[i]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 08:47:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398249#M174464</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-11-26T08:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating End_Loading_Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398250#M174465</link>
      <description>&lt;P&gt;You are a legend! thank you for the info mate.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 02:49:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-End-Loading-Time/m-p/398250#M174465</guid>
      <dc:creator>kakarsu</dc:creator>
      <dc:date>2018-11-27T02:49:14Z</dc:date>
    </item>
  </channel>
</rss>

