<?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: How to feed a query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556345#M157985</link>
    <description>&lt;P&gt;Thank you for your quick response!&lt;/P&gt;&lt;P&gt;I do have a couple of fields in the weblogs that may contain the domain or variations of it.&amp;nbsp; As I am creating the CSV I can name that single column whatever I like so that it matches.&amp;nbsp; There are a couple of "unknowns" here that I believe are making this complicated.&amp;nbsp; In my simple query:&lt;/P&gt;&lt;P&gt;index=weblogs somedomain.com | stats count&lt;/P&gt;&lt;P&gt;I am results for *somedomain.com* regardless of the field.&amp;nbsp; I certainly can be more specific and designate a single field to search, but I do need to be able to still retain the wildcard aspect so that "somedomain.com" from the list of domains provided by the CSV also finds "somedomain.com", "&lt;A href="http://www.somedomain.com" target="_blank"&gt;www.somedomain.com&lt;/A&gt;", "video.somedomain.com", etc. from the weblogs.&amp;nbsp; In my past experience, adding an asterisk such as domain="*somedomain.com" significantly impacted the search and processing.&amp;nbsp; "Significantly" = a search similar to what I'm currently using but with an asterisk was 40% complete after two days, but when I ran the same search without the asterisk completed in a couple of minutes.&lt;/P&gt;&lt;P&gt;I really like the simplicity of your suggestion:&lt;/P&gt;&lt;P&gt;index=weblogs [| inputlookup domainlist.csv] | stats count by domain&lt;/P&gt;&lt;P&gt;This is the line of thought I've been working along, but Splunk refuses to produce a count, 0 found.&lt;/P&gt;&lt;P&gt;Though I do not _know_, I _suspect_ that the inputlookup as a subsearch is essentially responding with the entire results/contents, rather than one at a time, iteratively.&amp;nbsp; I spent some time trying to get map or foreach to spit each domain from the CSV to me, one at a time but thus far have been unsuccessful.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Jun 2021 15:52:00 GMT</pubDate>
    <dc:creator>jacques</dc:creator>
    <dc:date>2021-06-18T15:52:00Z</dc:date>
    <item>
      <title>How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556233#M157944</link>
      <description>&lt;P&gt;I am trying to run a simple query, but with a catch.&amp;nbsp; I want to run something like this:&lt;/P&gt;&lt;P&gt;index=weblogs somedomain.com | stats count&lt;/P&gt;&lt;P&gt;I don't want to see all of the the events. I don't want detail. I just want to know how many events make reference to *somedomain.com*.&amp;nbsp; For this specific domain, I'm good, and the above query returns almost instantaneously what I want.&lt;/P&gt;&lt;P&gt;The catch - I now need to perform this simple query several thousand more times for each of the domains on a list, providing the number of events make reference to each domain in the list.&lt;/P&gt;&lt;P&gt;I thought if I spun my list into a CSV, import it and the reference/"feed" the query using something like this:&lt;/P&gt;&lt;P&gt;index=weblogs | inputcsv domainlist.csv | stats count&lt;/P&gt;&lt;P&gt;Or perhaps:&lt;/P&gt;&lt;P&gt;index=weblogs | inputlookup domainlist.csv | stats count&lt;/P&gt;&lt;P&gt;I'd have what I needed, but to no avail.&amp;nbsp; I've tinkered with LOOKUP, MAP, FOREACH and several others.&amp;nbsp; In the end, I feel like I've missed the obvious.&amp;nbsp; I feel like it's the iterative nature of the query that is defeating me.&lt;/P&gt;&lt;P&gt;Thank you in advance for your assistance.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 19:45:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556233#M157944</guid>
      <dc:creator>jacques</dc:creator>
      <dc:date>2021-06-17T19:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556241#M157948</link>
      <description>&lt;P&gt;If you domain is in a field called domain and your csv has a single column called domain you could try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=weblogs [| inputlookup domainlist.csv] | stats count by domain&lt;/LI-CODE&gt;&lt;P&gt;If not, you could extract the domain from your events and search for matches&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=weblogs | &amp;lt;extract domain from events&amp;gt; | search [| inputlookup domainlist.csv] | stats count by domain&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 17 Jun 2021 22:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556241#M157948</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-17T22:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556242#M157949</link>
      <description>&lt;P&gt;Do you have a field that contains the name of the domain or are you searching for that domain anywhere in the raw event data - currently you are just looking for&amp;nbsp;&lt;SPAN&gt;somedomain.com in the raw event.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The obvious solution if there is a field containing the domain is&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count by domainField&lt;/LI-CODE&gt;&lt;P&gt;but you would need to have domainField containing your event field.&lt;/P&gt;&lt;P&gt;Depending on your data, you may be able to extract 'domains' from the data, for example you could rex out what looks like a domain based on the standard domain elements, e.g. something basic as this captures various domains from raw&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?&amp;lt;domainField&amp;gt;\w+\.(com|org|co)\.?(au|uk|fr)?)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and then you could run your stats following the rex and then finally limit the search results to the ones you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 22:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556242#M157949</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-17T22:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556345#M157985</link>
      <description>&lt;P&gt;Thank you for your quick response!&lt;/P&gt;&lt;P&gt;I do have a couple of fields in the weblogs that may contain the domain or variations of it.&amp;nbsp; As I am creating the CSV I can name that single column whatever I like so that it matches.&amp;nbsp; There are a couple of "unknowns" here that I believe are making this complicated.&amp;nbsp; In my simple query:&lt;/P&gt;&lt;P&gt;index=weblogs somedomain.com | stats count&lt;/P&gt;&lt;P&gt;I am results for *somedomain.com* regardless of the field.&amp;nbsp; I certainly can be more specific and designate a single field to search, but I do need to be able to still retain the wildcard aspect so that "somedomain.com" from the list of domains provided by the CSV also finds "somedomain.com", "&lt;A href="http://www.somedomain.com" target="_blank"&gt;www.somedomain.com&lt;/A&gt;", "video.somedomain.com", etc. from the weblogs.&amp;nbsp; In my past experience, adding an asterisk such as domain="*somedomain.com" significantly impacted the search and processing.&amp;nbsp; "Significantly" = a search similar to what I'm currently using but with an asterisk was 40% complete after two days, but when I ran the same search without the asterisk completed in a couple of minutes.&lt;/P&gt;&lt;P&gt;I really like the simplicity of your suggestion:&lt;/P&gt;&lt;P&gt;index=weblogs [| inputlookup domainlist.csv] | stats count by domain&lt;/P&gt;&lt;P&gt;This is the line of thought I've been working along, but Splunk refuses to produce a count, 0 found.&lt;/P&gt;&lt;P&gt;Though I do not _know_, I _suspect_ that the inputlookup as a subsearch is essentially responding with the entire results/contents, rather than one at a time, iteratively.&amp;nbsp; I spent some time trying to get map or foreach to spit each domain from the CSV to me, one at a time but thus far have been unsuccessful.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 15:52:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556345#M157985</guid>
      <dc:creator>jacques</dc:creator>
      <dc:date>2021-06-18T15:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556347#M157986</link>
      <description>&lt;DIV class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Thank you for your quick response!&lt;/P&gt;&lt;P&gt;I do have a couple of fields in the weblogs that may contain the domain or variations of it.&amp;nbsp; As I am creating the CSV I can name that single column whatever I like so that it matches.&amp;nbsp; There are a couple of "unknowns" here that I believe are making this complicated.&amp;nbsp; In my simple query:&lt;/P&gt;&lt;P&gt;index=weblogs somedomain.com | stats count&lt;/P&gt;&lt;P data-unlink="true"&gt;I am searching my results for *somedomain.com* regardless of the field.&amp;nbsp; I certainly can be more specific and designate a single field to search, but I do need to be able to still retain the wildcard aspect so that "somedomain.com" from the list of domains provided by the CSV also finds "somedomain.com", "www.somedomain.com&amp;nbsp;", "video.somedomain.com", etc. from the weblogs.&amp;nbsp; In my past experience, adding an asterisk such as domain="*somedomain.com" significantly impacted the search and processing.&amp;nbsp; "Significantly" = a search similar to what I'm currently using but with an asterisk was 40% complete after two days, but when I ran the same search without the asterisk completed in a couple of minutes.&lt;/P&gt;&lt;P&gt;I am also following up with my Admin to see if there is a means to confirm _which_ field in weblogs is triggering "found" when I execute:&lt;/P&gt;&lt;P&gt;index=weblogs somedomain.com | stats count&lt;/P&gt;&lt;P&gt;I hadn't thought about it but the initial query's speed may likely be due to the request domain being in an indexed field and it might help my response time if I ensure that I use that field to search as opposed to a non-indexed one.&lt;/P&gt;&lt;P&gt;In my attempts to use inputlookup, Splunk refuses to produce a count of hits, 0 found.&lt;/P&gt;&lt;P&gt;Though I do not _know_, I _suspect_ that the inputlookup as a subsearch is essentially responding with the entire results/contents, rather than one at a time, iteratively.&amp;nbsp; I spent some time trying to get map or foreach to spit each domain from the CSV to me, one at a time but thus far have been unsuccessful in producing results.&lt;/P&gt;&lt;P&gt;Thanks again for your suggestion.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Jun 2021 16:01:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556347#M157986</guid>
      <dc:creator>jacques</dc:creator>
      <dc:date>2021-06-18T16:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556349#M157987</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=weblogs [| inputlookup domainlist.csv] | stats count by domain&lt;/LI-CODE&gt;&lt;P&gt;effectively expands to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=weblogs (domain=somedomain.com OR domain=someotherdomain.com) | stats count by domain&lt;/LI-CODE&gt;&lt;P&gt;so you are right, this would not pick up on &lt;A href="http://www.somedomain.com" target="_blank"&gt;www.somedomain.com&lt;/A&gt; (unless that was also in domainlist.csv).&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 16:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556349#M157987</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-18T16:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556434#M158026</link>
      <description>&lt;P&gt;So, assuming you can identify a domain field in your raw data you could do something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt; 
