<?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 errors from unstructured log file with rex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567555#M197803</link>
    <description>&lt;P&gt;It would help to know what you've tried already, but perhaps this will help.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... | rex "Error: (?&amp;lt;Error&amp;gt;[^\[]+)"&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 19 Sep 2021 17:08:48 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-09-19T17:08:48Z</dc:date>
    <item>
      <title>extract errors from unstructured log file with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567548#M197799</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;I have several unstructured log file that need extract error messges with rex spl command.&lt;/P&gt;&lt;P&gt;1-what is the optimize way to extract error messages from those logs?&amp;nbsp;&lt;/P&gt;&lt;P&gt;2-group by error type (count by error type)&lt;/P&gt;&lt;P&gt;e.g: 19&lt;STRONG&gt;&amp;nbsp;Socket recv failed: Connection TimeOut&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;readData failed. Read&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; Invalid Length for facility number&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 17&amp;nbsp; &amp;nbsp;Duplicate - Stop Old Connection from IP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here is the sample:&lt;/P&gt;&lt;P&gt;00:03:00.895 APP module: Error: readData failed. Read [0] bytes instead of 4 for Len&lt;BR /&gt;00:03:00.895 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.12] Socket[405]&lt;BR /&gt;00:02:59.791 APP module1: T[0]R[0]L: ERROR: Invalid Length for facility number [000000000] !&lt;BR /&gt;00:02:55.193 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.112] Socket[705]&lt;BR /&gt;00:02:50.536 APP module: Error: Socket recv failed: Connection Reset by Peer[FIN Received] IP[192.168.13.1] Socket[114]&lt;BR /&gt;00:02:49.205 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.14] Socket[213]&lt;BR /&gt;00:02:46.317 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.51]&lt;BR /&gt;00:02:44.467 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.13] Socket[697]&lt;BR /&gt;00:02:43.468 APP module2: T[0]R[0]L: Error: Invalid TopUp No!&lt;BR /&gt;00:02:40.047 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.123]&lt;BR /&gt;00:02:34.424 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.13]&lt;BR /&gt;00:02:27.125 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.14]&lt;BR /&gt;00:02:25.840 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[506]&lt;BR /&gt;00:02:21.836 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:02:21.434 APP module: Error: Socket recv failed: Connection Reset by Peer[FIN Received] IP[192.168.1.1] Socket[291]&lt;BR /&gt;00:02:18.846 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[220]&lt;BR /&gt;00:02:16.861 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[67]&lt;BR /&gt;00:02:16.855 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:02:13.954 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:02:13.085 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[284]&lt;BR /&gt;00:02:08.332 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:01:59.926 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[824]&lt;BR /&gt;00:01:59.371 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[216]&lt;BR /&gt;00:01:57.313 APP module3: X[0000]T[000000]R[000]L: ERR logoutInternalErr200Or100Or100: Txn Was Not Found To Logout&lt;BR /&gt;00:01:55.881 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[104]&lt;BR /&gt;00:01:49.036 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[191]&lt;BR /&gt;00:01:48.551 APP module2: T[0]R[0]L: Error: DoAction can not find action. TypeId(-1) Expect(0)&lt;BR /&gt;00:01:48.266 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:01:46.272 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:01:44.942 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[37]&lt;BR /&gt;00:01:44.016 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[449]&lt;BR /&gt;00:01:43.305 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[345]&lt;BR /&gt;00:01:38.840 APP module: Error: Socket recv failed: Connection Reset by Peer[FIN Received] IP[195.165.249.51] Socket[655]&lt;BR /&gt;00:01:29.366 APP module2: T[0]R[0]L: ERROR: Invalid Length for facility number [000000000000] !&lt;BR /&gt;00:01:27.744 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:01:26.463 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:01:24.663 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[195]&lt;BR /&gt;00:01:21.249 APP module: Error: Socket recv failed: Connection Reset by Peer[FIN Received] IP[192.168.1.1] Socket[689]&lt;BR /&gt;00:01:19.752 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:01:15.978 APP module2: T[0]R[0]L: ERROR: Invalid Length for facility number [0000000000] !&lt;BR /&gt;00:01:08.395 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[372]&lt;BR /&gt;00:01:08.367 APP module2: T[0]R[0]L: Error: Can not find exe []&lt;BR /&gt;00:00:55.808 APP1 module4: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[313]&lt;BR /&gt;00:00:54.566 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:00:53.914 APP module: Error: Socket recv failed: Connection Reset by Peer[FIN Received] IP[192.168.1.1] Socket[248]&lt;BR /&gt;00:00:47.717 APP module: Error: Socket recv failed: Connection TimeOut IP[192.168.1.1] Socket[197]&lt;BR /&gt;00:00:43.755 APP2 module4: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:00:39.936 APP2 module4: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;BR /&gt;00:00:37.646 APP module: Error: Duplicate - Stop Old Connection from IP[192.168.1.1]&lt;/P&gt;&lt;P&gt;00:02:43.468 APP module4: T[0]R[0]L: Error: Invalid TopUp No!&lt;BR /&gt;00:03:00.895 APP module4: Error: readData failed. Read [0] bytes instead of 4 for Len&lt;BR /&gt;23:50:41.582 APP module4: X[00000]T[000000]R[0]L: oiu_fetch Error: I Cannot Found Any For This code:[0000000000]&lt;BR /&gt;00:00:03.164 APP module: T[0]R[0]L: Error: Module does not produce Pin Block. Call Supervisor. U[3357]&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 15:32:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567548#M197799</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2021-09-19T15:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: extract errors from unstructured log file with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567555#M197803</link>
      <description>&lt;P&gt;It would help to know what you've tried already, but perhaps this will help.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... | rex "Error: (?&amp;lt;Error&amp;gt;[^\[]+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 19 Sep 2021 17:08:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567555#M197803</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-09-19T17:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: extract errors from unstructured log file with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567557#M197805</link>
      <description>&lt;P&gt;Thank you for answer,&lt;/P&gt;&lt;P&gt;I try this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| rex "Error: (?&amp;lt;Error&amp;gt;[^\[]+)"&lt;/PRE&gt;&lt;P&gt;ouput is:&lt;/P&gt;&lt;P&gt;Socket recv failed: Connection TimeOut IP[192.168.1.2] Socket[406]&lt;BR /&gt;Socket recv failed: Connection TimeOut IP[192.168.1.4] Socket[397]&lt;BR /&gt;Socket recv failed: Connection TimeOut IP[192.168.90.20] Socket[474]&lt;/P&gt;&lt;P&gt;as you see consider them as seprate events, my goal here is to group by them like this:&lt;/P&gt;&lt;P&gt;excpected output:&lt;BR /&gt;Socket recv failed: Connection TimeOut (3 times)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;another example:&lt;/P&gt;&lt;P&gt;current output:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Invalid Length for facility number [000000000] !&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Invalid Length for facility number [112222222] !&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;excpected output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Invalid Length for facility number (2 times)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;UPDATE :&lt;/FONT&gt;&lt;/STRONG&gt; i try to use sed but it really slow&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;index="my-index" err*&amp;nbsp;&lt;BR /&gt;|rex "Error: (?&amp;lt;Errors&amp;gt;^\[]+)"&lt;BR /&gt;|rex field=Errors mode=sed "s/[[].*//g"&lt;BR /&gt;|top&amp;nbsp; Errors&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 20:01:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567557#M197805</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2021-09-19T20:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: extract errors from unstructured log file with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567559#M197807</link>
      <description>&lt;P&gt;In general - you don't merge events as such and count them... Unless you do an explicit search.&lt;/P&gt;&lt;P&gt;So you firstly need to parse the event to get the error type from each event and then you can try - for example - doing stats or eventstats on those error types.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 18:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567559#M197807</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-19T18:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: extract errors from unstructured log file with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567562#M197809</link>
      <description>&lt;P&gt;would you please write spl command with sample data that I post?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 20:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567562#M197809</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2021-09-19T20:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: extract errors from unstructured log file with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567564#M197810</link>
      <description>&lt;P&gt;Firstly, you extract the error type as per &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;'s&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;... | rex "Error: (?&amp;lt;Error&amp;gt;[^\[]+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, there are at least two ways of counting the consecutive events.&lt;/P&gt;&lt;P&gt;One - which is not mine, I nicked it off someone else's solution - is to do a trick with streamstats and reversing&lt;/P&gt;&lt;PRE&gt;| streamstats count as errcount by Error reset_on_change=t&lt;BR /&gt;| reverse&lt;BR /&gt;| streamstats count as auxcount by Error reset_on_change=t&lt;BR /&gt;| where auxcount=1&lt;BR /&gt;| reverse&lt;/PRE&gt;&lt;P&gt;To be honest - I didn't test it&lt;/P&gt;&lt;P&gt;Other option is to use streamstats as well but with autoregress&lt;/P&gt;&lt;PRE&gt;| streamstats count as Errcount by Error current=t reset_on_change=t &lt;BR /&gt;| autoregress Error as oldError&lt;BR /&gt;| streamstats count(eval(Error!=oldError)) as difcount &lt;BR /&gt;| stats max(Errcount) as Errcount values(Error) as Error by difcount&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;But that counts &lt;U&gt;consecutive&lt;/U&gt; event occurences. If you simply want a global aggregate, you just do&lt;/P&gt;&lt;PRE&gt;| stats count by Error&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 06:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-errors-from-unstructured-log-file-with-rex/m-p/567564#M197810</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-20T06:30:05Z</dc:date>
    </item>
  </channel>
</rss>

