<?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: Extract only global IP with rex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136875#M37445</link>
    <description>&lt;P&gt;Hi stephanefotso,&lt;BR /&gt;
our web-proxy log is like as folllows,&lt;/P&gt;

&lt;P&gt;[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://www.google.com/" target="_blank"&gt;http://www.google.com/&lt;/A&gt; - DIRECT/173.194.120.67 text/html&lt;BR /&gt;
[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://192.168.200.10/-" target="_blank"&gt;http://192.168.200.10/-&lt;/A&gt; DIRECT/192.168.200.10 text/html&lt;BR /&gt;
[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://10.0.200.10/" target="_blank"&gt;http://10.0.200.10/&lt;/A&gt; - DIRECT/10.200.200.10 text/html&lt;/P&gt;

&lt;P&gt;2 bottom logs are both for access to our intra servers,  want to only pick up the web access to external like google.com.&lt;BR /&gt;
I tried following, but doesnt  work...&lt;BR /&gt;
index=proxy_log | rex field=dhost "(?!^10.\d+.\d+.\d+|^192.168.\d+.\d+")&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 20:08:17 GMT</pubDate>
    <dc:creator>kuga_mbsd</dc:creator>
    <dc:date>2020-09-28T20:08:17Z</dc:date>
    <item>
      <title>Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136873#M37443</link>
      <description>&lt;P&gt;Hi there,&lt;BR /&gt;
I want to extract only global IP addresses of destination from the internet access logs.&lt;BR /&gt;
Our server segments has both 10.0.0.0/8 and 192.168.0.0/16 exist and web-proxy records even from PC to 192.168.0.0/16 and 10.0.0.0/8 servers.&lt;BR /&gt;
I could extract either 10.0.0.0/8 or 192.168.0.0/16 with rex, however cannot get not matching both these private networks. &lt;BR /&gt;
How can I make it? &lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 07:18:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136873#M37443</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-06-05T07:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136874#M37444</link>
      <description>&lt;P&gt;Let's get your sample event, and please can you be more specific on the &lt;STRONG&gt;global Ip&lt;/STRONG&gt; you want to extract?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 08:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136874#M37444</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-05T08:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136875#M37445</link>
      <description>&lt;P&gt;Hi stephanefotso,&lt;BR /&gt;
our web-proxy log is like as folllows,&lt;/P&gt;

&lt;P&gt;[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://www.google.com/" target="_blank"&gt;http://www.google.com/&lt;/A&gt; - DIRECT/173.194.120.67 text/html&lt;BR /&gt;
[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://192.168.200.10/-" target="_blank"&gt;http://192.168.200.10/-&lt;/A&gt; DIRECT/192.168.200.10 text/html&lt;BR /&gt;
[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://10.0.200.10/" target="_blank"&gt;http://10.0.200.10/&lt;/A&gt; - DIRECT/10.200.200.10 text/html&lt;/P&gt;

&lt;P&gt;2 bottom logs are both for access to our intra servers,  want to only pick up the web access to external like google.com.&lt;BR /&gt;
I tried following, but doesnt  work...&lt;BR /&gt;
index=proxy_log | rex field=dhost "(?!^10.\d+.\d+.\d+|^192.168.\d+.\d+")&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:08:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136875#M37445</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2020-09-28T20:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136876#M37446</link>
      <description>&lt;P&gt;oops, escape has gone...&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 08:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136876#M37446</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-06-05T08:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136877#M37447</link>
      <description>&lt;P&gt;If i have understood, you want to extract&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;&lt;A href="http://www.google.com"&gt;www.google.com&lt;/A&gt;&lt;BR /&gt;
192.168.200.10&lt;BR /&gt;
10.0.200.10&lt;/STRONG&gt;&lt;BR /&gt;
and put them in the same field. Isn't it?&lt;BR /&gt;
Also, is &lt;STRONG&gt;dhost&lt;/STRONG&gt; a field in your events? if yes, can you let us see a sample value of that field?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 08:48:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136877#M37447</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-05T08:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136878#M37448</link>
      <description>&lt;P&gt;I want to only pick up &lt;A href="http://www.google.com"&gt;www.google.com&lt;/A&gt; from the sample log since 192.168.&lt;EM&gt;/10.&lt;/EM&gt; are our internal web servers.&lt;BR /&gt;
yes, &lt;STRONG&gt;dhost&lt;/STRONG&gt; is our field which has  destination IP address of www servers:173.194.120.67, 192.168.200.10, and 10.200.200.10.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 08:54:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136878#M37448</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-06-05T08:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136879#M37449</link>
      <description>&lt;P&gt;Given your example from the comments,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://www.google.com/" target="test_blank"&gt;http://www.google.com/&lt;/A&gt; - DIRECT/173.194.120.67 text/html
[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://192.168.200.10/-" target="test_blank"&gt;http://192.168.200.10/-&lt;/A&gt; DIRECT/192.168.200.10 text/html
[05/Jun/2015:14:14:17 +0900] 476 192.168.0.10 TCP_MISS/200 5306 GET &lt;A href="http://10.0.200.10/" target="test_blank"&gt;http://10.0.200.10/&lt;/A&gt; - DIRECT/10.200.200.10 text/html
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have the field &lt;CODE&gt;dhost&lt;/CODE&gt; extracted, you can use the &lt;CODE&gt;eval&lt;/CODE&gt; function &lt;CODE&gt;cidrmatch("X",Y)&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy_log | where NOT (cidrmatch("10.0.0.0/8", dhost) OR cidrmatch("192.168.0.0/16", dhost))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might be able to remove the pipe and the &lt;CODE&gt;where&lt;/CODE&gt; command keyword, I didn't really have data to test that on.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 08:59:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136879#M37449</guid>
      <dc:creator>laserval</dc:creator>
      <dc:date>2015-06-05T08:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136880#M37450</link>
      <description>&lt;P&gt;OK. Means you just want to pick &lt;STRONG&gt;&lt;A href="http://www.google.com"&gt;www.google.com&lt;/A&gt;&lt;/STRONG&gt; . But since &lt;A href="http://www.google.com"&gt;www.google.com&lt;/A&gt; is not one of your &lt;STRONG&gt;dhost&lt;/STRONG&gt; field values you must extract that value from your raw event. Here you go&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy_log | rex field=_raw "http\:\/\/(?&amp;lt;webaccess&amp;gt;\w+\.\w+\.\w+)"|table webaccess
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 09:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136880#M37450</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-05T09:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only global IP with rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136881#M37451</link>
      <description>&lt;P&gt;OMG, it's embarrassing...&lt;BR /&gt;
Yeah, &lt;STRONG&gt;cidrmatch&lt;/STRONG&gt; definitely works in this case!&lt;/P&gt;

&lt;P&gt;Thanks a lot, both  laserval and stephanefotso!!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 09:16:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-only-global-IP-with-rex/m-p/136881#M37451</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-06-05T09:16:41Z</dc:date>
    </item>
  </channel>
</rss>

