<?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 create a search to join 2 csv files? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593516#M206578</link>
    <description>&lt;P&gt;Here is an example that does what you want. I have made an assumption that the Alert_Type field provides the mapping to find the associated rules to apply.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup Alerts.csv
| lookup Mapping.csv Alert_Type as Alert_type
| eval criteria=mvzip(mvzip(Inclusion, Exclusion, ","), Header, ",")
| fields Alert_Header Alert_type Date criteria
| mvexpand criteria
| rex field=criteria "(?&amp;lt;Inclusion&amp;gt;[^,]*),(?&amp;lt;Exclusion&amp;gt;[^,]*),(?&amp;lt;Header&amp;gt;.*)"
| fields - criteria
| where match(Alert_Header, Inclusion) AND (Exclusion="NONE" OR !match(Alert_Header, Exclusion))
| table Alert_Header Alert_type Date Header&lt;/LI-CODE&gt;&lt;P&gt;Note a couple of observations. The "DATABASE" in the Alerts.csv will not lookup 'Database' in Mapping.csv as the case is different - you can make these case insensitive lookup definitions or just convert the lookup field before the lookup command to match the case of the lookup.&lt;/P&gt;&lt;P&gt;Also, note that Alert_Type and Alert_type are different fields, hence the syntax of the lookup command&lt;/P&gt;&lt;P&gt;What this is doing is&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Looking up the associated rules for Alert_Type&lt;/LI&gt;&lt;LI&gt;Building a composite field of the 2 criteria + header&lt;/LI&gt;&lt;LI&gt;Expanding the rows to provide a single set of criteria per Alert_Header&lt;/LI&gt;&lt;LI&gt;Breaking out the criteria to the separate fields again&lt;/LI&gt;&lt;LI&gt;Performing the logic match&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Apr 2022 23:45:28 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2022-04-12T23:45:28Z</dc:date>
    <item>
      <title>How to create a search to join 2 csv files?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593482#M206560</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have 2 CSVs in my splunk:&lt;/P&gt;
&lt;P&gt;Alert.csv having below columns and data:&lt;/P&gt;
&lt;P&gt;Alert_Header&amp;nbsp; &amp;nbsp;Alert_type&amp;nbsp; &amp;nbsp;Date&lt;/P&gt;
&lt;P&gt;JNA/athena_VICTORIA_Load [FAILED]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&lt;/P&gt;
&lt;P&gt;JNA/athena_VICTORIA_Staging [MAXRUN]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&lt;/P&gt;
&lt;P&gt;JNA/athena_MAIN_Load [FAILED]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&lt;/P&gt;
&lt;P&gt;JNA/athena_OLTP_Staging [MAXRUN]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&lt;/P&gt;
&lt;P&gt;NYP02000 has high_cpu&amp;nbsp; &amp;nbsp;DATABASE&amp;nbsp; &amp;nbsp;01/03/2022&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mapping.csv having below columns and data:&lt;/P&gt;
&lt;P&gt;Alert_Type&amp;nbsp; &amp;nbsp;Inclusion&amp;nbsp; &amp;nbsp;Exclusion&amp;nbsp; &amp;nbsp;Header&lt;/P&gt;
&lt;P&gt;Autosys&amp;nbsp; &amp;nbsp;athena&amp;nbsp; &amp;nbsp;VICTORIA&amp;nbsp; &amp;nbsp;ATHENA-Jobs&lt;/P&gt;
&lt;P&gt;Autosys&amp;nbsp; &amp;nbsp;VICTORIA&amp;nbsp; &amp;nbsp;NONE&amp;nbsp; &amp;nbsp;VICTORIA-Jobs&lt;/P&gt;
&lt;P&gt;Database&amp;nbsp; &amp;nbsp;high_cpu&amp;nbsp; &amp;nbsp;NONE&amp;nbsp; &amp;nbsp;CPU alerts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output required:&lt;/P&gt;
&lt;P&gt;Alert_Header&amp;nbsp; &amp;nbsp;Alert_type&amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp;Header&lt;/P&gt;
&lt;P&gt;JNA/athena_VICTORIA_Load [FAILED]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&amp;nbsp; &amp;nbsp;VICTORIA-Jobs&lt;/P&gt;
&lt;P&gt;JNA/athena_VICTORIA_Staging [MAXRUN]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&amp;nbsp; &amp;nbsp;VICTORIA-Jobs&lt;/P&gt;
&lt;P&gt;JNA/athena_MAIN_Load [FAILED]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&amp;nbsp; &amp;nbsp;ATHENA-Jobs&lt;/P&gt;
&lt;P&gt;JNA/athena_OLTP_Staging [MAXRUN]&amp;nbsp; &amp;nbsp;Autosys&amp;nbsp; &amp;nbsp;01/03/2022&amp;nbsp; &amp;nbsp;ATHENA-Jobs&lt;/P&gt;
&lt;P&gt;NYP02000 has high_cpu&amp;nbsp; &amp;nbsp;DATABASE&amp;nbsp; &amp;nbsp;01/03/2022&amp;nbsp; &amp;nbsp;CPU alerts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Logic: Mapping file is for looking up pattern in the Alert.csv. So if any Alert_Header which has "athena"(mentioned in Inclusion)&amp;nbsp;but doesn't have "Victoria" (mentioned in Exclusion) keyword in it will be termed as "ATHENA-Jobs" . Similarly if any Alert_Header which has "Victoria"(mentioned in Inclusion) only will be termed as "VICTORIA-Jobs". None in Exclusion column would mean there is no exclusion pattern to be searched in Alert_Header.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help with this query&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 16:39:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593482#M206560</guid>
      <dc:creator>jinishshah</dc:creator>
      <dc:date>2022-04-12T16:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search to join 2 csv files?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593516#M206578</link>
      <description>&lt;P&gt;Here is an example that does what you want. I have made an assumption that the Alert_Type field provides the mapping to find the associated rules to apply.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup Alerts.csv
