<?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 modify my search to find IP addresses that hit exactly one URL? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216226#M63407</link>
    <description>&lt;P&gt;maybe something like this?&lt;BR /&gt;
but, do you really need the regex?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=weblogs
request="GET /url_a/*"
| regex request="^GET /url_a/([0-9a-z].*)? HTTP"
| stats values(request) as requests by ip
| search requests="GET /url_a/ HTTP*"
| sort ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Sep 2016 20:15:04 GMT</pubDate>
    <dc:creator>mhpark</dc:creator>
    <dc:date>2016-09-28T20:15:04Z</dc:date>
    <item>
      <title>How to modify my search to find IP addresses that hit exactly one URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216225#M63406</link>
      <description>&lt;P&gt;I'm trying to find IP addresses that hit a specific url and no other. I tried to use &lt;CODE&gt;set diff&lt;/CODE&gt; but it's not returning results I expect.&lt;/P&gt;

&lt;P&gt;If this search gives the IP addresses of everyone who hit url_a, let's say this returns 447 results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=weblogs request="GET /url_a/ HTTP*" | dedup ip | table ip | sort ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this request gives the IP addresses of everyone who hit a url underneath there, let's say this returns 314 results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=weblogs | regex request="^GET /url_a/[0-9a-z].* HTTP.*" | dedup ip | table ip | sort ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to find the list of IPs in the first list that are not in the second. &lt;CODE&gt;set diff&lt;/CODE&gt; will also return items in the second search that aren't in the first, which is not what I want.&lt;/P&gt;

&lt;P&gt;The other thing I tried was a subsearch like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=weblogs request="GET /url_a/ HTTP*"  NOT [ search sourcetype=weblogs  | regex request="^GET /url_a/[0-9a-z].* HTTP.*" | dedup ip | table ip | sort ip] | dedup ip | table ip | sort ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this returns entries that are also in the second search, so it cannot be correct. Does anyone know of an effective way to do this?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 18:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216225#M63406</guid>
      <dc:creator>sfrazer</dc:creator>
      <dc:date>2016-09-28T18:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to find IP addresses that hit exactly one URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216226#M63407</link>
      <description>&lt;P&gt;maybe something like this?&lt;BR /&gt;
but, do you really need the regex?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=weblogs
request="GET /url_a/*"
| regex request="^GET /url_a/([0-9a-z].*)? HTTP"
| stats values(request) as requests by ip
| search requests="GET /url_a/ HTTP*"
| sort ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2016 20:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216226#M63407</guid>
      <dc:creator>mhpark</dc:creator>
      <dc:date>2016-09-28T20:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to find IP addresses that hit exactly one URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216227#M63408</link>
      <description>&lt;P&gt;I'm using the regex because &lt;CODE&gt;request="GET /url_a/*&lt;/CODE&gt; will include both the following urls:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;GET /url_a/
GET /url_a/url_b/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and I only want it to return the second of those two entries. &lt;CODE&gt;url_b&lt;/CODE&gt; in this case could be one of a number of urls that start with a-z or 0-9&lt;/P&gt;

&lt;P&gt;Your search is getting me closer. The stats values() piece seems to make a collection of urls for each IP, correct? The issue is that I'm still getting results that have multiple urls in their collection something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ip  requests
1.1.1.1 
    GET /url_a/ HTTP/1.1
    GET /url_a/ad/ HTTP/1.1
    GET /url_a/do/ HTTP/1.1
    GET /url_a/ho/ HTTP/1.1
    GET /url_a/ju/ HTTP/1.1
    GET /url_a/of/ HTTP/1.1
1.1.1.2 
    GET /url_a/ HTTP/1.1
1.1.1.3 
    GET /url_a/ HTTP/1.1
    GET /url_a/di/ HTTP/1.1
1.1.1.4 
    GET /url_a/ HTTP/1.1
1.1.1.5 
    GET /url_a/ HTTP/1.1
    GET /url_a/al/ HTTP/1.1
    GET /url_a/ba/ HTTP/1.1
    GET /url_a/bu/ HTTP/1.1
    GET /url_a/gr/ HTTP/1.1
    GET /url_a/wh/ HTTP/1.1
1.1.1.6 
    GET /url_a/ HTTP/1.1
1.1.1.7 
    GET /url_a/ HTTP/1.0
    GET /url_a/bl/ HTTP/1.0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Out of those results I really only want 1.1.1.2, 1.1.1.4 and 1.1.1.6&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 21:27:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216227#M63408</guid>
      <dc:creator>sfrazer</dc:creator>
      <dc:date>2016-09-28T21:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to find IP addresses that hit exactly one URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216228#M63409</link>
      <description>&lt;P&gt;Aha, this helped me. And you're correct that the regex isn't needed in the code snippet you gave, but I did need it to do what I wanted. Here's the final form:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=weblogs
 request="GET /url_a/*"
 | stats values(request) as requests by ip
 | search requests="GET /url_a/ HTTP*" | regex requests!="^GET /url_a/[0-9a-z]"
 | sort ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 21:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216228#M63409</guid>
      <dc:creator>sfrazer</dc:creator>
      <dc:date>2016-09-28T21:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my search to find IP addresses that hit exactly one URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216229#M63410</link>
      <description>&lt;P&gt;You might rather go like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search requests="GET /url_a/ HTTP*" and mvcount(requests) == 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cause regex costs a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 13:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-search-to-find-IP-addresses-that-hit-exactly/m-p/216229#M63410</guid>
      <dc:creator>mhpark</dc:creator>
      <dc:date>2016-09-29T13:43:54Z</dc:date>
    </item>
  </channel>
</rss>

