<?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: Help using lookup tables to select search results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616698#M214327</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just want to share a more robust way of extracting domains, esp if it contains a top level country domain or port.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval input_string="site.taiwan.asus.com.tw"
| append [| makeresults | eval input_string="www.telegraph.co.uk"]
| append [| makeresults | eval input_string="company.splunkcloud.com:8089"]
| rex field=input_string "(?&amp;lt;sld_name_1&amp;gt;[^\.]+\.[^\.]+)$"
| rex field=input_string "(?&amp;lt;sld_name_2&amp;gt;([\w-]+(\.com?\.[a-zA-Z]{2,5}|\.[a-zA-Z]{2,5})))((:\d+)?$)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 14:43:42 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-10-11T14:43:42Z</dc:date>
    <item>
      <title>Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616563#M214289</link>
      <description>&lt;P&gt;I have a lookup table named ics_special_domains that contains this:&lt;/P&gt;
&lt;PRE&gt;domain_name,type&lt;BR /&gt;microsoft.com,microsoft&lt;BR /&gt;*.microsoft.com,microsoft&lt;BR /&gt;google.com,google&lt;BR /&gt;*.google.com,google&lt;BR /&gt;nwngms.com,ot&lt;BR /&gt;*.nwngms.com,ot&lt;BR /&gt;gasco.com,it&lt;BR /&gt;*.gasco.com,it&lt;/PRE&gt;
&lt;P&gt;I'm trying to use this in a search to filter on specific types, but I'm trying a basic search first.&amp;nbsp; This is the most basic search I'm trying:&lt;/P&gt;
&lt;PRE&gt;index=ics_dns ( query_type="A" OR query_type="AAAA" )&lt;BR /&gt;| lookup ics_special_domains domain_name as query{} outputnew type as domain_type&lt;BR /&gt;| where domain_type="microsoft"&lt;/PRE&gt;
&lt;P&gt;It returns this error:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;basic_string::erase: __pos (which is 18446744073709551615) &amp;gt; this-&amp;gt;size() (which is 0)&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;I'd appreciate any help figuring this out.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 19:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616563#M214289</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2022-10-10T19:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616572#M214296</link>
      <description>&lt;P&gt;I think the leading character cannot be wildcard if that field is set up as WILDCARD.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 20:40:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616572#M214296</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-10-10T20:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616573#M214297</link>
      <description>&lt;P&gt;Is there a way I can enter wildcard domains to compare against?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 20:45:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616573#M214297</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2022-10-10T20:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616599#M214304</link>
      <description>&lt;P&gt;Can you explain the use case in which wildcard must be used? &amp;nbsp;If all you want to compare is whether a domain matches, you do not need&amp;nbsp;*.microsoft.com. &amp;nbsp;All you need is a table like&lt;/P&gt;&lt;PRE&gt;domain_name,type&lt;BR /&gt;microsoft.com,microsoft&lt;BR /&gt;google.com,google&lt;BR /&gt;nwngms.com,ot&lt;BR /&gt;gasco.com,it&lt;/PRE&gt;&lt;P&gt;and trim&amp;nbsp;values of query{} down to this level, like&lt;/P&gt;&lt;PRE&gt;index=ics_dns ( query_type="A" OR query_type="AAAA" )&lt;BR /&gt;| eval l2domain = mvmap(query{}, replace(query{}, "([^\.]+\.[^\.]+)$", "\1"))&lt;BR /&gt;| lookup ics_special_domains domain_name as l2domain outputnew type as domain_type&lt;BR /&gt;| where domain_type="microsoft"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The above should work in Splunk 9. &amp;nbsp;In Splunk 8 and below, you can do&lt;/P&gt;&lt;PRE&gt;index=ics_dns ( query_type="A" OR query_type="AAAA" )&lt;BR /&gt;| mvexpand query{}&lt;BR /&gt;| rex field=query{} "(?&amp;lt;l2domain&amp;gt;[^\.]+\.[^\.]+)$"&lt;BR /&gt;| lookup ics_special_domains domain_name as l2domain outputnew type as domain_type&lt;BR /&gt;| where domain_type="microsoft"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 06:10:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616599#M214304</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-10-11T06:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616672#M214318</link>
      <description>&lt;P&gt;Yes, that makes sense.&amp;nbsp; It did just occur to me to trim the query down (except that I was thinking about split() instead of rex).&amp;nbsp; However, your second query still gives me the same error:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;basic_string::erase: __pos (which is 18446744073709551615) &amp;gt; this-&amp;gt;size() (which is 0)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;There must be a problem with my lookup table.&amp;nbsp; I did remove the wildcard lines, and it looks like this now:&lt;/P&gt;&lt;PRE&gt;domain_name,type&lt;BR /&gt;microsoft.com,microsoft&lt;BR /&gt;google.com,google&lt;BR /&gt;nwngms.com,ot&lt;BR /&gt;gasco.com,it&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Oct 2022 13:08:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616672#M214318</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2022-10-11T13:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616676#M214320</link>
      <description>&lt;P&gt;It works now.&amp;nbsp; I had to go back into the lookup definition and remove the WILDCARD match type.&amp;nbsp; I don't understand how to use that match type, but I have my solution now.&amp;nbsp; Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 13:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616676#M214320</guid>
      <dc:creator>ilhwan</dc:creator>
      <dc:date>2022-10-11T13:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help using lookup tables to select search results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616698#M214327</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just want to share a more robust way of extracting domains, esp if it contains a top level country domain or port.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval input_string="site.taiwan.asus.com.tw"
| append [| makeresults | eval input_string="www.telegraph.co.uk"]
| append [| makeresults | eval input_string="company.splunkcloud.com:8089"]
| rex field=input_string "(?&amp;lt;sld_name_1&amp;gt;[^\.]+\.[^\.]+)$"
| rex field=input_string "(?&amp;lt;sld_name_2&amp;gt;([\w-]+(\.com?\.[a-zA-Z]{2,5}|\.[a-zA-Z]{2,5})))((:\d+)?$)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 14:43:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-using-lookup-tables-to-select-search-results/m-p/616698#M214327</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-11T14:43:42Z</dc:date>
    </item>
  </channel>
</rss>

