<?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 Time difference by grouping identical events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-by-grouping-identical-events/m-p/484859#M135727</link>
    <description>&lt;P&gt;Suppose I have the following events.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;2019-09-20 01:40:09 INFO  Listener processing event with message key A1:B1:C1&lt;BR /&gt;
2019-09-20 01:40:06 INFO  Listener processing event with message key A1:B1:C1&lt;/P&gt;

&lt;P&gt;2019-09-20 01:40:00 INFO  Listener processing event with message key A1:B1:C2&lt;/P&gt;

&lt;H2&gt;2019-09-20 01:39:57 INFO  Listener processing event with message key A1:B1:C2&lt;/H2&gt;

&lt;P&gt;The event patterns are exactly identical, and the events differ only by timestamp, and they come in pairs. The timestamps are the start and end time of the event.&lt;/P&gt;

&lt;P&gt;I would like to generate a table to summarize the events, which looks like the following&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Field1| Field2 | Field3| StartTime | EndTime | Duration&lt;BR /&gt;
A1 | B1 | C1 | 2019-09-20 01:40:06 | 2019-09-20 01:40:09 | 3&lt;BR /&gt;
A1 | B1 | C2 | 2019-09-20 01:39:57 | 2019-09-20 01:40:00 | 3&lt;/P&gt;

&lt;P&gt;The main code block looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="*.log"
| rex field=_raw "message key (?&amp;lt;A&amp;gt;.*?):(?&amp;lt;B&amp;gt;.*?):(?&amp;lt;C&amp;gt;.*)"

| table A B C _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried both the transaction and stats function, but in vain, maybe I did not use them correctly.&lt;/P&gt;

&lt;P&gt;Is there anyone who can give me some advice on what to do, any help will be highly appreciated!&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 04:58:05 GMT</pubDate>
    <dc:creator>peeeeeeeeeeter</dc:creator>
    <dc:date>2019-09-23T04:58:05Z</dc:date>
    <item>
      <title>Time difference by grouping identical events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-by-grouping-identical-events/m-p/484859#M135727</link>
      <description>&lt;P&gt;Suppose I have the following events.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;2019-09-20 01:40:09 INFO  Listener processing event with message key A1:B1:C1&lt;BR /&gt;
2019-09-20 01:40:06 INFO  Listener processing event with message key A1:B1:C1&lt;/P&gt;

&lt;P&gt;2019-09-20 01:40:00 INFO  Listener processing event with message key A1:B1:C2&lt;/P&gt;

&lt;H2&gt;2019-09-20 01:39:57 INFO  Listener processing event with message key A1:B1:C2&lt;/H2&gt;

&lt;P&gt;The event patterns are exactly identical, and the events differ only by timestamp, and they come in pairs. The timestamps are the start and end time of the event.&lt;/P&gt;

&lt;P&gt;I would like to generate a table to summarize the events, which looks like the following&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Field1| Field2 | Field3| StartTime | EndTime | Duration&lt;BR /&gt;
A1 | B1 | C1 | 2019-09-20 01:40:06 | 2019-09-20 01:40:09 | 3&lt;BR /&gt;
A1 | B1 | C2 | 2019-09-20 01:39:57 | 2019-09-20 01:40:00 | 3&lt;/P&gt;

&lt;P&gt;The main code block looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="*.log"
| rex field=_raw "message key (?&amp;lt;A&amp;gt;.*?):(?&amp;lt;B&amp;gt;.*?):(?&amp;lt;C&amp;gt;.*)"

| table A B C _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried both the transaction and stats function, but in vain, maybe I did not use them correctly.&lt;/P&gt;

&lt;P&gt;Is there anyone who can give me some advice on what to do, any help will be highly appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 04:58:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-by-grouping-identical-events/m-p/484859#M135727</guid>
      <dc:creator>peeeeeeeeeeter</dc:creator>
      <dc:date>2019-09-23T04:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference by grouping identical events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-by-grouping-identical-events/m-p/484860#M135728</link>
      <description>&lt;P&gt;Hi peter with many e,&lt;/P&gt;

&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="*.log"
 | rex field=_raw "message key (?&amp;lt;A&amp;gt;.*?):(?&amp;lt;B&amp;gt;.*?):(?&amp;lt;C&amp;gt;.*)"
 |stats earliest(_time) as StartTime latest(StartTime) as EndTime by A,B,C
 | eval duration= tostring(EndTime-StartTime,"duration")
 | table A B C StartTime EndTime duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know how that works out for you.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 07:24:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-by-grouping-identical-events/m-p/484860#M135728</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-09-23T07:24:23Z</dc:date>
    </item>
  </channel>
</rss>

