<?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 based on 2 fields in splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616918#M214400</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;yes you can use more than one field in the stats command, so you could use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;BASE_SEARCH
| rex field= _raw "Exception: (?&amp;lt;Exception&amp;gt;[^\.\&amp;lt;]+)"
| stats count as Count by TYPE "Exception"&lt;/LI-CODE&gt;&lt;P&gt;You have to put attention only to one thing: using two fields in the stats command you take only the events with both the fields, in other words, if one event has the TYPE field but not the TYPE field or opposite, the event isn't counted.&lt;/P&gt;&lt;P&gt;So you have to analyze your data to be sure that all the relevant events have both the fields.&lt;/P&gt;&lt;P&gt;If one of them could be missing, use fillnull command to assign a value (e.g. "-") when the value is missing.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 06:32:22 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-10-13T06:32:22Z</dc:date>
    <item>
      <title>Grouping the messages based on 2 fields in splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616915#M214398</link>
      <description>&lt;P&gt;I have&amp;nbsp;below&amp;nbsp;events/messages in my search result. There are 2 fields &lt;STRONG&gt;stack_trace&lt;/STRONG&gt; and &lt;STRONG&gt;TYPE&lt;/STRONG&gt; like below. I want to &lt;STRONG&gt;group the events and count&lt;/STRONG&gt; them as shown below based on a particular text from &lt;STRONG&gt;stack_trace&amp;nbsp;&lt;/STRONG&gt;and &lt;STRONG&gt;TYPE&lt;/STRONG&gt; field as below. Is it possible to group the messages based on 2 fields (&lt;STRONG&gt;TYPE,stack_trace&lt;/STRONG&gt;)? I am using below query but I am stuck as to how to group by 2 fields.&amp;nbsp;&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
TYPE: ABCD
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;&lt;STRONG&gt;Event 2&lt;/STRONG&gt;&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;{
TYPE: XYZ
stack_trace : com.abc.xyz.package.ExceptionName: 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;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;LI-CODE lang="markup"&gt;TYPE   Exception  Count
ABCD   Missing A   3
ABCD   Missing B   4
XYZ    Missing A   6
XYZ    Missing B   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;&lt;STRONG&gt;Query I am using but incomplete&amp;nbsp;&lt;BR /&gt;&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;LI-CODE lang="markup"&gt;BASE_SEARCH
| rex field= _raw "Exception: (?&amp;lt;Exception&amp;gt;[^\.\&amp;lt;]+)"
| stats count as Count by "Exception"&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;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Actual Output&lt;/STRONG&gt;&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   6&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;</description>
      <pubDate>Thu, 13 Oct 2022 14:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616915#M214398</guid>
      <dc:creator>ghostrider</dc:creator>
      <dc:date>2022-10-13T14:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages based on 2 fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616918#M214400</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;yes you can use more than one field in the stats command, so you could use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;BASE_SEARCH
| rex field= _raw "Exception: (?&amp;lt;Exception&amp;gt;[^\.\&amp;lt;]+)"
| stats count as Count by TYPE "Exception"&lt;/LI-CODE&gt;&lt;P&gt;You have to put attention only to one thing: using two fields in the stats command you take only the events with both the fields, in other words, if one event has the TYPE field but not the TYPE field or opposite, the event isn't counted.&lt;/P&gt;&lt;P&gt;So you have to analyze your data to be sure that all the relevant events have both the fields.&lt;/P&gt;&lt;P&gt;If one of them could be missing, use fillnull command to assign a value (e.g. "-") when the value is missing.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 06:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616918#M214400</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-13T06:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages based on 2 fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616920#M214401</link>
      <description>&lt;P&gt;Thanks!! I just ran the query, and it looks like it shows "null" in the final output when the TYPE fields is not present but stack_trace is present. Is it possible to replace the null with some string like "N/A" so that it looks cleaner.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 06:42:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616920#M214401</guid>
      <dc:creator>ghostrider</dc:creator>
      <dc:date>2022-10-13T06:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping the messages based on 2 fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616921#M214402</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;as I said, you can use the fillnull command (&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fillnull" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fillnull&lt;/A&gt;)&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;BASE_SEARCH
| rex field= _raw "Exception: (?&amp;lt;Exception&amp;gt;[^\.\&amp;lt;]+)"
| fillnull value="N/A" TYPE
| stats count as Count by TYPE "Exception"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 06:47:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-the-messages-based-on-2-fields-in-splunk/m-p/616921#M214402</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-13T06:47:44Z</dc:date>
    </item>
  </channel>
</rss>

