<?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: Inputlookup subsearch to match on field A and output field B in CSV file in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323767#M60266</link>
    <description>&lt;P&gt;Let me see if I understand your problem. You have:&lt;BR /&gt;
1. A csv file that maps  &lt;CODE&gt;host&lt;/CODE&gt; values to  &lt;CODE&gt;country&lt;/CODE&gt; values; and&lt;BR /&gt;
2. Data containing values for  &lt;CODE&gt;host&lt;/CODE&gt;, which you are extracting with a  &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;And your goal is to wind up with a table that maps  &lt;CODE&gt;host&lt;/CODE&gt; values present in #2 to their respective  &lt;CODE&gt;country&lt;/CODE&gt; values, as found from the csv file. If that's correct, it's pretty straightforward:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;some search | rex extracting host value into field "host" | lookup csvfile.csv host OUTPUT country | stats values(host) AS host BY country&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2017 14:36:19 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2017-10-23T14:36:19Z</dc:date>
    <item>
      <title>Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323766#M60265</link>
      <description>&lt;P&gt;Im trying to correlate info based on a lookup file and no matter how I try, I cant make it work.&lt;/P&gt;

&lt;P&gt;I have a CSV with values like:&lt;/P&gt;

&lt;P&gt;host,country&lt;BR /&gt;
host1*,country1&lt;BR /&gt;
host2*,country1&lt;BR /&gt;
host3*,country2&lt;/P&gt;

&lt;P&gt;etc&lt;/P&gt;

&lt;P&gt;Im running a search that outputs hosts using a regex:&lt;BR /&gt;
... | rex field=field1  //Simplified, extracts host from text&lt;BR /&gt;
| [|inputlookup csvfile.csv ] &lt;BR /&gt;
| bucket _time span=30d&lt;BR /&gt;
| stats list(host), list(country) by _time&lt;/P&gt;

&lt;P&gt;This search of course does not work.&lt;BR /&gt;
I want to match the &lt;STRONG&gt;host&lt;/STRONG&gt; field of the csv with the rexed host from the search and get the country the host is in in a list along with the actual host. &lt;/P&gt;

&lt;P&gt;I've tried numerous ways but cannot get it to work. Some help would be greatly appreciated. How do I make sure to match the rexed host with a host* value in the csv?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323766#M60265</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2020-09-29T16:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323767#M60266</link>
      <description>&lt;P&gt;Let me see if I understand your problem. You have:&lt;BR /&gt;
1. A csv file that maps  &lt;CODE&gt;host&lt;/CODE&gt; values to  &lt;CODE&gt;country&lt;/CODE&gt; values; and&lt;BR /&gt;
2. Data containing values for  &lt;CODE&gt;host&lt;/CODE&gt;, which you are extracting with a  &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;And your goal is to wind up with a table that maps  &lt;CODE&gt;host&lt;/CODE&gt; values present in #2 to their respective  &lt;CODE&gt;country&lt;/CODE&gt; values, as found from the csv file. If that's correct, it's pretty straightforward:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;some search | rex extracting host value into field "host" | lookup csvfile.csv host OUTPUT country | stats values(host) AS host BY country&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 14:36:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323767#M60266</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T14:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323768#M60267</link>
      <description>&lt;P&gt;Hi christoffertoft,&lt;BR /&gt;
in your lookup don't use * but insert a row for each host&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host,country
host1,country1
host2,country1
host3,country3
host4,country2
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then try a search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search
| rex "//Simplified"
| dedup host
| lookup csvfile.csv host OUTPUT country
| table host country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have more that 10,000 hosts use &lt;CODE&gt;dedup 0 host&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 14:40:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323768#M60267</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-23T14:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323769#M60268</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;BR /&gt;
I need to have host* entries because there are a too wide variety of possible names for me to catalogue. I only need to match the first part of the host anyway. Does this make a difference? Thanks for your reply&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 15:03:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323769#M60268</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-10-23T15:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323770#M60269</link>
      <description>&lt;P&gt;Hi elliot, &lt;/P&gt;

&lt;P&gt;youre correct, sorry for my bad wording in the OP. . &lt;/P&gt;

&lt;P&gt;I tried this, and i get results but the country table is empty. &lt;/P&gt;

&lt;P&gt;The hostnames in the csv have the first part ( a uniquely identifying part ) of the actual hostname presented by the search. i added a star to be able to match on the first part. This should be enough right?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 15:07:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323770#M60269</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-10-23T15:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323771#M60270</link>
      <description>&lt;P&gt;Hi christoffertoft,&lt;BR /&gt;
lookup command matches only the full string, not *.&lt;BR /&gt;
but if you can define a rule (e.g.: first 4 chars of hostname) you could build your lookup in this way (e.g. first 4 chars without *):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class_host,country
aaaa,country1
bbbb,country2
cccc,country3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and run something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search
| rex "//Simplified"
| eval class_host=substr(host,1,4)
| lookup csvfile.csv class_host OUTPUT country
| dedup host
| table host country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this way lookup matches host and you can use the country field.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 15:21:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323771#M60270</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-23T15:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323772#M60271</link>
      <description>&lt;P&gt;Basically, I know that ABC123 and ABC456 belongs to a specific country and thus i only need to match on ABC.&lt;BR /&gt;
If it was DEF123 i would now it was another country. As such, I can say ABC*=country1, DEF*=country2. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323772#M60271</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2020-09-29T16:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323773#M60272</link>
      <description>&lt;P&gt;Hi christoffertoft,&lt;BR /&gt;
so you can build your lookup&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class_host,country
ABC,country1
DEF,country2
GHI,country3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and run this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; my_search
 | rex "//Simplified"
 | eval class_host=substr(host,1,3)
 | lookup csvfile.csv class_host OUTPUT country
 | dedup host
 | table host country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 15:24:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323773#M60272</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-23T15:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323774#M60273</link>
      <description>&lt;P&gt;Right, I will try this! Thanks alot for the help&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 15:26:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323774#M60273</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-10-23T15:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323775#M60274</link>
      <description>&lt;P&gt;If you're satisfied, please accept or upvote this answer.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 15:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323775#M60274</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-23T15:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Inputlookup subsearch to match on field A and output field B in CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323776#M60275</link>
      <description>&lt;P&gt;Ahh, if you are looking to implement wildcard lookup, you'll need a bit more than that.&lt;BR /&gt;
Check out this other answer for some guidance on how to do wildcard lookups:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html"&gt;https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 16:21:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Inputlookup-subsearch-to-match-on-field-A-and-output-field-B-in/m-p/323776#M60275</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T16:21:03Z</dc:date>
    </item>
  </channel>
</rss>

