<?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: Grouping the messages by Exception message present in stack_trace field of a json event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616912#M214397</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249848"&gt;@ghostrider&lt;/a&gt;&amp;nbsp;have you tried just using&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 field=stack_trace "^(?&amp;lt;classname&amp;gt;.+)\.\w+: (?&amp;lt;exceptiontext&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;Using your sample data, output is like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;classname&lt;/TD&gt;&lt;TD&gt;exceptiontext&lt;/TD&gt;&lt;TD&gt;stack_trace&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;com.abc.xyz.package&lt;/TD&gt;&lt;TD&gt;Missing A.&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;com.abc.xyz.package.ExceptionName: Missing A.&lt;BR /&gt;at random.package.w(DummyFile1:45)&lt;BR /&gt;at random.package.x(DummyFile2:64)&lt;BR /&gt;at random.package.y(DummyFile3:79)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;By default, rex stops at the first line.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 05:45:46 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-10-13T05:45:46Z</dc:date>
    <item>
      <title>How to group the messages by exception message present in stack_trace field of a json event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616653#M214315</link>
      <description>&lt;P&gt;I have &lt;STRONG&gt;json&lt;/STRONG&gt; events/messages in my search result. There is a field or property called "stack_trace" in the json like below. I want to group the events and count them as shown below based on the Exception Reason or message. The problem is traces are multi lined and hence below query that I am using is, it seems not able to extract the exact exception message. Is there a way to achieve the expected output?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Event&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&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;LI-CODE lang="markup"&gt;{

MESSAGE : Failed to send 
stack_trace : com.abc.xyz.package.ExceptionName: Missing A.
at random.package.w(DummyFile1:45)
at random.package.x(DummyFile2:64)
at random.package.y(DummyFile3:79)



}
&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Query I am using&lt;/STRONG&gt;&lt;/P&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;LI-CODE lang="markup"&gt;MY_SEARCH | rex field=stack_trace "(?&amp;lt;exceptionclass&amp;gt;\w+): (?&amp;lt;exceptiontext&amp;gt;\w+)."
| stats count as Count by "exceptiontext"&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Expected Output&lt;/STRONG&gt;&lt;/P&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;LI-CODE lang="markup"&gt;Exception     Count

Missing A     3
Missing B     4
Missing C     1&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 13:59:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616653#M214315</guid>
      <dc:creator>ghostrider</dc:creator>
      <dc:date>2022-10-11T13:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616657#M214316</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249848"&gt;@ghostrider&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you have to review your regex, please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MY_SEARCH 
