<?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: Why is the wrong value being extracted when using this regular expression? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358410#M105948</link>
    <description>&lt;P&gt;using regex101.com i have the same result as with my regex. The correct value is selected, but when this is applied to transforms.conf , the result value for the field is still"s" . Tested your regex after clearing my test environment data , and i get the same result... the value is "s" for endpoint 1. &lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 14:25:37 GMT</pubDate>
    <dc:creator>andrei1bc</dc:creator>
    <dc:date>2017-03-16T14:25:37Z</dc:date>
    <item>
      <title>Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358407#M105945</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am using a regular expression to extract the word that follows the string result of raw output. For endpoint 1 the captured value is "s"(incorrect) and for endpoint 2 the captured value is "OK" (correct).&lt;/P&gt;

&lt;P&gt;Using Splunk Enterprise 6.5.1 build f74036626f0c, and the regex was generated using RegexBuddy (language PCRE2 10.21 - closest to splunk, and here the correct value is highlighted in both cases). &lt;/P&gt;

&lt;P&gt;My inputs, props, transforms and raw output below. Would like some help on this, as i fail to understand from where "s" is captured.&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[rest://test]
source = test
auth_type = none
endpoint = &lt;A href="http://localhost:8130/test/v1/statuscheck" target="test_blank"&gt;http://localhost:8130/test/v1/statuscheck&lt;/A&gt;
http_method = GET
index = main
index_error_response_codes = 0
polling_interval = 60
request_timeout = 50
response_type = xml
sequential_mode = 0
sourcetype = url
streaming_request = 0

[rest://test2]
source = test2
auth_type = none
endpoint = &lt;A href="http://localhost:8131/test/v1/statuscheck" target="test_blank"&gt;http://localhost:8131/test/v1/statuscheck&lt;/A&gt;
http_method = GET
index = main
index_error_response_codes = 0
polling_interval = 60
request_timeout = 50
response_type = xml
sequential_mode = 0
sourcetype = url
streaming_request = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[url]
category = Custom
pulldown_type = 1
disabled = false
TRANSFORMS-url = url_transformation
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[url_transformation]
REGEX = ^.+&amp;lt;result&amp;gt;(?&amp;lt;url_status&amp;gt;\w+).+
FORMAT = url_status::$1
WRITE_META = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Endpoint 1 raw output :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl &lt;A href="http://localhost:8130/test/v1/statuscheck" target="test_blank"&gt;http://localhost:8130/test/v1/statuscheck&lt;/A&gt;
&amp;lt;status&amp;gt;
        &amp;lt;result&amp;gt;OK&amp;lt;/result&amp;gt;
        &amp;lt;resources/&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Endpoint 2 raw output :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl &lt;A href="http://localhost:8131/test/v1/statuscheck" target="test_blank"&gt;http://localhost:8131/test/v1/statuscheck&lt;/A&gt;
&amp;lt;status&amp;gt;
&amp;lt;result&amp;gt;OK&amp;lt;/result&amp;gt;
&amp;lt;resources&amp;gt;&amp;lt;resource name="..." status="OK" /&amp;gt;&amp;lt;resource name="..." status="OK" /&amp;gt;&amp;lt;/resources&amp;gt;
&amp;lt;/status&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:05:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358407#M105945</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-16T14:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358408#M105946</link>
      <description>&lt;P&gt;try this regex in your transforms.conf&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;REGEX = &amp;lt;result&amp;gt;(?&amp;lt;url_status&amp;gt;\w+).+&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358408#M105946</guid>
      <dc:creator>asimagu</dc:creator>
      <dc:date>2017-03-16T14:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358409#M105947</link>
      <description>&lt;P&gt;using regex101.com , using &lt;CODE&gt;.+&amp;lt;result&amp;gt;(?&amp;lt;url_status&amp;gt;\w+).+&lt;/CODE&gt; seemed to work for both, the carrot at the beginning was throwing something off.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358409#M105947</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-03-16T14:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358410#M105948</link>
      <description>&lt;P&gt;using regex101.com i have the same result as with my regex. The correct value is selected, but when this is applied to transforms.conf , the result value for the field is still"s" . Tested your regex after clearing my test environment data , and i get the same result... the value is "s" for endpoint 1. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358410#M105948</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-16T14:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358411#M105949</link>
      <description>&lt;P&gt;Forgot to mention that I am using Heavy Forwarders and the inputs,props and transforms files sit on the forwarder and not indexer. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358411#M105949</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-16T14:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358412#M105950</link>
      <description>&lt;P&gt;How about this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; REGEX = \&amp;lt;result\&amp;gt;(?&amp;lt;url_status&amp;gt;[^\&amp;lt;]+)\&amp;lt;\/result\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358412#M105950</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-16T14:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358413#M105951</link>
      <description>&lt;P&gt;Works in search , but when put in transforms.conf and  clearing my test environment data ,i get the same result... the value is "s" for endpoint 1. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:02:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358413#M105951</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-16T15:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358414#M105952</link>
      <description>&lt;P&gt;So, you're keeping the configuration on indexer/heavy forwarder and restarting Splunk on that host?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358414#M105952</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-16T15:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358415#M105953</link>
      <description>&lt;P&gt;configuration is kept on heavy forwarder, cleaning data from indexer and restarting indexer to have fresh data.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:20:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358415#M105953</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-16T15:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358416#M105954</link>
      <description>&lt;P&gt;Is this how you are testing?&lt;/P&gt;

&lt;P&gt;1: Remove ALL the existing (bad) data from the indexers by running a search that pulls it in and piping it to the &lt;CODE&gt;delete&lt;/CODE&gt; command on the search head.&lt;BR /&gt;
2: Update your configurations on the Heavy Forwarder and restart splunk there.&lt;BR /&gt;
3: Run a search and be sure that the data is "still gone".&lt;BR /&gt;
4: Forward the data in.&lt;BR /&gt;
5: Run the search again and see new data.&lt;/P&gt;

&lt;P&gt;This is important because the configuration changes only effect NEWLY FORWARDED events.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:36:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358416#M105954</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-16T19:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358417#M105955</link>
      <description>&lt;P&gt;Whenever i clean the indexer of events , i turn off the indexer and clean data. Steps below : &lt;/P&gt;

&lt;P&gt;on indexer :&lt;BR /&gt;
1. splunk stop&lt;BR /&gt;
2. splunk clean eventdata (Yes to clean all indexes)&lt;BR /&gt;
3. splunk start&lt;/P&gt;

&lt;P&gt;on search head&lt;BR /&gt;
1. after indexer comes online&lt;BR /&gt;
index=* OR index=_*  -&amp;gt; 0 events as result&lt;/P&gt;

&lt;P&gt;on forwarder&lt;BR /&gt;
1. splunk restart&lt;/P&gt;

&lt;P&gt;After a few minutes I run my search again and the events are in. The extracted field for endpoint 1 still shows the value for url_status as S .. but if i apply the regex directly in search .. it works.. &lt;/P&gt;

&lt;P&gt;Possible bug ?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:49:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358417#M105955</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-16T19:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358418#M105956</link>
      <description>&lt;P&gt;Unlikely.  More likely it is a rogue configuration that is bypassing/undoing the fixed configuration that you are deploying.  Look everywhere on your indexers and your forwarder for configurations which can create the field called &lt;CODE&gt;url_status&lt;/CODE&gt;.  On *NIX you can do this with this command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;find $SPLUNK_HOME -name "*.conf" -exec grep -l url_status {} \;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also use &lt;CODE&gt;btool&lt;/CODE&gt;.&lt;BR /&gt;
For example, if you have a broken configuration in &lt;CODE&gt;$SPLUNK_HOME/etc/apps/MyApp/local&lt;/CODE&gt; but you are deploying your fixed configuration into &lt;CODE&gt;$SPLUNK_HOME/etc/apps/MyApp/default&lt;/CODE&gt;, then the old/broken/local configuration will be overriding your fixed one.  Something like this has to be happening.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358418#M105956</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-16T19:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358419#M105957</link>
      <description>&lt;P&gt;Followed your recommendation, and nothing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Forwarder : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;test@Endpoint :~&amp;gt; cd /appserver/monitoring/splunk/
test@Endpoint :/appserver/monitoring/splunk&amp;gt; find ./ -name "*.conf" -exec grep -l url_status {} \;             
./etc/apps/url_check/local/transforms.conf

test@Endpoint :/appserver/monitoring/splunk&amp;gt; cat ./etc/apps/url_check/local/transforms.conf
[url_transformation]
REGEX = &amp;lt;result&amp;gt;(?&amp;lt;url_status&amp;gt;\w+).+
FORMAT = url_status::$1
WRITE_META = true

test@Endpoint :/appserver/monitoring/splunk&amp;gt; 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Indexer :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;test@indexer:/appserver/monitoring/splunk&amp;gt; find ./ -name "*.conf" -exec grep -l url_status {} \;
test@indexer:/appserver/monitoring/splunk&amp;gt; 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Search Head :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;test@search:/appserver/monitoring/splunk&amp;gt; find ./ -name "*.conf" -exec grep -l url_status {} \;
test@search:/appserver/monitoring/splunk&amp;gt; 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there any place the transformation process is logged ?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 09:16:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358419#M105957</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-03-17T09:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358420#M105958</link>
      <description>&lt;P&gt;Get rid of this and try again:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; WRITE_META = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 19:04:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358420#M105958</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-17T19:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the wrong value being extracted when using this regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358421#M105959</link>
      <description>&lt;P&gt;Updated forwarder to 6.5.3 and I no longer have this issue.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 15:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-wrong-value-being-extracted-when-using-this-regular/m-p/358421#M105959</guid>
      <dc:creator>andrei1bc</dc:creator>
      <dc:date>2017-04-28T15:00:59Z</dc:date>
    </item>
  </channel>
</rss>

