<?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 How to match values if already in table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483568#M135386</link>
    <description>&lt;P&gt;I appended a CSV to an index, and right now my results pop up as the 100 lines of CSV, and then 30K of the index. &lt;/P&gt;

&lt;P&gt;What I would like is to only return IF the values in the fw field from the index MATCH a value in the 100 lines of the CSV firewall_rule field... thoughts? I have a match in there currently but it's showing no similarities (even though I manually checked, there are many).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| from inputlookup:"firewall-exception-prod.csv"
| append [ search index=gcp_firewall]
| rename data.jsonPayload.rule_details.reference as FW 
| search FW = "network:prod*" OR firewall_rule=*
| rex field=FW "network:prod-corp/firewall:(?.*)"
| eval result=if(match(fw, firewall_rule),"yes", "no")
| table firewall_rule fw result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you know what I'm missing? Thank you!!!&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 18:27:06 GMT</pubDate>
    <dc:creator>katmagee</dc:creator>
    <dc:date>2020-04-27T18:27:06Z</dc:date>
    <item>
      <title>How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483568#M135386</link>
      <description>&lt;P&gt;I appended a CSV to an index, and right now my results pop up as the 100 lines of CSV, and then 30K of the index. &lt;/P&gt;

&lt;P&gt;What I would like is to only return IF the values in the fw field from the index MATCH a value in the 100 lines of the CSV firewall_rule field... thoughts? I have a match in there currently but it's showing no similarities (even though I manually checked, there are many).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| from inputlookup:"firewall-exception-prod.csv"
| append [ search index=gcp_firewall]
| rename data.jsonPayload.rule_details.reference as FW 
| search FW = "network:prod*" OR firewall_rule=*
| rex field=FW "network:prod-corp/firewall:(?.*)"
| eval result=if(match(fw, firewall_rule),"yes", "no")
| table firewall_rule fw result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you know what I'm missing? Thank you!!!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 18:27:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483568#M135386</guid>
      <dc:creator>katmagee</dc:creator>
      <dc:date>2020-04-27T18:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483569#M135387</link>
      <description>&lt;P&gt;The &lt;CODE&gt;append&lt;/CODE&gt; command adds the results of its search to the end of the results of the previous search.  The two sets of results have no relationship to each other so it's impossible to compare a field in one to a field in the other.&lt;/P&gt;

&lt;P&gt;The typical approach to this problem is to put the lookup file in a subsearch.  The results of the subsearch become a filter of the main search, getting you indexed events that have a field value in the CSV.  It looks something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=gcp_firewall [ | inputlookup firewall-exception-prod.csv ]
| rename data.jsonPayload.rule_details.reference as FW
| search FW = "network:prod*" OR firewall_rule=
| rex field=FW "network:prod-corp/firewall:(?.)"
| eval result=if(match(fw, firewall_rule),"yes", "no")
| table firewall_rule fw result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The exact query may be different depending on the names of the fields in the lookup.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 19:53:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483569#M135387</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-04-27T19:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483570#M135388</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;since you have a CSV file, did you try to use the lookup or join command instead of append, something like below.&lt;/P&gt;

&lt;P&gt;search index=gcp_firewall&lt;BR /&gt;
| rename data.jsonPayload.rule_details.reference as FW&lt;BR /&gt;
| lookup firewall-exception-prod.csv FW as FWfield outputnew &amp;lt; whatever fields you want to get from csv file&amp;gt;&lt;BR /&gt;
|search FWfield=*&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:09:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483570#M135388</guid>
      <dc:creator>prachisaxena</dc:creator>
      <dc:date>2020-09-30T05:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483571#M135389</link>
      <description>&lt;P&gt;Is this doing the lookup right away though?  The issue is a need lines 2-4 to happen before the lookup can occur since I have to change the FW field to fw via rex command....&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 17:57:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483571#M135389</guid>
      <dc:creator>katmagee</dc:creator>
      <dc:date>2020-04-28T17:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483572#M135390</link>
      <description>&lt;P&gt;so with this, FWfield is the same field from my csv names firewall_rule, correct? and its checking against FW from the index payload? Want to make sure I'm looking at this right&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 18:01:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483572#M135390</guid>
      <dc:creator>katmagee</dc:creator>
      <dc:date>2020-04-28T18:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483573#M135391</link>
      <description>&lt;P&gt;Yes, the lookup is done first.  To do field extraction before the lookup, try this:&lt;/P&gt;

&lt;P&gt;index=gcp_firewall&lt;BR /&gt;
| rename data.jsonPayload.rule_details.reference as FW&lt;BR /&gt;
| search FW = "network:prod*" OR firewall_rule=&lt;BR /&gt;
| rex field=FW "network:prod-corp/firewall:(?.)"&lt;BR /&gt;
| lookup firewall-exception-prod.csv firewall_rule as fw OUTPUT firewall_rule as fw&lt;BR /&gt;
| eval result=if(isnotnull(fw),"yes", "no")&lt;BR /&gt;
| table firewall_rule fw result&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:10:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483573#M135391</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-09-30T05:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to match values if already in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483574#M135392</link>
      <description>&lt;P&gt;this worked! thanks&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 13:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-values-if-already-in-table/m-p/483574#M135392</guid>
      <dc:creator>katmagee</dc:creator>
      <dc:date>2020-04-29T13:46:43Z</dc:date>
    </item>
  </channel>
</rss>

