<?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: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205176#M59626</link>
    <description>&lt;P&gt;Yes domain_name exists, Reference doesn't... however, I tried to butcher something together and it didn't work.&lt;/P&gt;

&lt;P&gt;how would something like this be written? &lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2016 10:53:41 GMT</pubDate>
    <dc:creator>abbam</dc:creator>
    <dc:date>2016-06-09T10:53:41Z</dc:date>
    <item>
      <title>How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205174#M59624</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;Wondering if anyone can help me and if this can be done.&lt;/P&gt;

&lt;P&gt;I have a CSV file with two columns.&lt;/P&gt;

&lt;P&gt;CSV file looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;domain_name           Reference
abc.com               ABC
bbc.co.uk             BBC
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In my index, I have a field called &lt;CODE&gt;domain_name&lt;/CODE&gt; in which I can run the following search on:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data [|inputlookup test.csv | fields domain_name]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above search works, however, I want to also reference that &lt;CODE&gt;domain_name&lt;/CODE&gt; to the &lt;CODE&gt;Reference&lt;/CODE&gt; column in the CSV file. This is where the problem starts because there isn't a &lt;CODE&gt;Reference&lt;/CODE&gt; field in the index=data, so the search fails to find any results.&lt;/P&gt;

&lt;P&gt;My end goal is to get a number of References against the domain_names so it looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Reference      count
ABC              150
BBC               25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can this be done at all?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 08:19:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205174#M59624</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2016-06-09T08:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205175#M59625</link>
      <description>&lt;P&gt;Is there a domain_name field inside of index=data? If so you might want to use the lookup command (&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Lookup" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Lookup&lt;/A&gt;)  instead of inputlookup. That way you can lookup the domain_name field of each event and return the Reference and then apply some stats commands on that. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:55:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205175#M59625</guid>
      <dc:creator>ryanoconnor</dc:creator>
      <dc:date>2020-09-29T09:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205176#M59626</link>
      <description>&lt;P&gt;Yes domain_name exists, Reference doesn't... however, I tried to butcher something together and it didn't work.&lt;/P&gt;

&lt;P&gt;how would something like this be written? &lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 10:53:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205176#M59626</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2016-06-09T10:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205177#M59627</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data | lookup test.csv domain_name OUTPUT Reference | where isnotnull(Reference) | stats count by Reference 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jun 2016 11:25:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205177#M59627</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-09T11:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205178#M59628</link>
      <description>&lt;P&gt;afraid nothing, doesnt return any events.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 12:18:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205178#M59628</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2016-06-09T12:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205179#M59629</link>
      <description>&lt;P&gt;You've uploaded the Lookup Table, have you also defined a Lookup Definition? You'll need to do that to use it in a search. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/Knowledge/Usefieldlookupstoaddinformationtoyourevents#Edit_existing_lookup_definitions_or_define_a_new_file-based_or_external_lookup" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/Knowledge/Usefieldlookupstoaddinformationtoyourevents#Edit_existing_lookup_definitions_or_define_a_new_file-based_or_external_lookup&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The following is basic but &lt;EM&gt;should&lt;/EM&gt; work provided you have the correct permissions to use the lookup. &lt;/P&gt;

&lt;P&gt;index=data | lookup test.csv domain_name OUTPUT Reference | table domain_name Reference | stats count by Reference&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205179#M59629</guid>
      <dc:creator>ryanoconnor</dc:creator>
      <dc:date>2020-09-29T09:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205180#M59630</link>
      <description>&lt;P&gt;The "right" way to do it is to setup the CSV as a &lt;CODE&gt;lookup table&lt;/CODE&gt;.  But let's look at doing it directly without doing that.  Assume your file is called &lt;CODE&gt;test.csv&lt;/CODE&gt; and try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=data | eval dataset="nonCSV"
| appendpipe  [|inputlookup test.csv | eval dataset="CSV" ]
| stats values(*) AS * BY domain_name
| stast count BY Reference
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2016 16:17:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205180#M59630</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-13T16:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205181#M59631</link>
      <description>&lt;P&gt;@abbam were you able to verify if the lookup definition is configured? &lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 17:23:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205181#M59631</guid>
      <dc:creator>ryanoconnor</dc:creator>
      <dc:date>2016-06-13T17:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to match a fieldA from an index to fieldA in a CSV lookup file and output the corresponding fieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205182#M59632</link>
      <description>&lt;P&gt;If you setup your lookup table to do automatic lookups, then your &lt;CODE&gt;Reference&lt;/CODE&gt; field will be a field in each event which has a &lt;CODE&gt;domain_name&lt;/CODE&gt;.&lt;BR /&gt;
At that point, you can then write a search similar to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; _your_search_here_ | stats count(domain_name) as count by Reference
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2016 18:45:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-a-fieldA-from-an-index-to-fieldA-in-a-CSV-lookup/m-p/205182#M59632</guid>
      <dc:creator>cb_usps</dc:creator>
      <dc:date>2016-06-13T18:45:54Z</dc:date>
    </item>
  </channel>
</rss>

