<?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: Compare .csv file with results from search and join by uniqueID in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619208#M215207</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats correct, so in a nutshell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the search result is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ioc: false&lt;BR /&gt;dns:false&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and in the csv i have&lt;BR /&gt;&lt;BR /&gt;Config Item, Config Setting&lt;BR /&gt;DNS,Enabled&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then i want my search result to basically show a line similar to the below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;customer&amp;nbsp; &amp;nbsp; Config Item&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; live&lt;/P&gt;&lt;P&gt;man0000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DNS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Enabled or true&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Disabled or false&lt;BR /&gt;&lt;BR /&gt;Only return result where there is a mismatch, showing the above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2022 21:41:16 GMT</pubDate>
    <dc:creator>greekleo89</dc:creator>
    <dc:date>2022-11-01T21:41:16Z</dc:date>
    <item>
      <title>How to compare .csv file with results from search and join by uniqueID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619136#M215187</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a search&amp;nbsp;&lt;/P&gt;
&lt;P&gt;index=main sourcetype=data2 type=policy&lt;BR /&gt;&lt;BR /&gt;that gives me the following in json:&lt;/P&gt;
&lt;P&gt;customerId: man0000&lt;/P&gt;
&lt;P&gt;dns: false&lt;/P&gt;
&lt;P&gt;ioc: true&lt;/P&gt;
&lt;P&gt;type: policy&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I have a csv which has the following (the purpose of the csv is to show what the default settings should be across all customers)&lt;BR /&gt;&lt;BR /&gt;Config Item, Config setting&lt;BR /&gt;DNS, Enabled&lt;BR /&gt;IOC, Disabled&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We also have a list of customers in a database with the customerId's&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So my search logic was as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search the index to bring all the different search results as a table&lt;BR /&gt;rename the search results so instead of dns have DNS and instead of ioc have IOC etc&lt;BR /&gt;&lt;BR /&gt;| join customer ID&lt;BR /&gt;[| dbxquery query=.....] -&lt;STRONG&gt; to get cus id's&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;|Inputlookup the csv file (here is where i get stuck)&lt;BR /&gt;&lt;BR /&gt;I don't know how to link them together so that for every customerid from the DB that matches the customerID in the search to compare the results from search i.e where ioc: true and on csv is Disabled, to output the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 02:40:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619136#M215187</guid>
      <dc:creator>greekleo89</dc:creator>
      <dc:date>2022-11-02T02:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619166#M215196</link>
      <description>&lt;P&gt;You want &lt;FONT face="courier new,courier"&gt;lookup&lt;/FONT&gt; rather than &lt;FONT face="courier new,courier"&gt;inputlookup&lt;/FONT&gt;. The latter reads in the entire lookup file whereas the former maps field values to lookup values.&amp;nbsp; Because DNS and IOC are in separate fields, we need separate lookups.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| join customer ID
[| dbxquery query=.....] - to get cus id's

|lookup mylookup.csv "Config Item" AS DNS OUTPUT dns_enabled
|lookup mylookup.csv "Config Item" AS IOC OUTPUT ioc_enabled&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:48:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619166#M215196</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-01T16:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619207#M215206</link>
      <description>&lt;P&gt;If you are intending to get the 'default' setting for the "DNS" and "IOC" into your event, so you can compare the returned search value "false" in the dns field against the default DNS setting if "Enabled" then you can either do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval item="DNS"
| lookup mylookup.csv "Config Item" AS item OUTPUT dns_enabled
| eval item="IOC"
| lookup mylookup.csv "Config Item" AS item OUTPUT ioc_enabled&lt;/LI-CODE&gt;&lt;P&gt;then you will have two new fields in each event with the value of the config setting. You can then make comparisons as needed against your dns and ioc fields against the setting fields.&lt;/P&gt;&lt;P&gt;Alternatively you can do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your search...
| appendcols [
  | inputlookup mycsv.csv
  ``` This is to remove the spaces in the field names ```
  | rename "Config Item" as ConfigItem, "Config setting" as ConfigSetting
  | eval {ConfigItem}_default = ConfigSetting
  | fields *_default
  | stats values(*) as *
]
| filldown *_default&lt;/LI-CODE&gt;&lt;P&gt;and that will give you two new fields in each event,&amp;nbsp;IOC_default and DNS_default&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 21:32:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619207#M215206</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-01T21:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619208#M215207</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats correct, so in a nutshell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the search result is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ioc: false&lt;BR /&gt;dns:false&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and in the csv i have&lt;BR /&gt;&lt;BR /&gt;Config Item, Config Setting&lt;BR /&gt;DNS,Enabled&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then i want my search result to basically show a line similar to the below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;customer&amp;nbsp; &amp;nbsp; Config Item&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; default&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; live&lt;/P&gt;&lt;P&gt;man0000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DNS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Enabled or true&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Disabled or false&lt;BR /&gt;&lt;BR /&gt;Only return result where there is a mismatch, showing the above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 21:41:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619208#M215207</guid>
      <dc:creator>greekleo89</dc:creator>
      <dc:date>2022-11-01T21:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619209#M215208</link>
      <description>&lt;P&gt;So having used either of the techniques in the earlier post to get the data, use the following clause&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval dns_mismatch=if(match(DNS_enabled, "(?i)true|enabled") AND match(dns, "(?i)false|disabled") OR match(DNS_enabled, "(?i)false|disabled") AND match(dns, "(?i)true|enabled"), 1, 0)
