<?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: multiple input fields for csv lookup in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362163#M92891</link>
    <description>&lt;P&gt;Don't forget to &lt;CODE&gt;up-vote&lt;/CODE&gt; and/or click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jun 2017 13:09:42 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-06-23T13:09:42Z</dc:date>
    <item>
      <title>multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362158#M92886</link>
      <description>&lt;P&gt;if I have a src_ip in a juniper sourcetype and want to match it to a HOST in the csv file and also to a SERVER in the same csv file, is there a way to do that?  Here is what I have so far&lt;/P&gt;

&lt;P&gt;|lookup data_file HOST as src_ip OR SERVER as src_ip Output src_ip destzone srczone &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:33:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362158#M92886</guid>
      <dc:creator>dxw350</dc:creator>
      <dc:date>2020-09-29T14:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362159#M92887</link>
      <description>&lt;P&gt;Do it twice, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|lookup data_file HOST as src_ip Output src_ip destzone srczone
|lookup data_file SERVER as src_ip Output src_ip destzone srczone
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whichever one works last, wins.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 20:10:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362159#M92887</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-22T20:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362160#M92888</link>
      <description>&lt;P&gt;Thanks for the reply.  I didn't understand what you meant by "which ever one works last, wins".  I need both sets of input in the results as separate src-ip rows. Also, it seems this is doubling the search processsing.  Is there a conditional " OR" that can be used as an input portion the the |lookup????&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 22:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362160#M92888</guid>
      <dc:creator>dxw350</dc:creator>
      <dc:date>2017-06-22T22:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362161#M92889</link>
      <description>&lt;P&gt;If you need "both sets" then you do not need "OR", you need "AND".  My solution assumes that EITHER &lt;CODE&gt;HOST&lt;/CODE&gt; OR &lt;CODE&gt;SERVER&lt;/CODE&gt; will match.  The comment "whichever matches last wins" means that in the odd case where BOTH match, whichever one matches last will overwrite the existing values (from the previous match).  You can control "which one wins" either by swapping the order or by swapping &lt;CODE&gt;OUTPUTNEW&lt;/CODE&gt; for &lt;CODE&gt;OUTPUT&lt;/CODE&gt; because the difference between &lt;CODE&gt;OUTPUT&lt;/CODE&gt; and &lt;CODE&gt;OUTPUTNEW&lt;/CODE&gt; is if the output field already exists in your event, &lt;CODE&gt;OUTPUT&lt;/CODE&gt; will overwrite it and &lt;CODE&gt;OUTPUTNEW&lt;/CODE&gt; won't.&lt;/P&gt;

&lt;P&gt;If you really need AND and you need multivalued output fields, then you can do that like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup data_file HOST as src_ip Output src_ip destzone srczone
| lookup data_file SERVER as src_ip Output src_ip2 destzone2 srczone2
| eval src_ip=case(isnull(src_ip), src_ip2,
                   isnull(src_ip 2), src_ip,
                   true(), src_ip . "," src_ip2)
| eval src_ip2=null()
| makemv delim="," src_ip
| eval destzone=case(isnull(destzone), destzone2,
                     isnull(destzone2), destzone,
                     true(), destzone . "," destzone2)
| eval destzone2=null()
| makemv delim="," destzone
| eval srczone=case(isnull(srczone), srczone2,
                    isnull(srczone2), srczone,
                    true(), srczone. "," srczone2)
| eval srczone2=null()
| makemv delim="," srczone
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2017 08:29:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362161#M92889</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-23T08:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362162#M92890</link>
      <description>&lt;P&gt;This is a great explanation.  Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 12:21:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362162#M92890</guid>
      <dc:creator>dxw350</dc:creator>
      <dc:date>2017-06-23T12:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362163#M92891</link>
      <description>&lt;P&gt;Don't forget to &lt;CODE&gt;up-vote&lt;/CODE&gt; and/or click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 13:09:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362163#M92891</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-23T13:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362164#M92892</link>
      <description>&lt;P&gt;Thanks for all your help.  I tried to give you points, but don't have any yet.  I also tried your code and I guess I wasn't too clear on what I exactly needed, although we are close.  MY ISSUE:  There are always entries for both Host and Server, but if the Server entry is not listed as a separate row in the HOST column I need to add it as a reciprocal row.  Is there a way to do that with |outputnew  ?&lt;BR /&gt;
