<?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: Can't MAP a host field with IN clausole in a map searching in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503189#M195271</link>
    <description>&lt;P&gt;Gotcha...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |inputlookup list.csv|where tag="locals"
 |map maxsearches=50 search="search index=* host IN([|makeresults|eval h=$hostnames$|return $h]) source=$source$|table host,source"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Oct 2019 19:45:41 GMT</pubDate>
    <dc:creator>verbal_666</dc:creator>
    <dc:date>2019-10-21T19:45:41Z</dc:date>
    <item>
      <title>Can't MAP a host field with IN clausole in a map searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503185#M195267</link>
      <description>&lt;P&gt;As in object, it's a strange behaviour, i can't use an IN clausole with host field in a map search.&lt;/P&gt;

&lt;P&gt;Here's my search,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup list.csv|where tag="locals"
|map maxsearches=50 search="search index=* host IN($hostnames$) source=$source$|table host,source"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First line works, all fields are passed to map (i also tried a display fields in the map search, and all fields are ok).&lt;BR /&gt;
Second line, the map, does not work with IN clausole and "hostnames" field with more than 1 host.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;list.csv&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NOT WORKING
tag     hostnames   source
locals  host1,host2 /tmp/*logs
locals  host1,host2 /tmp/*TXT
locals  host1,host2 /tmp/*json

WORKING
tag     hostnames   source
locals  host1   /tmp/*logs
locals  host2   /tmp/*logs
locals  host1   /tmp/*TXT
locals  host2   /tmp/*TXT
locals  host1   /tmp/*json
locals  host2   /tmp/*json
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I also tried a &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host IN(*$hostnames$*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but this is like an IN(**), variable seems to be null, but i can display if i try a&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval host=$hostnames$|table host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why?&lt;BR /&gt;
Suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 11:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503185#M195267</guid>
      <dc:creator>verbal_666</dc:creator>
      <dc:date>2019-10-21T11:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can't MAP a host field with IN clausole in a map searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503186#M195268</link>
      <description>&lt;P&gt;@verbal_666 &lt;/P&gt;

&lt;P&gt;Not sure about &lt;CODE&gt;map&lt;/CODE&gt; but you can try below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*  [ |inputlookup list.csv|where tag="locals" | eval hostnames =split(hostnames,",") | mvexpand hostnames | table  hostnames source   ] |table host,source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2019 12:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503186#M195268</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-10-21T12:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can't MAP a host field with IN clausole in a map searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503187#M195269</link>
      <description>&lt;P&gt;Thanx a lot.&lt;BR /&gt;
But i have built this little "Engine" for the "map" command; in reality the csv has many many more fields (earliest, latest, thresholds, pattern to find etc.....). MAP command works perfecly, only the IN clausole does not when i have more than 1 host!!!!!!! &lt;span class="lia-unicode-emoji" title=":neutral_face:"&gt;😐&lt;/span&gt; .....also, the "table host,source" up is only an example, in the real searches i have more than 10 piped commands. It works, but the "host IN" with multiple hosts NOT &lt;span class="lia-unicode-emoji" title=":neutral_face:"&gt;😐&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":neutral_face:"&gt;😐&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":neutral_face:"&gt;😐&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;With the subsearch i need to change many things. Also, the subsearch up, i think, should be ended with a "format" command and also hostnames renamed in "host" to work fine.&lt;/P&gt;

&lt;P&gt;I prefer to fix the "map", for now.&lt;BR /&gt;
Thanks a lot.&lt;/P&gt;

&lt;P&gt;ps. i fixed as workaround the "IN problem" with a tag/eventtype in front who make me permit to search what i need&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|map maxsearches=50 search="search tag=MYTAG source=$source$|table host,source"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;....tag/eventtype contain index and hosts i need.................. i want to bypass also tag.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 15:20:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503187#M195269</guid>
      <dc:creator>verbal_666</dc:creator>
      <dc:date>2019-10-21T15:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can't MAP a host field with IN clausole in a map searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503188#M195270</link>
      <description>&lt;P&gt;Found the problem. Inputlookup passes variables to the map with double-quotes,so a single host is get, a list in IN clausole not.&lt;/P&gt;

&lt;P&gt;Ex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host1,host2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;become, literally,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"host1,host2"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;IN("host1,host2")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is not parsed good,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host1 IN(host1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in parsed good, without double quotes, but also making quoted works with single host. Null-string is passed as &lt;STRONG&gt;""&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;Trying to remove the quotes.&lt;/P&gt;

&lt;P&gt;Another workaround, bad, but working,is something like adding single host fields in csv,&lt;BR /&gt;
h1,h2,h3,h4&lt;BR /&gt;
and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=$h1$ OR host=$h2$ OR host=$h3$ OR host=$h4$)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in the map search. Very bad, but it works.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 19:26:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503188#M195270</guid>
      <dc:creator>verbal_666</dc:creator>
      <dc:date>2019-10-21T19:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can't MAP a host field with IN clausole in a map searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503189#M195271</link>
      <description>&lt;P&gt;Gotcha...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |inputlookup list.csv|where tag="locals"
 |map maxsearches=50 search="search index=* host IN([|makeresults|eval h=$hostnames$|return $h]) source=$source$|table host,source"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2019 19:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-MAP-a-host-field-with-IN-clausole-in-a-map-searching/m-p/503189#M195271</guid>
      <dc:creator>verbal_666</dc:creator>
      <dc:date>2019-10-21T19:45:41Z</dc:date>
    </item>
  </channel>
</rss>

