<?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 How to extract fields from log in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458493#M129457</link>
    <description>&lt;P&gt;I'm trying to extract fields from a log and failing miserably. &lt;BR /&gt;
In my first attempt I used a props.conf to specify the delimiter and field names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ipoz]
FIELD_NAMES = "Priority","Date","Thread","Category","Message"
FIELD_DELIMITER="\t"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That didn't work for some reason, so I tried using props and transforms first by specifying the delimiter/fields again, and later switching to regular expression like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;props.conf&amp;gt;
[ipoz]
REPORT-IPOZ=IPOZ-DELIM
&amp;lt;transforms.conf&amp;gt;
[IPOZ-DELIM]
#DELIMS="\t"
#FIELDS="Priority","Date","Thread","Category","Message"
REGEX=(?&amp;lt;Priority&amp;gt;.+)\t(?&amp;lt;Date&amp;gt;.+)\t(?&amp;lt;Thread&amp;gt;.+)\t(?&amp;lt;Category&amp;gt;.+)\t(?&amp;lt;Message&amp;gt;.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have some control over the formatting of the log, so I can change the delimiter, but since the 5th field can contain commas I feel like using tab for a delimiter is the right choice.&lt;BR /&gt;
Can anyone help with this???  I have confirmed that the log is indeed tab delimited by checking the logger configuration (log4j), pasting the log into Notepad++ and showing characters, and using a regex tester to validate the regex.&lt;/P&gt;

&lt;P&gt;Here is the relevant section of inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor://&amp;lt;path to the not so very good software company&amp;gt;\ipoz.log]
index=casuite
sourcetype=ipoz
disabled = 0
queue = parsingQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is a sample of the log I am trying to parse.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ERROR   2019-08-21 10:53:32,386 [0x00001cb4]    [eiam.server.ipoz.sponsorinterfacev1]   [src/Poz.cpp:2047] bool __cdecl eiam::server::poz::Poz::detach(const class eiam::core::String &amp;amp;)
 INFO   2019-08-21 11:19:32,821 [0x0000222c]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   SponsorInterfaceV1::clientDetach: detach failed [sessionId: 43d70a8e665b51f5363dc44ad1f5537d-5d5c41dd-cb06650-1e2, clienthost: 10.33.52.44:60103]
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   Exception[-704]: session expired
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   [src/SessionManager.cpp:286] class eiam::server::dirobj::Session *__cdecl eiam::server::poz::SessionManager::retrieveSession(const class eiam::core::String &amp;amp;)
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   [src/Poz.cpp:3433] class eiam::server::dirobj::Session *__cdecl eiam::server::poz::Poz::retrieveSession(const class eiam::core::String &amp;amp;)
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   [src/Poz.cpp:2047] bool __cdecl eiam::server::poz::Poz::detach(const class eiam::core::String &amp;amp;)
 INFO   2019-08-21 11:42:41,448 [0x00000bec]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:09:29,304 [0x000012b0]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:10:15,716 [0x00001150]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:14:52,428 [0x000003b8]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:19:49,863 [0x00001e48]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:24:26,612 [0x00001858]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
INFO    2019-08-21 13:27:33,143 [0x00001698]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Aug 2019 18:39:32 GMT</pubDate>
    <dc:creator>insert_regex_he</dc:creator>
    <dc:date>2019-08-21T18:39:32Z</dc:date>
    <item>
      <title>How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458493#M129457</link>
      <description>&lt;P&gt;I'm trying to extract fields from a log and failing miserably. &lt;BR /&gt;
In my first attempt I used a props.conf to specify the delimiter and field names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ipoz]
FIELD_NAMES = "Priority","Date","Thread","Category","Message"
FIELD_DELIMITER="\t"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That didn't work for some reason, so I tried using props and transforms first by specifying the delimiter/fields again, and later switching to regular expression like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;props.conf&amp;gt;
[ipoz]
REPORT-IPOZ=IPOZ-DELIM
&amp;lt;transforms.conf&amp;gt;
[IPOZ-DELIM]
#DELIMS="\t"
#FIELDS="Priority","Date","Thread","Category","Message"
REGEX=(?&amp;lt;Priority&amp;gt;.+)\t(?&amp;lt;Date&amp;gt;.+)\t(?&amp;lt;Thread&amp;gt;.+)\t(?&amp;lt;Category&amp;gt;.+)\t(?&amp;lt;Message&amp;gt;.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have some control over the formatting of the log, so I can change the delimiter, but since the 5th field can contain commas I feel like using tab for a delimiter is the right choice.&lt;BR /&gt;
Can anyone help with this???  I have confirmed that the log is indeed tab delimited by checking the logger configuration (log4j), pasting the log into Notepad++ and showing characters, and using a regex tester to validate the regex.&lt;/P&gt;

&lt;P&gt;Here is the relevant section of inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor://&amp;lt;path to the not so very good software company&amp;gt;\ipoz.log]
index=casuite
sourcetype=ipoz
disabled = 0
queue = parsingQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is a sample of the log I am trying to parse.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ERROR   2019-08-21 10:53:32,386 [0x00001cb4]    [eiam.server.ipoz.sponsorinterfacev1]   [src/Poz.cpp:2047] bool __cdecl eiam::server::poz::Poz::detach(const class eiam::core::String &amp;amp;)
 INFO   2019-08-21 11:19:32,821 [0x0000222c]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   SponsorInterfaceV1::clientDetach: detach failed [sessionId: 43d70a8e665b51f5363dc44ad1f5537d-5d5c41dd-cb06650-1e2, clienthost: 10.33.52.44:60103]
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   Exception[-704]: session expired
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   [src/SessionManager.cpp:286] class eiam::server::dirobj::Session *__cdecl eiam::server::poz::SessionManager::retrieveSession(const class eiam::core::String &amp;amp;)
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   [src/Poz.cpp:3433] class eiam::server::dirobj::Session *__cdecl eiam::server::poz::Poz::retrieveSession(const class eiam::core::String &amp;amp;)
ERROR   2019-08-21 11:23:33,224 [0x00002358]    [eiam.server.ipoz.sponsorinterfacev1]   [src/Poz.cpp:2047] bool __cdecl eiam::server::poz::Poz::detach(const class eiam::core::String &amp;amp;)
 INFO   2019-08-21 11:42:41,448 [0x00000bec]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:09:29,304 [0x000012b0]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:10:15,716 [0x00001150]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:14:52,428 [0x000003b8]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:19:49,863 [0x00001e48]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
 INFO   2019-08-21 13:24:26,612 [0x00001858]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
INFO    2019-08-21 13:27:33,143 [0x00001698]    [eiam.server.ipoz.sponsor]  Sponsor::Sponsor: Poz initialized
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Aug 2019 18:39:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458493#M129457</guid>
      <dc:creator>insert_regex_he</dc:creator>
      <dc:date>2019-08-21T18:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458494#M129458</link>
      <description>&lt;P&gt;you should be able to extract this using regex , try tinkering wih your conf files as a last resort in this case&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Description="ERROR    2019-08-21 10:53:32,386    [0x00001cb4]    [eiam.server.ipoz.sponsorinterfacev1]    [src/Poz.cpp:2047] bool __cdecl eiam::server::poz::Poz::detach(const class eiam::core::String &amp;amp;)"
| rex field=Description "(?&amp;lt;pri&amp;gt;.*?)\s+"| rex field=Description "\s+(?&amp;lt;date&amp;gt;.*?)\s+\[" | rex field=Description "\[+(?&amp;lt;thread&amp;gt;.*?)\]"| rex field=Description "\]\s+\[+(?&amp;lt;cat&amp;gt;.*?)\]"| rex field=Description ".*\[+(?&amp;lt;msg&amp;gt;.*?)\)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this is what you need, there is no need to hard code description, just replace rex field=Description with rex field=_raw&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 19:14:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458494#M129458</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-21T19:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458495#M129459</link>
      <description>&lt;P&gt;i am guessing a few fields here of course, particularly your message,category fields&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 19:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458495#M129459</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-21T19:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458496#M129460</link>
      <description>&lt;P&gt;I've got a bunch of similar logs to parse and I was really hoping to break it into fields on the forwarder and not the indexer.  &lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 19:40:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458496#M129460</guid>
      <dc:creator>insert_regex_he</dc:creator>
      <dc:date>2019-08-21T19:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458497#M129461</link>
      <description>&lt;P&gt;ok but you are using \t or tab as delmiter, tried with \s or \s+ or just plain space or  ' '&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/Data/Extractfieldsfromfileswithstructureddata"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/Data/Extractfieldsfromfileswithstructureddata&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Special value   Props.conf representation&lt;BR /&gt;
form feed   \f&lt;BR /&gt;
space   space or ' '&lt;BR /&gt;
horizontal tab  \t or tab&lt;BR /&gt;
vertical tab    \v&lt;BR /&gt;
whitespace  whitespace&lt;BR /&gt;
none    none or \0&lt;BR /&gt;
file separator  fs or \034&lt;BR /&gt;
group separator gs or \035&lt;BR /&gt;
record separator    rs or \036&lt;BR /&gt;
unit separator  us or \037&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 19:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458497#M129461</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-21T19:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458498#M129462</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/199593"&gt;@insert_regex_he&lt;/a&gt;re &lt;BR /&gt;
Did you try the above options?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:53:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458498#M129462</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-30T01:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458499#M129463</link>
      <description>&lt;P&gt;I believe you are missing something in the REGEX on your second attempt.&lt;/P&gt;

&lt;P&gt;Try it like this:&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ipoz]
REPORT-IPOZ=IPOZ-DELIM
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[IPOZ-DELIM]
REGEX=(?&amp;lt;Priority&amp;gt;[^\t\s]+)[\t\s]+(?&amp;lt;Date&amp;gt;[^\t\s]+)[\t\s]+(?&amp;lt;Thread&amp;gt;[^\t\s]+)[\t\s]+(?&amp;lt;Category&amp;gt;[^\t\s]+)[\t\s]+(?&amp;lt;Message&amp;gt;.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can validate the regex here: &lt;A href="https://regex101.com/r/dcaJTn/1"&gt;https://regex101.com/r/dcaJTn/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Aug 2019 11:16:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458499#M129463</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2019-08-24T11:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458500#M129464</link>
      <description>&lt;P&gt;I figured this out.  First the delimiter in props.conf file shouldn't be in quotes (seems odd, I expect a string to be in quotes).&lt;/P&gt;

&lt;P&gt;Secondly I removed "queue = parsingQueue" from inputs.conf.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;inputs.conf&amp;gt;
[monitor://F:\Program Files\CA\SC\EmbeddedEntitlementsManager\logs\ipoz.log]
index=casuite
sourcetype=ca_eem_ipoz
disabled=0

&amp;lt;props.conf&amp;gt;
[ca_eem_ipoz]
FIELD_NAMES="Priority","Date","Thread","Category","Message"
FIELD_DELIMITER=\t

&amp;lt;transforms.conf&amp;gt;
#empty
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Aug 2019 15:23:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458500#M129464</guid>
      <dc:creator>insert_regex_he</dc:creator>
      <dc:date>2019-08-26T15:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458501#M129465</link>
      <description>&lt;P&gt;I can't use a space because the last field contains spaces.  I think tab is most appropriate for my data.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 15:26:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-log/m-p/458501#M129465</guid>
      <dc:creator>insert_regex_he</dc:creator>
      <dc:date>2019-08-26T15:26:39Z</dc:date>
    </item>
  </channel>
</rss>

