<?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: Need help with a query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692960#M235839</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;that solution will work when we have a common field in both, but that's the case here&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What do you mean? &amp;nbsp;You don't need "common" field, if by that you mean identical entries. &amp;nbsp;Consider these two:&lt;/P&gt;&lt;P&gt;IP_add.csv&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;ip&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.110.1.152&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.16.8.11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.16.8.240&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;cidr.csv&lt;/P&gt;&lt;TABLE border="1" width="5.1767676767676765%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;cidr&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If cidr.csv is set up with MATCH_TYPE(cidr), the above search will give you&lt;/P&gt;&lt;TABLE border="1" width="57.196969696969695%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;cidr&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;ip&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;match&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;10.110.1.152&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;"No Match"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;10.16.8.11&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;10.16.8.240&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Have you tried?&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2024 05:33:03 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-07-11T05:33:03Z</dc:date>
    <item>
      <title>Need help with a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692906#M235826</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I match the IPs from&amp;nbsp;csv file with the CIDR ranges in another csv? If no CIDR matches, I want to return "NoMatch" and if proper IP and CIDR match then return the CIDR&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the approach below, but I keep getting "No Match" for all entries, even though I have proper CIDR ranges:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"| inputlookup IP_add.csv
| rename "IP Address" as ip
| appendcols
[| inputlookup cidr.csv]
| foreach cidr
[ eval match=if(cidrmatch('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', ip), cidr, "No Match")]"&lt;/LI-CODE&gt;
&lt;P&gt;Note: I can't use join as I don't have IP field or ips in the cidr csv&lt;/P&gt;
&lt;P&gt;any help would be greatly appreciated. Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 17:06:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692906#M235826</guid>
      <dc:creator>satyaallaparthi</dc:creator>
      <dc:date>2024-07-10T17:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692908#M235827</link>
      <description>&lt;P&gt;This may be useful to you:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.2.2/SearchReference/Lookup#2._IPv6_CIDR_match_in_Splunk_Web" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.2.2/SearchReference/Lookup#2._IPv6_CIDR_match_in_Splunk_Web&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 16:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692908#M235827</guid>
      <dc:creator>JohnEGones</dc:creator>
      <dc:date>2024-07-10T16:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692925#M235830</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258618"&gt;@JohnEGones&lt;/a&gt;&amp;nbsp;suggested, cidrmatch is not the answer. &amp;nbsp;Set MATCH_TYPE(cidr) in cidr.csv following that document, then use lookup command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup IP_add.csv
| rename "IP Address" as ip
| lookup cidr.csv cidr as ip output cidr
| eval match=if(isnull(cidr), "No Match", cidr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 19:25:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692925#M235830</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-10T19:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692929#M235831</link>
      <description>&lt;P&gt;Adding to already provided answer, your idea wouldn't work because appendcols adds fields from the appended dataset to the original results row-by-row (in a as-is order). So in your case a first row from the second lookup would "extend" first row of contents of the first lookup, second row would be glued to second row and so on.&lt;/P&gt;&lt;P&gt;Also your "foreach cidr", since you're only specifying a single field would yield the exactly same results as if you simply wrote your eval using "cidr" instead of "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;". And since most probably your cidr and ip fields didn't happen to "join" so that they landed in matching rows, your result was always a no-match.&lt;/P&gt;&lt;P&gt;I suppose you wanted to add a transposed contents of the second lookup to each result of your initial inputlookup search but it doesn't work that way.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 19:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692929#M235831</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-07-10T19:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692950#M235835</link>
      <description>&lt;P&gt;that solution will work when we have a common field in both, but that's the case here&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 00:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692950#M235835</guid>
      <dc:creator>satyaallaparthi</dc:creator>
      <dc:date>2024-07-11T00:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692960#M235839</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;that solution will work when we have a common field in both, but that's the case here&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What do you mean? &amp;nbsp;You don't need "common" field, if by that you mean identical entries. &amp;nbsp;Consider these two:&lt;/P&gt;&lt;P&gt;IP_add.csv&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;ip&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.110.1.152&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.16.8.11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.16.8.240&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;cidr.csv&lt;/P&gt;&lt;TABLE border="1" width="5.1767676767676765%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;cidr&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If cidr.csv is set up with MATCH_TYPE(cidr), the above search will give you&lt;/P&gt;&lt;TABLE border="1" width="57.196969696969695%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;cidr&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;ip&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;match&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;10.110.1.152&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;"No Match"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;10.16.8.11&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="17.2979797979798%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;TD width="18.68686868686869%"&gt;10.16.8.240&lt;/TD&gt;&lt;TD width="21.21212121212121%"&gt;10.16.8.0/24&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Have you tried?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 05:33:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-query/m-p/692960#M235839</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-07-11T05:33:03Z</dc:date>
    </item>
  </channel>
</rss>