| stats count by domain
| lookup domain_lookup domain output domain as foundDomain
| where !isnull(foundDomain)
| stats sum(count) as count by foundDomain&lt;/LI-CODE&gt;&lt;P&gt;where you have a CSV lookup containing a domain field you are interested in, which includes wildcards, e.g.&lt;/P&gt;&lt;P&gt;*somedomain.com&lt;BR /&gt;*otherdomain.com&lt;BR /&gt;*xyz.domain.com&lt;BR /&gt;*.abc.domain.co.uk&lt;/P&gt;&lt;P&gt;and then you create a lookup definition using the CSV file, with an advanced lookup option Match type set to WILDCARD(domain)&lt;/P&gt;&lt;P&gt;Then if your domain in your data looks like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;www.somedomain.com 
video.somedomain.com
blablabla.otherdomain.com
xyz.domain.com
123.abc.domain.co.uk
456.abc.domain.co.uk
789.abc.domain.co.uk&lt;/LI-CODE&gt;&lt;P data-unlink="true"&gt;you will end up with&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;*somedomain.com 2
*otherdomain.com 1
*xyz.domain.com 1
*.abc.domain.co.uk 3&lt;/LI-CODE&gt;&lt;P&gt;The final stats in the query will sum the results of all the independent found domains into a total for the domain template in the lookup&lt;/P&gt;&lt;P&gt;You could do that several ways - either no need to do the final stats - just show the true found domains, or do this to get the individual counts grouped into the master domain from the lookup.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt; 
| stats count by domain
| lookup domain_lookup domain output domain as foundDomain
| where !isnull(foundDomain)
| stats list(domain) as domains list(count) as counts sum(count) as total by foundDomain&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 00:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556434#M158026</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-21T00:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to feed a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556678#M158101</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; I'm not initially able to get this to work, but feel like it is on the right path.&amp;nbsp; I've a series of errors just using a minimal amount of data (e.g. a couple of domains in the CSV over a 15 minute period).&amp;nbsp; Thank you for bearing with me while I get this sorted.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 12:27:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-feed-a-query/m-p/556678#M158101</guid>
      <dc:creator>jacques</dc:creator>
      <dc:date>2021-06-22T12:27:31Z</dc:date>
    </item>
  </channel>
</rss>