| lookup Mapping.csv Alert_Type as Alert_type
| eval criteria=mvzip(mvzip(Inclusion, Exclusion, ","), Header, ",")
| fields Alert_Header Alert_type Date criteria
| mvexpand criteria
| rex field=criteria "(?&amp;lt;Inclusion&amp;gt;[^,]*),(?&amp;lt;Exclusion&amp;gt;[^,]*),(?&amp;lt;Header&amp;gt;.*)"
| fields - criteria
| where match(Alert_Header, Inclusion) AND (Exclusion="NONE" OR !match(Alert_Header, Exclusion))
| table Alert_Header Alert_type Date Header&lt;/LI-CODE&gt;&lt;P&gt;Note a couple of observations. The "DATABASE" in the Alerts.csv will not lookup 'Database' in Mapping.csv as the case is different - you can make these case insensitive lookup definitions or just convert the lookup field before the lookup command to match the case of the lookup.&lt;/P&gt;&lt;P&gt;Also, note that Alert_Type and Alert_type are different fields, hence the syntax of the lookup command&lt;/P&gt;&lt;P&gt;What this is doing is&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Looking up the associated rules for Alert_Type&lt;/LI&gt;&lt;LI&gt;Building a composite field of the 2 criteria + header&lt;/LI&gt;&lt;LI&gt;Expanding the rows to provide a single set of criteria per Alert_Header&lt;/LI&gt;&lt;LI&gt;Breaking out the criteria to the separate fields again&lt;/LI&gt;&lt;LI&gt;Performing the logic match&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 23:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593516#M206578</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-12T23:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search to join 2 csv files?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593608#M206616</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;for your quick response.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Just have one issue with this, it is ignoring the rows which don't match any of pattern. How can I update the query such that all rows which don't match any criteria are termed as Header="Others"&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 14:06:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593608#M206616</guid>
      <dc:creator>jinishshah</dc:creator>
      <dc:date>2022-04-13T14:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a search to join 2 csv files?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593686#M206646</link>
      <description>&lt;P&gt;All you need to do is to change the 'where' line to this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fillnull Header value="Others"
| where match(Alert_Header, Inclusion) AND (Exclusion="NONE" OR !match(Alert_Header, Exclusion)) OR match(Header, "^Others$")&lt;/LI-CODE&gt;&lt;P&gt;This is saying&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;make all Header values that are null, the word "Others"&lt;/LI&gt;&lt;LI&gt;Add an extra test to include the row is that header is exactly Others&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The reason why it's excluded is that criteria is null for the non matched mappings, hence the expanded variables Inclusion/Exclusion/Header are then null, so for this specific case, you then fix it up at the end.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 23:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-to-join-2-csv-files/m-p/593686#M206646</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-13T23:45:22Z</dc:date>
    </item>
  </channel>
</rss>

