<?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: PHP_error auto extraction not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173110#M49651</link>
    <description>&lt;P&gt;PHP error logs are not part of the pre-trained sourcetypes, per &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Data/Listofpretrainedsourcetypes" target="_blank"&gt;this documentation&lt;/A&gt;.&lt;BR /&gt;
Fields will only be auto-extracted for self-describing log formats, like key=value, json or XML, for example.&lt;/P&gt;

&lt;P&gt;If you want fields extracted, you will have to configure field extraction for each of the log formats you will see from your servers. You could create two sourcetypes (php_error_fmt1, php_error_fmt2) and then just search for sourcetype=php_error_fmt* to search across both formats.&lt;/P&gt;

&lt;P&gt;You can create your field extractions either &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles" target="_blank"&gt;via configuration files&lt;/A&gt;, or by using the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Knowledge/ExtractfieldsinteractivelywithIFX" target="_blank"&gt;interactive field extractor&lt;/A&gt; in the UI.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 06:58:17 GMT</pubDate>
    <dc:creator>s2_splunk</dc:creator>
    <dc:date>2020-09-29T06:58:17Z</dc:date>
    <item>
      <title>PHP_error auto extraction not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173108#M49649</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have set up two servers forwarding php error logs to Splunk. The souretype is set to log4php but the field auto extraction is not working.&lt;/P&gt;

&lt;P&gt;These are what Splunk gives me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# date_hour 2
# date_mday 1
# date_minute 2
a date_month 1
# date_second 3
a date_wday 1
# date_year 1
a date_zone 2
a index 1
# linecount 2
a punct 3
a splunk_server 1
# timeendpos 2
# timestartpos 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Both servers have a slightly different log format:&lt;/P&gt;

&lt;P&gt;Server 1&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[13-Aug-2015 10:16:40 UTC] PHP Notice:  Use of undefined constant gdfgdg - assumed 'gdfgdg' in /srv/users/serverpilot/apps/gibhershop2/public/test.php on line 6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Server 2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Thu Aug 13 11:36:09.160891 2015] [:error] [pid 1823] [client 141.101.98.217:23987] PHP Parse error: syntax error, unexpected '!' in /var/www/gsysmp/err.php on line 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Edit&lt;BR /&gt;
The fields I want are:&lt;/P&gt;

&lt;P&gt;Server 1&lt;/P&gt;

&lt;P&gt;PHP error type, in the example that's &lt;STRONG&gt;PHP Notice&lt;/STRONG&gt;, but could be PHP Error: etc.&lt;BR /&gt;
The actual error message, in the example &lt;STRONG&gt;Use of undefined constant gdfgdg - assumed 'gdfgdg'&lt;/STRONG&gt;   - so that's from the ':' of the error type up to 'in /path....'&lt;BR /&gt;
The error location, so the path and line number: &lt;STRONG&gt;/srv/users/serverpilot/apps/gibhershop2/public/test.php on line 6&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Server 2&lt;/P&gt;

&lt;P&gt;PHP error type: [:&lt;STRONG&gt;error&lt;/STRONG&gt;], again this might have other values such as warning or notice.&lt;BR /&gt;
Error message: &lt;STRONG&gt;PHP Parse error: syntax error, unexpected '!'&lt;/STRONG&gt;&lt;BR /&gt;
Error location: &lt;STRONG&gt;/var/www/gsysmp/err.php on line 3&lt;/STRONG&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Am I doing something wrong? Does anyone have some good searches set up for dealing with this type of log if Splunk doesn't auto extract the fields well?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Ric&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 10:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173108#M49649</guid>
      <dc:creator>BWRic</dc:creator>
      <dc:date>2015-08-13T10:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: PHP_error auto extraction not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173109#M49650</link>
      <description>&lt;P&gt;If you will explain in each of these logs what fields are supposed to be created where, I will show you a command string that creates them.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 18:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173109#M49650</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-13T18:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: PHP_error auto extraction not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173110#M49651</link>
      <description>&lt;P&gt;PHP error logs are not part of the pre-trained sourcetypes, per &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Data/Listofpretrainedsourcetypes" target="_blank"&gt;this documentation&lt;/A&gt;.&lt;BR /&gt;
Fields will only be auto-extracted for self-describing log formats, like key=value, json or XML, for example.&lt;/P&gt;

&lt;P&gt;If you want fields extracted, you will have to configure field extraction for each of the log formats you will see from your servers. You could create two sourcetypes (php_error_fmt1, php_error_fmt2) and then just search for sourcetype=php_error_fmt* to search across both formats.&lt;/P&gt;

&lt;P&gt;You can create your field extractions either &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles" target="_blank"&gt;via configuration files&lt;/A&gt;, or by using the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Knowledge/ExtractfieldsinteractivelywithIFX" target="_blank"&gt;interactive field extractor&lt;/A&gt; in the UI.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173110#M49651</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2020-09-29T06:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: PHP_error auto extraction not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173111#M49652</link>
      <description>&lt;P&gt;@woodcock, thanks, I have updated my answer with the fields I'd like&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2015 08:18:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173111#M49652</guid>
      <dc:creator>BWRic</dc:creator>
      <dc:date>2015-08-14T08:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: PHP_error auto extraction not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173112#M49653</link>
      <description>&lt;P&gt;OK, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex ".*\](?&amp;lt;PHP_Error_Type&amp;gt;[^:]+):\s*(?&amp;lt;PHP_Error_Message&amp;gt;.*)\s+in\s+(?&amp;lt;PHP_Error_Location&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2015 14:48:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PHP-error-auto-extraction-not-working/m-p/173112#M49653</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-14T14:48:48Z</dc:date>
    </item>
  </channel>
</rss>

