<?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: get the start and end time based on key words in logs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629828#M218810</link>
    <description>&lt;P&gt;Use rex to extract the file name portion from the string that you want.&lt;/P&gt;&lt;P&gt;For example, if you have the _raw string which contains your data as in your example, you can do this regular expression to extract the filex/filey parts&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex " \d{6}_(?&amp;lt;file&amp;gt;[A-Za-z0-9]+)"&lt;/LI-CODE&gt;&lt;P&gt;that looks for a space + 6 digits then an _ before it then extracts a new field called "file" containing just the characters in the square brackets.&lt;/P&gt;&lt;P&gt;If you already have a field containing that entire string, then use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=your_field "\d{6}_(?&amp;lt;file&amp;gt;[A-Za-z0-9]+)"&lt;/LI-CODE&gt;&lt;P&gt;or change the regex as needed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 05:59:10 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-02-07T05:59:10Z</dc:date>
    <item>
      <title>How to get the start and end time based on key words in logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629664#M218752</link>
      <description>&lt;P&gt;Hi folks looking for some expert opinion.&lt;/P&gt;
&lt;P&gt;my logs contains many diff files. I want to capture the start and end time for each file&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the logs looks like this&lt;/P&gt;
&lt;P&gt;timestamp 202301_filex_a_b.z started execution&lt;/P&gt;
&lt;P&gt;timestamp 202301_filex_a_b.z finished execution&lt;/P&gt;
&lt;P&gt;timestamp 202301_filey_e_f.z started execution&lt;/P&gt;
&lt;P&gt;timestamp 202301_filey_e_f.z finished execution&lt;/P&gt;
&lt;P&gt;The output would look something like&lt;/P&gt;
&lt;P&gt;filex | start timestamp | end timestamp | duration&lt;/P&gt;
&lt;P&gt;filey&amp;nbsp;| start timestamp | end timestamp | duration&lt;/P&gt;
&lt;P&gt;I was able to do write diff search for start and end and then join them on the filename, but wondering if there is a better way to do it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 15:08:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629664#M218752</guid>
      <dc:creator>merc14</dc:creator>
      <dc:date>2023-02-06T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: get the start and end time based on key words in logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629665#M218753</link>
      <description>&lt;P&gt;Simple method is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats min(_time) as start max(_time) as end by file
| eval duration=end-start&lt;/LI-CODE&gt;&lt;P&gt;That assumes the following&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;you have a field "file" containing the file name&lt;/LI&gt;&lt;LI&gt;_time is the log timestamp of the event&lt;/LI&gt;&lt;LI&gt;there are only 2 log messages per file and start always comes before end&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;It simply calculates the minimum and maximum value for the time and then calculates duration&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 03:47:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629665#M218753</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-06T03:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: get the start and end time based on key words in logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629822#M218807</link>
      <description>&lt;P&gt;need one more clarification, here file is a substring (filex, filey), can you please let me know how I can get the value for file&amp;nbsp; and combine it with | stats&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 04:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629822#M218807</guid>
      <dc:creator>merc14</dc:creator>
      <dc:date>2023-02-07T04:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: get the start and end time based on key words in logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629828#M218810</link>
      <description>&lt;P&gt;Use rex to extract the file name portion from the string that you want.&lt;/P&gt;&lt;P&gt;For example, if you have the _raw string which contains your data as in your example, you can do this regular expression to extract the filex/filey parts&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex " \d{6}_(?&amp;lt;file&amp;gt;[A-Za-z0-9]+)"&lt;/LI-CODE&gt;&lt;P&gt;that looks for a space + 6 digits then an _ before it then extracts a new field called "file" containing just the characters in the square brackets.&lt;/P&gt;&lt;P&gt;If you already have a field containing that entire string, then use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=your_field "\d{6}_(?&amp;lt;file&amp;gt;[A-Za-z0-9]+)"&lt;/LI-CODE&gt;&lt;P&gt;or change the regex as needed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 05:59:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-start-and-end-time-based-on-key-words-in-logs/m-p/629828#M218810</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-07T05:59:10Z</dc:date>
    </item>
  </channel>
</rss>

