<?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 use Eval to find all matching errors and display result count by error in Security</title>
    <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239561#M14872</link>
    <description>&lt;P&gt;Your should use rex, may be along these lines to extract those errors into a field and then report on it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ndex=test "common_error" | rex field=_raw "failed with an error (?&amp;lt;error_message&amp;gt;.*)" | stats count by error_message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your eval fails as the syntax is incorrect . Also, eval is used to create a field from existing fields or static values, it can't extract field from raw data.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;BR /&gt;
Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test "common_error"  | eval test_msg=case(match(_raw,"known error1"),"known error1",match(_raw,"known error2"),"known error2",match(_raw,"known error3"),"known error3",......., 1=1,"New Error") | stats count by test_msg
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 10 Mar 2016 19:39:37 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-03-10T19:39:37Z</dc:date>
    <item>
      <title>How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239555#M14866</link>
      <description>&lt;P&gt;I tried below, but getting an error. It works if i limit the error to single message error1.&lt;/P&gt;

&lt;P&gt;Here i dont have filed for error, so defining new variable test_msg and trying to match for any of the 3 messages.. &lt;/P&gt;

&lt;P&gt;index=test "common_error" | eval test_msg="error1" "error2" "error3" | stats count by test_msg&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239555#M14866</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2020-09-29T09:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239556#M14867</link>
      <description>&lt;P&gt;.................................| eval test_msg="error*" | stats count by test_msg&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:01:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239556#M14867</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2020-09-29T09:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239557#M14868</link>
      <description>&lt;P&gt;it is better to use rex command to extract test_msg field whih contain all the error .&lt;BR /&gt;
let me see your events &lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 07:52:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239557#M14868</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2016-03-10T07:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239558#M14869</link>
      <description>&lt;P&gt;What error are you getting?&lt;BR /&gt;
It would help to see some sample events that you are trying to match.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 14:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239558#M14869</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-03-10T14:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239559#M14870</link>
      <description>&lt;P&gt;Events looks like below. I want to display report/Dash borad with all these erro1-4 in a report or dashborad and any new error should be displayed as new.. For now i am looking for count of all known errors.&lt;/P&gt;

&lt;P&gt;16:30:24,115|Service:call common_error failed with  an error error1&lt;/P&gt;

&lt;P&gt;16:33:01,115|Service:call common_error failed with  an error error2&lt;/P&gt;

&lt;P&gt;13:30:08,115|Service:call common_error failed with  an error error3&lt;/P&gt;

&lt;P&gt;23:30:05,115|Service:call common_error failed with  an error error4&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 14:48:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239559#M14870</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2016-03-10T14:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239560#M14871</link>
      <description>&lt;P&gt;The error i am getting is &lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The expression is malformed.&lt;BR /&gt;
The search job has failed due to an error. You may be able view the job in the Job Inspector.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 18:44:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239560#M14871</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2016-03-10T18:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239561#M14872</link>
      <description>&lt;P&gt;Your should use rex, may be along these lines to extract those errors into a field and then report on it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ndex=test "common_error" | rex field=_raw "failed with an error (?&amp;lt;error_message&amp;gt;.*)" | stats count by error_message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your eval fails as the syntax is incorrect . Also, eval is used to create a field from existing fields or static values, it can't extract field from raw data.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;BR /&gt;
Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test "common_error"  | eval test_msg=case(match(_raw,"known error1"),"known error1",match(_raw,"known error2"),"known error2",match(_raw,"known error3"),"known error3",......., 1=1,"New Error") | stats count by test_msg
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Mar 2016 19:39:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239561#M14872</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-10T19:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239562#M14873</link>
      <description>&lt;P&gt;Here,   error_message needs to be replaced with "error1"/"error2"/"error3" ? in that case where we are defining error_message which is used for ordering.&lt;/P&gt;

&lt;P&gt;Basically, all my errors are part of raw which is not mapped to any field.&lt;/P&gt;

&lt;P&gt;How the query will look like for the following scenario?&lt;/P&gt;

&lt;P&gt;OrderserviceImpl Exception: Workflow Exception ---&amp;gt; FileNotFoundException: ERR_234: File not found for cust_abc&lt;/P&gt;

&lt;P&gt;OrderserviceImpl Exception: Workflow Exception ---&amp;gt; CustomerNotFoundException: ERR_453: Customer not found for cust_123&lt;/P&gt;

&lt;P&gt;OrderserviceImpl Exception: Workflow Exception ---&amp;gt; InvalidInputException: ERR_443: Invalid Input&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;In the above error, "OrderserviceImpl" is common for all errors and remaining like "FileNotFoundException: ERR_234" varies.. i want to display count for each error message.&lt;/P&gt;

&lt;P&gt;Thanks for helping with my questions.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:02:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239562#M14873</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2020-09-29T09:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239563#M14874</link>
      <description>&lt;P&gt;I tried below, which found some X number of events but below it displayed "no results found", so stats is not working?&lt;/P&gt;

&lt;P&gt;index=test "common_error" | rex field=_raw "error1 (?.*)" | stats count by error_message&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:02:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239563#M14874</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2020-09-29T09:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239564#M14875</link>
      <description>&lt;P&gt;Check if the field extraction is working fine or not. Run this and see if you get values under error_message field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test "common_error" | table _raw | rex field=_raw "error1 (?&amp;lt;error_message&amp;gt;.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Mar 2016 21:57:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239564#M14875</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-10T21:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239565#M14876</link>
      <description>&lt;P&gt;No, error_message is blank. Only _raw displays text of stack trace where error1 is part of huge stack trace.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 22:05:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239565#M14876</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2016-03-10T22:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239566#M14877</link>
      <description>&lt;P&gt;Did you try the updated answers?? &lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 22:15:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239566#M14877</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-10T22:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval to find all matching errors and display result count by error</title>
      <link>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239567#M14878</link>
      <description>&lt;P&gt;This worked like charm..thanks a lot for helping with this.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 01:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-use-Eval-to-find-all-matching-errors-and-display-result/m-p/239567#M14878</guid>
      <dc:creator>akonduru</dc:creator>
      <dc:date>2016-03-11T01:51:02Z</dc:date>
    </item>
  </channel>
</rss>

