<?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 location to IPs found in lookup or add unknown if missing in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500558#M139362</link>
    <description>&lt;P&gt;This should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup hostnames.csv
| fields hostname ip
| eval ip = split(ip,"|")
| mvexpand ip
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Feb 2020 14:39:55 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-02-04T14:39:55Z</dc:date>
    <item>
      <title>Add location to IPs found in lookup or add unknown if missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500557#M139361</link>
      <description>&lt;P&gt;So I have a string of IPs that are input and trying to figure out how to add the location on them which are stated in a csv.&lt;/P&gt;

&lt;P&gt;the input string varies and could looks like for example like this for each host:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;ip=1.1.1.1&lt;BR /&gt;
ip=1.1.1.2|1.2.3.4&lt;BR /&gt;
ip=1.1.1.5|1.4.4.6|1.2.4.6&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;meaning each could either have one ip or more, some of these ips are in the location csv some not&lt;/P&gt;

&lt;P&gt;so my table from the begining have these values and other empty fields that will be filled later,&lt;BR /&gt;
*&lt;EM&gt;hostname, ip, location, owner *&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;The ones with information atm are hostname, ip, trying to add location with below, then add the other info after this code as its dependad on it:&lt;/P&gt;

&lt;P&gt;**&lt;BR /&gt;
|inputlookup hostnames.csv &lt;BR /&gt;
|table hostname ip&lt;BR /&gt;
| eval ip = split(ip,"|") &lt;BR /&gt;
| eval numIPs = mvcount(ip)&lt;BR /&gt;
| eval iVal = mvrange(0,numIPs,1)&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
...missing...code...&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
| lookup location_info ip_prefix AS ip OUTPUT location&lt;BR /&gt;
|table hostname ip location owner&lt;BR /&gt;
| eval location = if(location="NONE" OR location="Unknown", "Unkown", location)&lt;BR /&gt;
| streamstats count&lt;BR /&gt;
| mvexpand location&lt;BR /&gt;
| dedup count location&lt;BR /&gt;
| mvcombine location&lt;BR /&gt;
| fields - count&lt;BR /&gt;
| lookup owners.csv location OUTPUT owner&lt;BR /&gt;
| table hostname ip location owner**&lt;/P&gt;

&lt;P&gt;when there is 1 ip in the string, this works, but if there is more I have no clue at all how to solve it. I've tried mvexpand, mvcombine, foreach, with no luck or I'm using them wrongly.&lt;/P&gt;

&lt;P&gt;can someone share some insight in this?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500557#M139361</guid>
      <dc:creator>khaghsam</dc:creator>
      <dc:date>2020-09-30T04:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add location to IPs found in lookup or add unknown if missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500558#M139362</link>
      <description>&lt;P&gt;This should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup hostnames.csv
| fields hostname ip
| eval ip = split(ip,"|")
| mvexpand ip
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2020 14:39:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500558#M139362</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-02-04T14:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Add location to IPs found in lookup or add unknown if missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500559#M139363</link>
      <description>&lt;P&gt;| inputlookup hostnames.csv&lt;BR /&gt;
 | fields hostname ip&lt;BR /&gt;
 | eval ip = split(ip,"|")&lt;BR /&gt;
 | mvexpand ip&lt;BR /&gt;
 | lookup location_info ip_prefix AS ip OUTPUT location&lt;/P&gt;

&lt;P&gt;Works but the combine part becomes an issue then.&lt;BR /&gt;
So the output of above becomes:&lt;/P&gt;

&lt;P&gt;hostname1   1.1.1.1   location1&lt;BR /&gt;&lt;BR /&gt;
hostname1   2.2.2.2   unknown&lt;BR /&gt;
hostname1   3.3.3.3   location2&lt;/P&gt;

&lt;P&gt;depending on how many local/virtual ips the host has.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:00:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500559#M139363</guid>
      <dc:creator>khaghsam</dc:creator>
      <dc:date>2020-09-30T04:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Add location to IPs found in lookup or add unknown if missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500560#M139364</link>
      <description>&lt;P&gt;What is the desired output?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 13:45:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500560#M139364</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-02-05T13:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add location to IPs found in lookup or add unknown if missing</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500561#M139365</link>
      <description>&lt;P&gt;Something like this:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://drive.google.com/open?id=1D5zo70owEnr5teSrWnkfSEU1uZBv6hdf" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://drive.google.com/open?id=1D5zo70owEnr5teSrWnkfSEU1uZBv6hdf"&gt;https://drive.google.com/open?id=1D5zo70owEnr5teSrWnkfSEU1uZBv6hdf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Now the location field's duplicates need to be removed in case there are, same with owner. (so I guess  only unique values)&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 13:58:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-location-to-IPs-found-in-lookup-or-add-unknown-if-missing/m-p/500561#M139365</guid>
      <dc:creator>khaghsam</dc:creator>
      <dc:date>2020-02-05T13:58:41Z</dc:date>
    </item>
  </channel>
</rss>

