<?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: Using a field value to reference a lookup column in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363409#M6074</link>
    <description>&lt;P&gt;Thanks very much for the pointer - now managed to get this working.  I'd been thinking about re-working the lookup but the untable option is very nifty to do this.  &lt;/P&gt;</description>
    <pubDate>Thu, 26 Apr 2018 21:04:23 GMT</pubDate>
    <dc:creator>skelly99</dc:creator>
    <dc:date>2018-04-26T21:04:23Z</dc:date>
    <item>
      <title>Using a field value to reference a lookup column</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363407#M6072</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;Is there any way I can use a field value to reference a column in a lookup&lt;/P&gt;

&lt;P&gt;In my events I have a field called &lt;STRONG&gt;cve&lt;/STRONG&gt; which contains a cve value, eg cve-2016-2018.   I want to use the value of this field along with os information that is also available in my events to match a column in my lookup file.&lt;/P&gt;

&lt;P&gt;The lookup file (vulnerability.csv) looks like this (this is only a small extract from the file - there are 39 columns and 50 or so rows)&lt;/P&gt;

&lt;P&gt;platform, major, minor, cve-2016-2108, cve-2016-5195, cve2017-10010, cve-2017-14491 &lt;BR /&gt;
rhel, 5,5, NP , NV, OSP , NP&lt;BR /&gt;
rhel, 5,6, NP , NV , OSP , DP&lt;BR /&gt;
rhel, 5,7, NP , NV , OSP , DP&lt;BR /&gt;
rhel,6, OSP , DP , NV , NP&lt;BR /&gt;
suse,10 , SP1 , NP , NV , OSP, NP&lt;BR /&gt;
suse,11,  SP1 , NP , NV , OSP , NP&lt;/P&gt;

&lt;P&gt;So I can use | lookup vulnerability platform major minor and I will get all 39 lookup columns added to the event for the matching os&lt;BR /&gt;
However I am only interested in the column that matches the value of the field cve in my event&lt;/P&gt;

&lt;P&gt;Using the lookup table example above - if my event has field values platform=rhel major=5 minor=6 cve=cve-2016-2108 I am only interested in the value in the lookup column cve-2016-2108 which matches my os - in the lookup above that is the value NP&lt;/P&gt;

&lt;P&gt;Does anyone know of a way to substitute a field value to then use match a lookup column?  &lt;/P&gt;

&lt;P&gt;I know I can create a field from a value using eval -  eg field cve=cve-2016-2108  - if I use eval "{cve}"=cve this creates  a new field called cve-2016-2108 with the value cve-2016-2108 - however I can't find a way to then pass the new field into the call to the lookup&lt;/P&gt;

&lt;P&gt;Interested in any suggestions please on how to use a field value to reference look-up column.  Failing that I have to return all columns in the lookup file whats the best way of keeping the column I need and discarding the rest?&lt;/P&gt;

&lt;P&gt;Thanks, S&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 07:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363407#M6072</guid>
      <dc:creator>skelly99</dc:creator>
      <dc:date>2018-04-26T07:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a field value to reference a lookup column</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363408#M6073</link>
      <description>&lt;P&gt;Another better option would be to re-format your lookup table content. Instead of having a column for each cve value, have two columns, cve_name and cve_value. This way you can just lookup based on platform major minor and cve column and get the value as OUTPUT.&lt;/P&gt;

&lt;P&gt;The format that I am talking about for your lookup can be seen by this query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup vulnerability | eval temp=platform."##".major."##".minor | table temp cve*
| untable temp cve_name cve_value
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:18:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363408#M6073</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T19:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using a field value to reference a lookup column</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363409#M6074</link>
      <description>&lt;P&gt;Thanks very much for the pointer - now managed to get this working.  I'd been thinking about re-working the lookup but the untable option is very nifty to do this.  &lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 21:04:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363409#M6074</guid>
      <dc:creator>skelly99</dc:creator>
      <dc:date>2018-04-26T21:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using a field value to reference a lookup column</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363410#M6075</link>
      <description>&lt;P&gt;I actually forgot a step in my query to re-extract fields from temp. You just need to add following after untable command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=temp "(?&amp;lt;platform&amp;gt;.+)##(?&amp;lt;major&amp;gt;.+)##(?&amp;lt;minor&amp;gt;.+)" | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Apr 2018 22:19:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363410#M6075</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-04-26T22:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using a field value to reference a lookup column</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363411#M6076</link>
      <description>&lt;P&gt;Moved to answer, since it solves the issue perfectly.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 03:20:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Using-a-field-value-to-reference-a-lookup-column/m-p/363411#M6076</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-04-27T03:20:01Z</dc:date>
    </item>
  </channel>
</rss>

