<?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 conditional field choice in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39137#M8913</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have log files which have both IP numbers (field IP) and corresponding names (field DNSNAME).&lt;BR /&gt;
I would like to chart (a distribution for instance) based on the names but unfortunately some of them are not available (the value of the field DNSNAME="N/A"). In that case I need to fallback to the IP.&lt;/P&gt;

&lt;P&gt;If I always had names I would do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count by DNSNAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to construct something along the lines of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count [ if DNSNAME != "N/A" then "by DNSNAME" else "by IP" ) ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was looking around the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;eval &amp;amp; co. functions&lt;/A&gt; but the "if" mentioned there seems to work on a given field only (while I want to modify the search itself based on conditions)&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 22 Dec 2011 10:46:56 GMT</pubDate>
    <dc:creator>wsw70</dc:creator>
    <dc:date>2011-12-22T10:46:56Z</dc:date>
    <item>
      <title>conditional field choice</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39137#M8913</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have log files which have both IP numbers (field IP) and corresponding names (field DNSNAME).&lt;BR /&gt;
I would like to chart (a distribution for instance) based on the names but unfortunately some of them are not available (the value of the field DNSNAME="N/A"). In that case I need to fallback to the IP.&lt;/P&gt;

&lt;P&gt;If I always had names I would do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count by DNSNAME
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to construct something along the lines of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count [ if DNSNAME != "N/A" then "by DNSNAME" else "by IP" ) ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was looking around the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;eval &amp;amp; co. functions&lt;/A&gt; but the "if" mentioned there seems to work on a given field only (while I want to modify the search itself based on conditions)&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2011 10:46:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39137#M8913</guid>
      <dc:creator>wsw70</dc:creator>
      <dc:date>2011-12-22T10:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: conditional field choice</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39138#M8914</link>
      <description>&lt;P&gt;... | eval newfield=if(DNSNAME=="N/A",IP,DNSNAME) | stats count by newfield&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2011 11:15:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39138#M8914</guid>
      <dc:creator>imrago</dc:creator>
      <dc:date>2011-12-22T11:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: conditional field choice</title>
      <link>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39139#M8915</link>
      <description>&lt;P&gt;Aahhh - I was looking at the "if" (as I mentioned) but somehow it did not ring a bell.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2011 11:33:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/conditional-field-choice/m-p/39139#M8915</guid>
      <dc:creator>wsw70</dc:creator>
      <dc:date>2011-12-22T11:33:03Z</dc:date>
    </item>
  </channel>
</rss>

