<?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 to extract two different fields on same timestamp based on the type of log statement? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338874#M62545</link>
    <description>&lt;P&gt;Hi mlprasad,&lt;/P&gt;

&lt;P&gt;look at this solution.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\]\s+?((?&amp;lt;begin_time&amp;gt;.+?)\s\"Starting|(?&amp;lt;end_time&amp;gt;.+?)\s\"End)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that you are able to reformat the newly created fields further.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2017 14:01:15 GMT</pubDate>
    <dc:creator>horsefez</dc:creator>
    <dc:date>2017-11-03T14:01:15Z</dc:date>
    <item>
      <title>How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338864#M62535</link>
      <description>&lt;P&gt;Hi there,&lt;BR /&gt;
I have the following two different sample logger statements, the first statement written at the beginning of the process flow and the second logger is written at the end of the process flow.&lt;BR /&gt;
1. [Info] &lt;STRONG&gt;2017/09/09 12:00:00, 456&lt;/STRONG&gt;   "Starting of the process"&lt;BR /&gt;
2. [Info] &lt;STRONG&gt;2017/09/09 12:00:00, 789&lt;/STRONG&gt;   "End of the process".&lt;/P&gt;

&lt;P&gt;Now, I want to extract 2 different fields on the time stamp, if the logger statement is "Starting of the process" I need to create &lt;STRONG&gt;beginTime&lt;/STRONG&gt; field, and if the logger statement is "end of the process", I need to create &lt;STRONG&gt;endTime&lt;/STRONG&gt; field, Please help.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 11:08:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338864#M62535</guid>
      <dc:creator>mlprasad79</dc:creator>
      <dc:date>2017-10-31T11:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338865#M62536</link>
      <description>&lt;P&gt;Hello there @mlprasad79&lt;/P&gt;

&lt;P&gt;This might work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\]\s(?&amp;lt;beginTime&amp;gt;[\d\/\s:]+)(?=,\s\d+\s\"Starting)" | rex "\]\s(?&amp;lt;endTime&amp;gt;[\d\/\s:]+)(?=,\s\d+\s\"End)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 13:24:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338865#M62536</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-10-31T13:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338866#M62537</link>
      <description>&lt;P&gt;Hi @Alemarzu,&lt;/P&gt;

&lt;P&gt;Thanks for your reply, &lt;BR /&gt;
The rex is giving result till this portion | &lt;STRONG&gt;rex "]\s(?[\d\/\s:]+)(?=,\s\d+\s&lt;/STRONG&gt; , but if I append &lt;STRONG&gt;\"Starting&lt;/STRONG&gt;, it is producing empty results, what went wong??&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 12:02:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338866#M62537</guid>
      <dc:creator>mlprasad79</dc:creator>
      <dc:date>2017-11-02T12:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338867#M62538</link>
      <description>&lt;P&gt;My bad, square brackets at the beginning were not scaped. Its fixed now.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 13:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338867#M62538</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-11-02T13:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338868#M62539</link>
      <description>&lt;P&gt;Hi Alemarzu,&lt;/P&gt;

&lt;P&gt;Here is my actual  sample first and last logger statements,&lt;BR /&gt;
[INFO ] 2017-11-02 10:58:16,071  - com.aetna.eie.vtwoprovider.helper.util  VTwoProviderRule  87675606-ddcc-4841-a925-96aac6a1a395-L7  &lt;STRONG&gt;MainflowOUT  Exit the Ruleflow&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;[INFO ] 2017-11-02 10:58:16,071  - com.aetna.eie.vtwoprovider.helper.util  VTwoProviderRule  87675606-ddcc-4841-a925-96aac6a1a395-L7  &lt;STRONG&gt;MainflowIN  Into the Ruleflow&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;where the highlighted is the string decided whther the logger is first statement or last.&lt;/P&gt;

&lt;P&gt;Here is my search query,&lt;BR /&gt;
((com.aetna.eie.vtwoprovider.helper.util  VTwoProviderRule  * "MainflowIN  Into the Ruleflow") OR (com.aetna.eie.vtwoprovider.helper.util  VTwoProviderRule  * "MainflowOUT  Exit the Ruleflow")) |rex "]\s(?P\d+-\d+-\d+\s+\d+:\d+:\d+,\d+)(?=\s+-\s+\w+.\w+.\w+.\w+.\w+.\w+\s+\w+\s+ )" &lt;BR /&gt;
if I try to hard code "MainflowIN" or "MainflowOUT" at the end of the query the results are blank, if I don't add this string results are coming but my ultimate goal is not achevied, please help. &lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 15:06:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338868#M62539</guid>
      <dc:creator>mlprasad79</dc:creator>
      <dc:date>2017-11-02T15:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338869#M62540</link>
      <description>&lt;P&gt;It would be more efficient to do both extractions in a single regex. &lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 16:28:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338869#M62540</guid>
      <dc:creator>valiquet</dc:creator>
      <dc:date>2017-11-02T16:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338870#M62541</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/74914"&gt;@mlprasad79&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;try this,&lt;/P&gt;

&lt;P&gt;your search | rex field=_raw "[\S+\s+]\s(?P&amp;lt;end_time&amp;gt;\d+-\d+-\d+\s\d+:\d+:\d+\,\d+)\s+-\s+.+(?P&amp;lt;MainFlowOUT&amp;gt;MainflowOUT)" | rex field=_raw "[\S+\s+]\s(?P&amp;lt;begin_time&amp;gt;\d+-\d+-\d+\s\d+:\d+:\d+\,\d+)\s+-\s+.+(?P&amp;lt;MainFlowIN&amp;gt;MainflowIN)"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338870#M62541</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T16:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338871#M62542</link>
      <description>&lt;P&gt;Hi Badri, &lt;BR /&gt;
Thanks for your reply, &lt;/P&gt;

&lt;P&gt;The query is kinda working fine, now I am trying to figure out the response time which is end_time - begin_time.&lt;BR /&gt;
For that I am using the below query,&lt;BR /&gt;
--above query--|eval response_time=strptime(end_time,"%Y-%m-%d %H:%M:%S.%3N") - strptime(begin_time,"%Y-%m-%d %H:%M:%S.%3N") |table begin_time, end_time , response_time.&lt;/P&gt;

&lt;P&gt;but the response_time column is coming empty, not sure what went wrong.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:37:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338871#M62542</guid>
      <dc:creator>mlprasad79</dc:creator>
      <dc:date>2020-09-29T16:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338872#M62543</link>
      <description>&lt;P&gt;Try this&lt;BR /&gt;
strptime(end_time,”%Y/%m/%d %H:%M:%S, %3N”) and do the same thing for begin_time&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338872#M62543</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T16:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338873#M62544</link>
      <description>&lt;P&gt;Oh I see what happened. The log sample that you provided at the beginnig is not the same like the one above.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 13:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338873#M62544</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-11-03T13:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two different fields on same timestamp based on the type of log statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338874#M62545</link>
      <description>&lt;P&gt;Hi mlprasad,&lt;/P&gt;

&lt;P&gt;look at this solution.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\]\s+?((?&amp;lt;begin_time&amp;gt;.+?)\s\"Starting|(?&amp;lt;end_time&amp;gt;.+?)\s\"End)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that you are able to reformat the newly created fields further.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 14:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-two-different-fields-on-same-timestamp-based-on/m-p/338874#M62545</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2017-11-03T14:01:15Z</dc:date>
    </item>
  </channel>
</rss>

