<?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 write regex for field extraction to match two log entries? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121431#M32682</link>
    <description>&lt;P&gt;@gartnerj,  my idea would be that your new style logs be called *&lt;EM&gt;yoursourcetype_v2&lt;/EM&gt; and apply a new transform with the correct delim.  You would keep your old data with a separate transform with the appropriate delim applied.  Hope that makes sense.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Sep 2014 21:07:55 GMT</pubDate>
    <dc:creator>bmacias84</dc:creator>
    <dc:date>2014-09-11T21:07:55Z</dc:date>
    <item>
      <title>How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121424#M32675</link>
      <description>&lt;P&gt;Folks,&lt;BR /&gt;
I have the following REGEX:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?:[^:\n]*:){4}\d+\.\d+\w+,(?P&amp;lt;ComponentName&amp;gt;[^,]+),(?P&amp;lt;EventCode&amp;gt;[^,]+),(?P&amp;lt;MessageType&amp;gt;[^,]+),(?P&amp;lt;NAME1&amp;gt;[^,]+)?,?(?P&amp;lt;NAME2&amp;gt;[^,]+)?,?(?P&amp;lt;NAME3&amp;gt;[^,]+)?,?ID:(?P&amp;lt;messageId&amp;gt;[^,]+),ID:(?P&amp;lt;CorrelationId&amp;gt;[^,]+),(?P&amp;lt;UserId&amp;gt;[^,]*),(?P&amp;lt;otherInfo&amp;gt;[^,]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to match 2 different log entries, one for systems that have upgraded (and have the NAME1, NAME2, NAME3, entries in the log files), and the older style which only have the ....MessageType,messageId,messageId2  stuff.&lt;/P&gt;

&lt;P&gt;Here are example log entries I need to match:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;OLD style (NO NAME1, NAME2, or NAME3 entries):&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2014-09-10T06:03:22.270Z,CLIENT,MESSAGE_SENT,SERVICE_REQUEST,ID:a1b9817d-a017-3924-a2e4-6e1ac30cd571,ID:c6ca4fa4-71ee-4453-be8e-66f41db75323,anonymous,,
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;NEW style 1 (addition of the NAME1, NAME2, NAME3 parts)&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2014-09-10T15:02:02.060Z,CLIENT,MESSAGE_SENT,SERVICE_REQUEST,NAME1,NAME2,NAME3,ID:3b84ef25-aa86-3020-951f-748bf47644f6,1161e6ca-9dc9-4205-a2bb-39fe8a220266,anonymous,,,
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;New Style 2 (blank NAME3)&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2014-09-10T15:02:02.060Z,CLIENT,MESSAGE_SENT,SERVICE_REQUEST,NAME1,NAME2,,ID:3b84ef25-aa86-3020-951f-748bf47644f6,1161e6ca-9dc9-4205-a2bb-39fe8a220266,anonymous,,,
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the REGEX above, I do match The OLD Style correctly (nothing in the NAME1, NAME2, or NAME3 groups), and the NEW STYLE1 (NAME1/NAME2 are correct, but nothing in NAME3), but when I am testing in the regex101 site, for New Style 2, I am getting and error  due to a "catastrophic backtracking" and  execution time error.&lt;BR /&gt;
I just can't seem to find the magic incantation to make sure it works for all three versions in the logs.&lt;BR /&gt;
Any help is GREATLY appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 16:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121424#M32675</guid>
      <dc:creator>gartnerj</dc:creator>
      <dc:date>2014-09-11T16:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121425#M32676</link>
      <description>&lt;P&gt;Why are you use regex?  its seem  like you should be using a transform with &lt;STRONG&gt;delim = ,&lt;/STRONG&gt;.  Then specify the fields.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 16:59:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121425#M32676</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2014-09-11T16:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121426#M32677</link>
      <description>&lt;P&gt;Don't I still need the regex to do this?  I haven't used transforms before (I will look into them more) -- I was doing this in a given search.  Also, does this change the fields for ALL users of SPLUNK, or just the APP that I am in?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 17:09:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121426#M32677</guid>
      <dc:creator>gartnerj</dc:creator>
      <dc:date>2014-09-11T17:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121427#M32678</link>
      <description>&lt;P&gt;There is s different count of fields so, a single &lt;STRONG&gt;REPORT&lt;/STRONG&gt; with DELIMS/FIELDS will not necessarily do it for you. Haven't tried working with overlapping REPORTs, but that may work. What you could do is two EXTRACTs in props.conf&lt;/P&gt;

&lt;P&gt;Btw, &lt;CODE&gt;(?:[^:\n]*:){4}&lt;/CODE&gt; looks rather odd in the beginning. Perhaps you could write &lt;CODE&gt;^[^,]+,&lt;/CODE&gt; instead to jump over the timestamp.&lt;/P&gt;

&lt;P&gt;EDIT: TYPO&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 17:25:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121427#M32678</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-09-11T17:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121428#M32679</link>
      <description>&lt;P&gt;That is true, but both new styles have the some field field count.  If gartnerj keeps the original as &lt;STRONG&gt;foo&lt;/STRONG&gt; and names the new format with a source type &lt;STRONG&gt;foov2&lt;/STRONG&gt; he shouldn't have any problems.   and the fields can be made global.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 17:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121428#M32679</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2014-09-11T17:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121429#M32680</link>
      <description>&lt;P&gt;Actually agree with you there. Normally, different format of the logs = different sourcetype.  But perhaps these sourcetypes are already in place.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 20:25:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121429#M32680</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-09-11T20:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121430#M32681</link>
      <description>&lt;P&gt;With these logs, they are all in the same sourcetype.  I'm still a bit unclear as to some of the comments above.   Keeping foo/foov2 -- not sure what you are referring to there -- are you talking about two different field transformations?  Any hints on how to construct the different field transforms?  I still don't see how I get away from the regex required to pull the three different versions.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 21:04:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121430#M32681</guid>
      <dc:creator>gartnerj</dc:creator>
      <dc:date>2014-09-11T21:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121431#M32682</link>
      <description>&lt;P&gt;@gartnerj,  my idea would be that your new style logs be called *&lt;EM&gt;yoursourcetype_v2&lt;/EM&gt; and apply a new transform with the correct delim.  You would keep your old data with a separate transform with the appropriate delim applied.  Hope that makes sense.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 21:07:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121431#M32682</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2014-09-11T21:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for field extraction to match two log entries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121432#M32683</link>
      <description>&lt;P&gt;Well, I actually got it to work via regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?:[^:\n]*:){4}\d+\.\d+\w+,(?P&amp;lt;ComponentName&amp;gt;[^,]+),(?P&amp;lt;EventCode&amp;gt;[^,]+),(?P&amp;lt;MessageType&amp;gt;[^,]+),?(?P&amp;lt;ServiceName&amp;gt;[^,]+)?,?(?P&amp;lt;ServiceMethod&amp;gt;[^,]+)?,?(?P&amp;lt;ServiceInstance&amp;gt;[^,]+)?,ID:(?P&amp;lt;messageId&amp;gt;[^,]+),ID:(?P&amp;lt;CorrelationId&amp;gt;[^,]+),(?P&amp;lt;UserId&amp;gt;[^,]*)?,(?P&amp;lt;otherInfo&amp;gt;[^,]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gets all of parts for each type correctly.  Thanks for the other suggestions -- I am going to look into those as it would be nice to have the fields extracted automatically so that I don't have to use this in each search/report.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Sep 2014 16:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-field-extraction-to-match-two-log-entries/m-p/121432#M32683</guid>
      <dc:creator>gartnerj</dc:creator>
      <dc:date>2014-09-12T16:23:25Z</dc:date>
    </item>
  </channel>
</rss>

