<?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: iplocation: How to replace null or empty string City field with &amp;quot;Unknown&amp;quot;? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188461#M54300</link>
    <description>&lt;P&gt;Gerne! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Aug 2014 14:37:17 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-08-20T14:37:17Z</dc:date>
    <item>
      <title>iplocation: How to replace null or empty string City field with "Unknown"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188458#M54297</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;i have several search results where the City Field ist after IPLocation not filled up. i recognized it already that simply for such an IP there is no City Information available - only Country. &lt;/P&gt;

&lt;P&gt;In Splunk no values are shown as "blank" or whatever values - i like to convert them to "Unknown" in the report. i tried already fill null but it did not work. can someone help? maybe with eval City=if(City="")? &lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://answers.splunk.com//storage/Bildschirmfoto_2014-08-20_um_15.37.09.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Thx a lot&lt;BR /&gt;
Matthias&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2014 13:42:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188458#M54297</guid>
      <dc:creator>Matthias_BY</dc:creator>
      <dc:date>2014-08-20T13:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: iplocation: How to replace null or empty string City field with "Unknown"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188459#M54298</link>
      <description>&lt;P&gt;The mean thing here is that &lt;CODE&gt;City&lt;/CODE&gt; sometimes is null, sometimes it's the empty string. Apparently it's null only if there is no location info whatsoever, but the empty string if there is some location info but no city. Here's an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval clientip = "127.0.0.1 8.8.8.8" | makemv clientip | mvexpand clientip | iplocation clientip | eval null = if(isnull(City), "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For me it translates Google's public DNS into "somewhere in the US" with &lt;CODE&gt;City=""&lt;/CODE&gt;, and it doesn't know anything about localhost leaving &lt;CODE&gt;City=null&lt;/CODE&gt;. That's why your &lt;CODE&gt;fillnull&lt;/CODE&gt; fails, and short-hand functions such as &lt;CODE&gt;coalesce()&lt;/CODE&gt; would fail as well.&lt;/P&gt;

&lt;P&gt;To address both cases you could do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval City = if(isnull(City) OR City="", "Unknown", City)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Maybe move that to a macro and do the same for &lt;CODE&gt;Country&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You could also use this, but it's not a lot prettier than the &lt;CODE&gt;if()&lt;/CODE&gt; expression above.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | fillnull value="Unknown" City | replace "" with "Unknown" in City
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Aug 2014 13:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188459#M54298</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-08-20T13:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: iplocation: How to replace null or empty string City field with "Unknown"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188460#M54299</link>
      <description>&lt;P&gt;perfect &lt;/P&gt;

&lt;P&gt;eval City = if(isnull(City) OR City="", "Unknown", City)&lt;/P&gt;

&lt;P&gt;is doing it! thanks for your nearly real time support and solution!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2014 14:29:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188460#M54299</guid>
      <dc:creator>Matthias_BY</dc:creator>
      <dc:date>2014-08-20T14:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: iplocation: How to replace null or empty string City field with "Unknown"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188461#M54300</link>
      <description>&lt;P&gt;Gerne! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2014 14:37:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/iplocation-How-to-replace-null-or-empty-string-City-field-with/m-p/188461#M54300</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-08-20T14:37:17Z</dc:date>
    </item>
  </channel>
</rss>