Example:&lt;BR /&gt;
HOST                  SERVER&lt;BR /&gt;
192.168..1.1        192.168.2.10&lt;BR /&gt;
192.168.2.10        192.168.1.1    This pair is good&lt;/P&gt;

&lt;P&gt;192.168.1.3         192.168.2.11&lt;BR /&gt;
Missing   reciprocal                     This row needs the reverse&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 18:04:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362164#M92892</guid>
      <dc:creator>dxw350</dc:creator>
      <dc:date>2017-06-23T18:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362165#M92893</link>
      <description>&lt;P&gt;It costs you no Karma to &lt;CODE&gt;Up-Vote&lt;/CODE&gt; or &lt;CODE&gt;Accept&lt;/CODE&gt; an answer to your question.  We all try to help the newbies get around and earn Karma (you get points for &lt;CODE&gt;Accept&lt;/CODE&gt;, you don't lose them).  Watch for my new answer in a bit...&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 18:20:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362165#M92893</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-23T18:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362166#M92894</link>
      <description>&lt;P&gt;Yes i accepted what is up-vote????  Also with respect to my issue I think that another reason the reciprocal inputnew lookup is not being populated is because it is not part of the same application dropdown list that  I used to filter. (Is there a way to include reciprocL nex t row entry eventhough it is not part of the same dropdown group&lt;/P&gt;

&lt;P&gt;For completion example&lt;/P&gt;

&lt;P&gt;Host                   Server                 dest_zone       Appl&lt;BR /&gt;
192.168.1.1      192.168.10.11        dmz                Word&lt;BR /&gt;
192.168.10.11.  192.168.1.1           Trust.              Word&lt;BR /&gt;
     (This pair was good)&lt;/P&gt;

&lt;P&gt;192.168.1.2        192.168.10.12       Dmz.              Word&lt;BR /&gt;
But.  192.168.10.12.  Not part of word app yet still want the pair as below (the below is missing)&lt;BR /&gt;
192.168.10.12.   192.168.1.2.          Trust.             Excel&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 21:43:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362166#M92894</guid>
      <dc:creator>dxw350</dc:creator>
      <dc:date>2017-06-23T21:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362167#M92895</link>
      <description>&lt;P&gt;Up-Vote is clicking the "^" character to the left of an answer above the counter and also in the header of a comment.&lt;/P&gt;

&lt;P&gt;Does something like this help?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval raw="192.168.1.1 192.168.2.10::192.168.2.10 192.168.1.1::192.168.1.3 192.168.2.11"
| makemv delim="::" raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?&amp;lt;HOST&amp;gt;\S+)\s+(?&amp;lt;SERVER&amp;gt;.*)$"

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| eval IPs=mvsort(mvappend(HOST, SERVER))
| nomv IPs
| rex field=IPs mode=sed "s/\s+/::/g"
| stats count by IPs
| makemv delim="::" IPs
| lookup data_file IPs as src_ip Output src_ip destzone srczone
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Jun 2017 15:57:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362167#M92895</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-24T15:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: multiple input fields for csv lookup</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362168#M92896</link>
      <description>&lt;P&gt;thank you.  I will try today and report the results.  Your help has been very valuable and I am learning the flexibility and approach.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 11:53:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/multiple-input-fields-for-csv-lookup/m-p/362168#M92896</guid>
      <dc:creator>dxw350</dc:creator>
      <dc:date>2017-06-26T11:53:59Z</dc:date>
    </item>
  </channel>
</rss>

