<?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 to search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700132#M237612</link>
    <description>&lt;P&gt;Either two columns as you described, or two columns with machines that SHOULD appear and another column saying Missing if it's not there or New if it's new and unexpected. That way I wouldn't need to look through them as thoroughly and at a glance be able to see if something is wrong.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2024 19:46:01 GMT</pubDate>
    <dc:creator>H4waiianPunch</dc:creator>
    <dc:date>2024-09-25T19:46:01Z</dc:date>
    <item>
      <title>Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700130#M237610</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'd like to start out by saying I'm really quite new to Splunk, and we run older versions(6.6.3 and 7.2.3).&lt;/P&gt;&lt;P&gt;I'm looking to have a search that will do the following:&lt;/P&gt;&lt;P&gt;- Look up the current hosts in our system, which I can get with the following search&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "daily.cvd"
| dedup host | table host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;- Then compare to a CSV file that has 1 column with A1 being "host" and then all other entries are the hosts that SHOULD be present/accounted for.&lt;/P&gt;&lt;P&gt;-- Using ChatGPT I was able to get something like below which on it's own will properly read the CSV file and output the hosts in it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| append [
    | inputlookup hosts.csv
    | rename host as known_hosts
    | stats values(known_hosts) as known_hosts
]
| eval source="current"
| eval status=if(isnull(mvfind(known_hosts, current_hosts)), "New", "Existing")
| eval status=if(isnull(mvfind(current_hosts, known_hosts)), "Missing", status)
| mvexpand current_hosts
| mvexpand known_hosts
| table current_hosts, known_hosts, status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- However when I combine the 2, it will show me 118 results(should only be 59) and there are no results in the "current_hosts" column, and after 59 blank results, the "known_hosts" will then show the correct results from the CSV.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "daily.cvd"
| dedup host | table host
| append [
    | inputlookup hosts.csv
    | rename host as known_hosts
    | stats values(known_hosts) as known_hosts
]
| eval source="current"
| eval status=if(isnull(mvfind(known_hosts, current_hosts)), "New", "Existing")
| eval status=if(isnull(mvfind(current_hosts, known_hosts)), "Missing", status)
| mvexpand current_hosts
| mvexpand known_hosts
| table current_hosts, known_hosts, status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd love to have any help on this, I'm wouldn't be surprised if ChatGPT is making things more difficult than needed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 19:14:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700130#M237610</guid>
      <dc:creator>H4waiianPunch</dc:creator>
      <dc:date>2024-09-25T19:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700131#M237611</link>
      <description>&lt;P&gt;If I understand correctly, you would like the final output to be two columns, where one shows the machines that SHOULD appear, and the second shows the machines that DO appear? Then you could see which machines are not appearing and therefore need attention?&lt;BR /&gt;&lt;BR /&gt;E.g.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;SHOULD_APPEAR&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;DO_APPEAR&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;host1&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;host1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;host2&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;host3&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;host3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 25 Sep 2024 19:43:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700131#M237611</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2024-09-25T19:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700132#M237612</link>
      <description>&lt;P&gt;Either two columns as you described, or two columns with machines that SHOULD appear and another column saying Missing if it's not there or New if it's new and unexpected. That way I wouldn't need to look through them as thoroughly and at a glance be able to see if something is wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 19:46:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700132#M237612</guid>
      <dc:creator>H4waiianPunch</dc:creator>
      <dc:date>2024-09-25T19:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700134#M237613</link>
      <description>&lt;P&gt;Have a go at this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "daily.cvd"
| dedup host
| table host
| append
[| inputlookup hosts.csv]
| stats count by host
| where count = 1
| lookup hosts.csv host outputnew host as host_found
| eval status = if(isnull(host_found),"NEW","MISSING")
| table host status&lt;/LI-CODE&gt;&lt;P&gt;Make sure you have a lookup table (hosts.csv) with a single "host" column containing all your expected hosts.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 20:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700134#M237613</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2024-09-25T20:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700158#M237625</link>
      <description>&lt;P&gt;ChatGPT is perhaps the last place you want to learn SPL from. &amp;nbsp;The task is relative straightforward.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "daily.cvd"
| fields host ``` only needed if sources have too many fields ```
| eval source = "INDEX"
| append
    [inputlookup hosts.csv
    | eval source = "CSV"]
| stats values(source) as source by host
| eval status = case(mvcount(source) &amp;gt; 1, null(), source == "CSV", "Missing", true(), "New")
| fields - source&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Sep 2024 04:00:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700158#M237625</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-09-26T04:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700251#M237647</link>
      <description>&lt;P&gt;Hey, I certainly agree that ChatGPT isn't the best place to learn, but it comes in handy sometimes. I need to start taking some actual training though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your solution did work, so thank you for sharing it with me. I did then go and use GPT to help explain the details to me and I think I understand it all so that's nice. Setting sources to different values and comparing them that way is neat and I'm glad I've seen that now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 16:53:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700251#M237647</guid>
      <dc:creator>H4waiianPunch</dc:creator>
      <dc:date>2024-09-26T16:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Compare CSV to search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700252#M237648</link>
      <description>&lt;P&gt;Hey, thank you very much for this query! I've decided to go with yours out of the 2 responses here as it displays just the one host in the end instead of all of them which will be nicer at a glance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You made it seem very simple and I appreciate that, I have a lot to learn!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 16:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-CSV-to-search/m-p/700252#M237648</guid>
      <dc:creator>H4waiianPunch</dc:creator>
      <dc:date>2024-09-26T16:54:50Z</dc:date>
    </item>
  </channel>
</rss>

