<?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: Extract error message from java error logs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624922#M217240</link>
    <description>&lt;P&gt;No &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am seeing entire error message as is if i exactly use your query and if I add table field then null values are being returned&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2022 03:24:02 GMT</pubDate>
    <dc:creator>mail2uharishp</dc:creator>
    <dc:date>2022-12-21T03:24:02Z</dc:date>
    <item>
      <title>How to extract error message from java error logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624913#M217235</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Could you please help in extracting the error log from java error log.&lt;BR /&gt;&lt;BR /&gt;I would like to see the result in a table format&lt;BR /&gt;Code | Message&lt;BR /&gt;1234 | due to system error&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Error log is as below&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;message: Exception Occurred ::org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: [{"code":"1234","reason":"due to system error.","type":"ValidationException"}]&lt;BR /&gt;at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:303)&lt;BR /&gt;at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:384)&lt;BR /&gt;at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:325)&lt;BR /&gt;......&lt;BR /&gt;&lt;BR /&gt;I have tried few extractions from splunk searches, however nothing were fruitful.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 04:51:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624913#M217235</guid>
      <dc:creator>mail2uharishp</dc:creator>
      <dc:date>2022-12-21T04:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extract error message from java error logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624919#M217238</link>
      <description>&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/Bad Request: */Bad_Request=/" ``` extract JSON array ```
| kv
| spath input=Bad_Request path={}
| mvexpand {} ``` in case there are multiple elements in JSON array ```
| spath input={}
| fields code reason&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 02:45:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624919#M217238</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-12-21T02:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extract error message from java error logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624921#M217239</link>
      <description>&lt;P&gt;No &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt; , it is still returning a blank data for me&lt;BR /&gt;&lt;BR /&gt;I have added table to your query only, apart from providing index my query looks like below&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = myindex "searchfields"
| rex mode=sed "s/Bad Request: */Bad_Request=/" ``` extract JSON array ```
| kv
| spath input=Bad_Request path={}
| mvexpand {} ``` in case there are multiple elements in JSON array ```
| spath input={}
| fields code reason
|table code reason&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 03:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624921#M217239</guid>
      <dc:creator>mail2uharishp</dc:creator>
      <dc:date>2022-12-21T03:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract error message from java error logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624922#M217240</link>
      <description>&lt;P&gt;No &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am seeing entire error message as is if i exactly use your query and if I add table field then null values are being returned&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 03:24:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624922#M217240</guid>
      <dc:creator>mail2uharishp</dc:creator>
      <dc:date>2022-12-21T03:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract error message from java error logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624927#M217242</link>
      <description>&lt;P&gt;This may mean that your data isn't exactly like you illustrated. &amp;nbsp;Let's diagnose step by step. (table command will not do anything special if you already see blank.) Please post result from the following (anonymize as needed):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search "Bad Request:" ``` only bad requests of interest ```
| rex mode=sed "s/Bad Request:\s*/Bad_Request=/" ``` extract JSON array ```
| kv
| table Bad_Request&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Emulated output&lt;/H3&gt;&lt;P&gt;The following is the emulation I use, and the result I get from your sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval _raw = "message: Exception Occurred ::org.springframework.web.client.HttpClientErrorException: 400 Bad Request: [{\"code\":\"1234\",\"reason\":\"due to system error.\",\"type\":\"ValidationException\"}]
at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:303)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:384)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:325)
......"
``` data emulation above ```
| rex mode=sed "s/Bad Request: */Bad_Request=/" ``` extract JSON array ```
| kv
| table Bad_Request _raw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Bad_Request&lt;/TD&gt;&lt;TD&gt;_raw&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;[{"code":"1234","reason":"due to system error.","type":"ValidationException"}]&lt;/TD&gt;&lt;TD&gt;message: Exception Occurred ::org.springframework.web.client.HttpClientErrorException: 400 Bad_Request=[{"code":"1234","reason":"due to system error.","type":"ValidationException"}] at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:303) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:384) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:325) ......&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Do you get similar output?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 05:08:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-error-message-from-java-error-logs/m-p/624927#M217242</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-12-21T05:08:00Z</dc:date>
    </item>
  </channel>
</rss>

