<?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 Problems Evaluating Field After Rex Extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40855#M9448</link>
    <description>&lt;P&gt;I'm trying to evaluate a field after it is extracted at search time using rex. Unfortunately it is failing. An example query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" | dedup _raw | rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" | ip != 10.*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results in an error message: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Search operation 'ip' is unknown. You&lt;BR /&gt;
might not have permission to run this&lt;BR /&gt;
operation.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I know IP field is being discovered as the following query works: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" | dedup _raw | rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" | stats values(netid), dc(netid), values(host) by ip | RENAME dc(netid) as netid_count | WHERE netid_count &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'm hoping to do is filter based on IP addresses. I've also tried adding a &lt;CODE&gt;WHERE&lt;/CODE&gt; clause but that didn't work either. Help would be appreciated. &lt;/P&gt;</description>
    <pubDate>Wed, 28 Dec 2011 05:25:20 GMT</pubDate>
    <dc:creator>mwollenweber</dc:creator>
    <dc:date>2011-12-28T05:25:20Z</dc:date>
    <item>
      <title>Problems Evaluating Field After Rex Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40855#M9448</link>
      <description>&lt;P&gt;I'm trying to evaluate a field after it is extracted at search time using rex. Unfortunately it is failing. An example query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" | dedup _raw | rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" | ip != 10.*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results in an error message: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Search operation 'ip' is unknown. You&lt;BR /&gt;
might not have permission to run this&lt;BR /&gt;
operation.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I know IP field is being discovered as the following query works: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" | dedup _raw | rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" | stats values(netid), dc(netid), values(host) by ip | RENAME dc(netid) as netid_count | WHERE netid_count &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'm hoping to do is filter based on IP addresses. I've also tried adding a &lt;CODE&gt;WHERE&lt;/CODE&gt; clause but that didn't work either. Help would be appreciated. &lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2011 05:25:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40855#M9448</guid>
      <dc:creator>mwollenweber</dc:creator>
      <dc:date>2011-12-28T05:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problems Evaluating Field After Rex Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40856#M9449</link>
      <description>&lt;P&gt;The first thing after a pipe should be a command, and &lt;CODE&gt;ip&lt;/CODE&gt; is not a command.  Without seeing your search I would say that &lt;CODE&gt;where&lt;/CODE&gt; should have worked.  But we'll try something else instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" 
| dedup _raw 
| rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" 
| search ip != 10.*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternately, this is a good place for the &lt;CODE&gt;cidrmatch&lt;/CODE&gt; function which is part of the &lt;CODE&gt;where&lt;/CODE&gt; command.  So, something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" 
| dedup _raw 
| rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" 
| where cidrmatch("10.0.0.0/8",ip)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Dec 2011 05:39:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40856#M9449</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-12-28T05:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problems Evaluating Field After Rex Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40857#M9450</link>
      <description>&lt;P&gt;Excellent, your where cidrmatch solution works. Oddly enough&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" 
| dedup _raw 
| rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" 
| where ip != "10.*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;evaluates correctly but doesn't appropriately filter but &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sslvpn* "Session started" 
| dedup _raw 
| rex field=_raw "\[(?&amp;lt;ip&amp;gt;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)\]\ (?&amp;lt;netid&amp;gt;.*)\(" 
| where ip != 10.*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is malformed with error: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'where' command: The expression is malformed. The factor is missing.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;ip&lt;/CODE&gt; has a &lt;CODE&gt;string&lt;/CODE&gt; as a type, so I'm not sure why the two options above fail, but your approach works. Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2011 06:01:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problems-Evaluating-Field-After-Rex-Extraction/m-p/40857#M9450</guid>
      <dc:creator>mwollenweber</dc:creator>
      <dc:date>2011-12-28T06:01:44Z</dc:date>
    </item>
  </channel>
</rss>

