<?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: Regex/timestamp question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63442#M15677</link>
    <description>&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Just given one event, it's not easy to give a regex that will always work. Try &lt;CODE&gt;rex&lt;/CODE&gt; to find a regex that will match the correct part of the event. The following might work for you.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | rex "^(?:\S+\s+){3}(?&amp;lt;msg&amp;gt;.*)$"&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;If Splunk does not capture the timestamp in the event correctly, you may have to edit the props.conf on the splunk server where the PARSING takes place. Normally that would be the Indexer, but if you have Heavy Forwarders, that's where you would make the configuration.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TIME_PREFIX = \[
TIME_FORMAT = %m/%d/%y %H:%M:%S
MAX_TIMESTAMP_LOOKAHEAD = 40
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
    <pubDate>Tue, 18 Sep 2012 14:44:03 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2012-09-18T14:44:03Z</dc:date>
    <item>
      <title>Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63440#M15675</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;

&lt;P&gt;Given an event like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; PSMONITORSRV.32876010 (0) [09/15/12 09:16:20](3) PSJNI: Created a Java VM instance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have two questions:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;What is the regex for extracting just the message? The message in this case is "PSJNI: Created a Java VM instance". I can sorta get it to work, but it keeps capture the timestamp in the message as well. &lt;/LI&gt;
&lt;LI&gt;How do I tell Splunk to index the event based on the time in the event's timestamp, and not on the time it was actually indexed? 99.9% of the time the two are the same, but once in a while there's a difference, and I'd rather Splunk index based on what the event says. &lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 14:25:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63440#M15675</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2012-09-18T14:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63441#M15676</link>
      <description>&lt;P&gt;Regex (assuming general format stays the same): "&lt;CODE&gt;\[\d+/\d+/\d+\s+\d+:\d+:\d+\]\(\d+\)(?P&amp;lt;yourField&amp;gt;.*)$&lt;/CODE&gt;"&lt;/P&gt;

&lt;P&gt;You can test regular expressions on you data using the following web-based tool: &lt;A href="http://gskinner.com/RegExr/"&gt;http://gskinner.com/RegExr/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;For timestamp recognition you should look at the following docs: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/Configuretimestamprecognition"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Data/Configuretimestamprecognition&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So for example for you data sourcetype you could configure something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yourSourcetype]
MAX_TIMESTAMP_LOOKAHEAD = &amp;lt;integer&amp;gt;
TIME_PREFIX = &amp;lt;regular expression&amp;gt;
TIME_FORMAT = &amp;lt;strptime-style format&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;External resource for strptime format: &lt;A href="http://linux.die.net/man/3/strptime"&gt;http://linux.die.net/man/3/strptime&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 14:33:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63441#M15676</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-09-18T14:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63442#M15677</link>
      <description>&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Just given one event, it's not easy to give a regex that will always work. Try &lt;CODE&gt;rex&lt;/CODE&gt; to find a regex that will match the correct part of the event. The following might work for you.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | rex "^(?:\S+\s+){3}(?&amp;lt;msg&amp;gt;.*)$"&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;If Splunk does not capture the timestamp in the event correctly, you may have to edit the props.conf on the splunk server where the PARSING takes place. Normally that would be the Indexer, but if you have Heavy Forwarders, that's where you would make the configuration.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TIME_PREFIX = \[
TIME_FORMAT = %m/%d/%y %H:%M:%S
MAX_TIMESTAMP_LOOKAHEAD = 40
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 14:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63442#M15677</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-18T14:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63443#M15678</link>
      <description>&lt;P&gt;Oh dear..... not again...&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 14:44:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63443#M15678</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-18T14:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63444#M15679</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; we should stop meeting like this&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 14:51:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63444#M15679</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-09-18T14:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63445#M15680</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; indeed&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 14:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63445#M15680</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-18T14:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63446#M15681</link>
      <description>&lt;P&gt;Thank you for your response. I will give this a try and report back!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 16:25:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63446#M15681</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2012-09-18T16:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Regex/timestamp question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63447#M15682</link>
      <description>&lt;P&gt;Thank you as well for your response. I plan to give these a try later today. Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 16:25:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-timestamp-question/m-p/63447#M15682</guid>
      <dc:creator>Branden</dc:creator>
      <dc:date>2012-09-18T16:25:46Z</dc:date>
    </item>
  </channel>
</rss>