| rex field=stack_trace "ExceptionName: (?&amp;lt;exceptiontext&amp;gt;[^\.]+)"
| stats count as Count by "exceptiontext"&lt;/LI-CODE&gt;&lt;P&gt;that you can test at&amp;nbsp;&lt;A href="https://regex101.com/r/OAJ4Iw/1" target="_blank"&gt;https://regex101.com/r/OAJ4Iw/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 11:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616657#M214316</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-11T11:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616674#M214319</link>
      <description>&lt;P&gt;Thank you!!. Issue is "ExceptionName" this is not same for all the exceptions. Is there a way to completely ignore this field and just get the exception message?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 13:10:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616674#M214319</guid>
      <dc:creator>ghostrider</dc:creator>
      <dc:date>2022-10-11T13:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616677#M214321</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249848"&gt;@ghostrider&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;sorry but I don't understand you need: maybe you should categorize the messages to find all the regexes to extract the message.&lt;/P&gt;&lt;P&gt;If you could share a sample of the other kind of logs I could try to find a regex.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 13:29:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616677#M214321</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-11T13:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616688#M214322</link>
      <description>&lt;P&gt;Ok. So I am trying to say is currently we can have different exceptionnames in the events like below. In this case your query will not work since you are matching the &lt;STRONG&gt;ExceptionName&lt;/STRONG&gt; literally. So is there any way to ignore the entire text till ":" and just extract the "Missing A" etc part?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Event 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{

MESSAGE : Failed to send 
stack_trace : com.abc.xyz.package.ExceptionName: Missing A.
at random.package.w(DummyFile1:45)
at random.package.x(DummyFile2:64)
at random.package.y(DummyFile3:79)
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Event 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{

MESSAGE : Failed to send 
stack_trace : com.abc.xyz.package.OtherExceptionName: Missing B.
at random.package.w(DummyFile1:45)
at random.package.x(DummyFile2:64)
at random.package.y(DummyFile3:79)
}&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;LI-CODE lang="markup"&gt;{

MESSAGE : Failed to send 
stack_trace : com.abc.xyz.package.SomeOtherExceptionName: Missing C.
at random.package.w(DummyFile1:45)
at random.package.x(DummyFile2:64)
at random.package.y(DummyFile3:79)
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Event 3&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 14:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616688#M214322</guid>
      <dc:creator>ghostrider</dc:creator>
      <dc:date>2022-10-11T14:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616696#M214326</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249848"&gt;@ghostrider&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you have to identify the string to capture.&lt;/P&gt;&lt;P&gt;Viewing your sample with the same regex, you can take all the messages as you can see at&amp;nbsp;&lt;A href="https://regex101.com/r/OAJ4Iw/2" target="_blank"&gt;https://regex101.com/r/OAJ4Iw/2&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It's not relevant if before ExceptionName there something else, it's important that there's "ExceptionName: ".&lt;/P&gt;&lt;P&gt;If you haven't this word it's difficoult because you have many colons in your logs so it isn't sufficient to identify the string to capture.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 14:27:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616696#M214326</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-11T14:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616776#M214365</link>
      <description>&lt;P&gt;Yes thanks your query is perfect. Just was curious is there any way to include in the regex one condition to extract the string till the current line only and not go to next line? Currently you are having "." as the limiting char till which we can read the string&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 06:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616776#M214365</guid>
      <dc:creator>ghostrider</dc:creator>
      <dc:date>2022-10-12T06:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616789#M214369</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249848"&gt;@ghostrider&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;sorry but I don't understand, could you share and highlit what you want to extract?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 09:30:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616789#M214369</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-12T09:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616795#M214373</link>
      <description>&lt;P&gt;You have to anchor your regex somewhere &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Otherwise the regex processor will not know where to start or stop. That's why the constant part of ExceptionName. Regex is a simple tool which matches strings to patterns, it doesn't understand "business logic" and cannot guess what you want &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So you have to either anchor it with a specific constant term(s) or restrict it to a special pattern. There's no way around it. You could try extracting, for example, a second line from each matching event, but then you'd have to be sure it's always on the second line.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 09:57:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616795#M214373</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-10-12T09:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages by Exception message present in stack_trace field of a json event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616912#M214397</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249848"&gt;@ghostrider&lt;/a&gt;&amp;nbsp;have you tried just using&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 field=stack_trace "^(?&amp;lt;classname&amp;gt;.+)\.\w+: (?&amp;lt;exceptiontext&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;Using your sample data, output is like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;classname&lt;/TD&gt;&lt;TD&gt;exceptiontext&lt;/TD&gt;&lt;TD&gt;stack_trace&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;com.abc.xyz.package&lt;/TD&gt;&lt;TD&gt;Missing A.&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;com.abc.xyz.package.ExceptionName: Missing A.&lt;BR /&gt;at random.package.w(DummyFile1:45)&lt;BR /&gt;at random.package.x(DummyFile2:64)&lt;BR /&gt;at random.package.y(DummyFile3:79)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;By default, rex stops at the first line.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 05:45:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-the-messages-by-exception-message-present-in-stack/m-p/616912#M214397</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-10-13T05:45:46Z</dc:date>
    </item>
  </channel>
</rss>

