<?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: Add results depending on different fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228797#M67702</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Thanks for you help everyone, i didn't try your queries because i start looking on another way to do the job : &lt;BR /&gt;
I had trouble at the beginning with my logs (they were very different) so i create multiple field to match them all and tried to coalesce them all.&lt;/P&gt;

&lt;P&gt;But finally i found a way to create better field and make my errorType &amp;amp; errorType2 match in one field !&lt;BR /&gt;
I had to work a little bit on the ReGex and delete the old field i create so i can't try your queries ! &lt;/P&gt;

&lt;P&gt;I apologize for the loss of time and thanks you all for your help,&lt;BR /&gt;
Maybe this queries will be useful for someone else !&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2016 07:28:39 GMT</pubDate>
    <dc:creator>BaptVe</dc:creator>
    <dc:date>2016-05-09T07:28:39Z</dc:date>
    <item>
      <title>Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228790#M67695</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm looking to add the results of a count from different fields in one for a table: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | stats count by errorType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I run this search, I only get the stats count for the errorType, but I'd like to add the count for errorType2 and NPE and make a table with all of these results.&lt;/P&gt;

&lt;P&gt;The table should looks like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name of Error          Count

navigation.Error       7896  
navigation.ErrorMenu   1780  
operation.Error        177  
validation.Error       96  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where, for example, navigation comes from errorType, operation comes errorType2, ...&lt;/P&gt;

&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 09:24:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228790#M67695</guid>
      <dc:creator>BaptVe</dc:creator>
      <dc:date>2016-05-02T09:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228791#M67696</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | stats count by errorType, errorType2, NPE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 09:37:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228791#M67696</guid>
      <dc:creator>NOUMSSI</dc:creator>
      <dc:date>2016-05-02T09:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228792#M67697</link>
      <description>&lt;P&gt;Or this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | rename errorType2 AS errorType NPE AS errorType | stats count by errorType | rename errorType AS "Name of Error"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 09:51:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228792#M67697</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-02T09:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228793#M67698</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | rename errorType2 AS errorType | rename NPE AS errorType | stats count by errorType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;==&amp;gt; Only keep the results of NPE.&lt;/P&gt;

&lt;P&gt;And others solution you give me didnt work : &lt;BR /&gt;
They only keep a part of the results !&lt;/P&gt;

&lt;P&gt;Perhpas should i search with append / join / appendcols / ... &lt;/P&gt;

&lt;P&gt;Still searching for an answer, thanks for your help !&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 10:28:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228793#M67698</guid>
      <dc:creator>BaptVe</dc:creator>
      <dc:date>2016-05-02T10:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228794#M67699</link>
      <description>&lt;P&gt;If mutually-exclusive, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | eval errorType = case(
   isnotnull(errorType), "errorType",
   isnotnull(errorType2), "errorType2",
   isnotnull(NPE), "NPE",
   true(), "ERROR!")
| stats count AS "Name of Error" BY errorType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Otherwise, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | fillnull value="NULL" errorType errorType2 NPE | stats count AS "Name of Error" BY errorType errorType2 NPE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The other answers skip &lt;CODE&gt;fillnull&lt;/CODE&gt; and without this, you will drop events (try it and you will see).&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 13:09:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228794#M67699</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-02T13:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228795#M67700</link>
      <description>&lt;P&gt;Another simple option would be to use coalesce command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | eval errorType=coalesce(errorType, errorType2, NPE)| stats count by errorType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 14:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228795#M67700</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-02T14:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228796#M67701</link>
      <description>&lt;P&gt;Actually, the first option should be this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XXXX sourcetype="XXXXXX" type=ERROR errorType="*" OR errorType2="*" OR NPE="*" | eval errorType=coalesce(errorType, errorType2, NPE) | stats count AS "Name of Error" BY errorType
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2016 14:25:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228796#M67701</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-02T14:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add results depending on different fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228797#M67702</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Thanks for you help everyone, i didn't try your queries because i start looking on another way to do the job : &lt;BR /&gt;
I had trouble at the beginning with my logs (they were very different) so i create multiple field to match them all and tried to coalesce them all.&lt;/P&gt;

&lt;P&gt;But finally i found a way to create better field and make my errorType &amp;amp; errorType2 match in one field !&lt;BR /&gt;
I had to work a little bit on the ReGex and delete the old field i create so i can't try your queries ! &lt;/P&gt;

&lt;P&gt;I apologize for the loss of time and thanks you all for your help,&lt;BR /&gt;
Maybe this queries will be useful for someone else !&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2016 07:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-results-depending-on-different-fields/m-p/228797#M67702</guid>
      <dc:creator>BaptVe</dc:creator>
      <dc:date>2016-05-09T07:28:39Z</dc:date>
    </item>
  </channel>
</rss>