| where dns_mismatch=1&lt;/LI-CODE&gt;&lt;P&gt;this sets a 1/0 value to dns_mismatch field if the actual value of dns field does NOT match the default setting (here is is case insensitive and supports the true/false/enabled/disabled variants of setting.&lt;/P&gt;&lt;P&gt;The just table out the fields you want.&lt;/P&gt;&lt;P&gt;Same applies to the IOC variant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 22:09:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619209#M215208</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-01T22:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619211#M215209</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this, i will try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However there are 15 settings files and most of them have like 12/13 settings so these searches will be huge to write out, but if this is the only way then so be it.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 22:23:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619211#M215209</guid>
      <dc:creator>greekleo89</dc:creator>
      <dc:date>2022-11-01T22:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619230#M215217</link>
      <description>&lt;P&gt;There are other ways to make it a one liner, e.g. this example is based on a lookup file containing the following lookup values&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Config_Item	Config_setting
DNS,Enabled
IOC,Disabled
S3,Disabled
TCP,Enabled
UDP,Disabled
XYZ,Enabled&lt;/LI-CODE&gt;&lt;P&gt;This example below then makes 10 events each with fields containing a random true/false setting to prove how this works.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=10
``` THIS MAKES RANDOM TRUE/FALSE VALUES FOR THE FOLLOWING FIELDS ```
| eval options=split("true,false",",")
| eval dns=mvindex(options, random() % 2), ioc=mvindex(options, random() % 2), s3=mvindex(options, random() % 2), tcp=mvindex(options, random() % 2), udp=mvindex(options, random() % 2), xyz=mvindex(options, random() % 2)
| fields - options
``` THIS APPENDS THE LOOKUP COLUMNS ```
| appendcols [
  | inputlookup mycsv.csv
  | eval Item=lower(Config_Item)
  | eval {Item}_default = Config_setting
  | fields *_default
  | stats values(*) as *
]
| filldown *_default
``` AND THIS MAKES XXX_MISMATCH FIELD TO INDICATE MISMATCH, AS WELL AS A MASTER MISMATCH FIELD ```
| foreach *_default [ eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_mismatch=if(match('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "(?i)true|enabled") AND match(&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;, "(?i)false|disabled") OR 
                                                    match('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "(?i)false|disabled") AND match(&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;, "(?i)true|enabled"), 1, 0),
                           mismatch=if(&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_mismatch=1, 1, mismatch) ]
| where mismatch=1&lt;/LI-CODE&gt;&lt;P&gt;So, it's that final one foreach statement that does the comparison for all fields named *_default and compares the * component to a field in your data with the same name. You don't need to set a xxx_mismatch field, that's just to show you what's happening.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, when you talk about 15 different settings files, maybe this may not be the right solution for your use case. If you can give a broader definition of your use case, and how all those settings files are supposed to work, we can see if there is a more appropriate solution.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 05:32:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619230#M215217</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-02T05:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Compare .csv file with results from search and join by uniqueID</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619258#M215228</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sure so i have 15 different .csv's all named differently.&lt;/P&gt;&lt;P&gt;policy.csv&lt;/P&gt;&lt;P&gt;audit.csv&lt;BR /&gt;&lt;BR /&gt;The files all contain the columns:&lt;BR /&gt;Configuration Item&amp;nbsp; Configuration Setting&lt;BR /&gt;DNS,Enabled&lt;BR /&gt;IOC,Disabled&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;**Note - I can't combine the csv's together because there would be duplicate fields i.e exist in more than one file.&lt;/P&gt;&lt;P&gt;My search is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Index=main sourcetype="data" type=policy&amp;nbsp; ''' the type basically exists in every csv file, coincidently the csv's are named by the type, i.e policy.csv.&lt;BR /&gt;&lt;BR /&gt;|rename dns as DNS ioc AS IOC customerId as companyId&lt;/P&gt;&lt;P&gt;|table DNS IOC companyId&lt;/P&gt;&lt;P&gt;| join companyId&lt;BR /&gt;&lt;BR /&gt;[| dbxquery query="SELECT companyId FROM table_systems WHERE status =1 connection="live_Db"]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My results (before the input lookup)&amp;nbsp; look like this in a table&lt;BR /&gt;&lt;BR /&gt;IOC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DNS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; companyId&lt;/P&gt;&lt;P&gt;false&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;true&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; man0000&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What i would like is&lt;BR /&gt;&lt;BR /&gt;Configuration Item&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Default&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Current or Live&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; companyId&lt;BR /&gt;IOC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Enabled&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; disabled or False&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; man0000&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 09:28:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-csv-file-with-results-from-search-and-join-by/m-p/619258#M215228</guid>
      <dc:creator>greekleo89</dc:creator>
      <dc:date>2022-11-02T09:28:45Z</dc:date>
    </item>
  </channel>
</rss>

