<?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: I failed to get parameter value from Splunk regex query result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38010#M178682</link>
    <description>&lt;P&gt;Since you're building up a host:: tag based upon the matches from the REGEX, I nominally thought of that as "fielda=host" and "fieldb=domain".  Based upon that, I wrote up this tiny sample:&lt;/P&gt;

&lt;PRE&gt;
Mar 20 22:03:49.335 [RATE] host="bogfly"
Mar 21 10:03:19.335 [RATE] host="wibblenog" domain="bar.com"
&lt;/PRE&gt;

&lt;P&gt;I then used this regex to capture appropriately:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host="(?&amp;lt;AAA&amp;gt;[^"]*)".*(domain="(?&amp;lt;BBB&amp;gt;[^"]*)")?"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The BBB value is now in $3.  The whole match for fieldb (in this case, "domain") is now optional.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Apr 2012 18:45:16 GMT</pubDate>
    <dc:creator>sowings</dc:creator>
    <dc:date>2012-04-30T18:45:16Z</dc:date>
    <item>
      <title>I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38007#M178679</link>
      <description>&lt;P&gt;Per this document in splunk (&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/overridedefaulthostassignments"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Data/overridedefaulthostassignments&lt;/A&gt;), i'd like to change value of a default field, "host" during index time.&lt;/P&gt;

&lt;P&gt;There are two fields, fielda="vala" and fieldb="valb" from log event data I need to refer to.&lt;BR /&gt;
And format of new host value is FORMAT = "host::$1.$2".&lt;/P&gt;

&lt;P&gt;I worte 3 regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = fielda="(?P&amp;lt;AAA&amp;gt;[^"]*)"|fieldb="(?P&amp;lt;BBB&amp;gt;[^"]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;$2 is always "" and host is set to 'vala.'.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = fielda="(?P&amp;lt;AAA&amp;gt;[^"]*)".*(fieldb="(?P&amp;lt;BBB&amp;gt;[^"]*)")?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;$2 is always "" and host is set to 'vala.'.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = fielda="(?P&amp;lt;AAA&amp;gt;[^"]*)".*fieldb="(?P&amp;lt;BBB&amp;gt;[^"]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got expected value, "vala.valb".&lt;/P&gt;

&lt;P&gt;In summary, splunk regex performs non-greedy matching. How can I match all paths and get $2 filled?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Kevin&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 05:41:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38007#M178679</guid>
      <dc:creator>splunkusera</dc:creator>
      <dc:date>2012-04-27T05:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38008#M178680</link>
      <description>&lt;P&gt;It's not performing non-greedy matching, but it's true that once a complete match is identified it stops. So if you have an OR type regex with (match1|match2) it will indeed not match match2 if it's already found match1. This is not something Splunk specific really.&lt;/P&gt;

&lt;P&gt;What's the problem with your third regex that makes you unable to use that? It looks pretty much like what I had suggested if you hadn't already created the correct regex yourself. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
If the issue is that fieldb can occur before fielda, just write a regex to cover that case as well.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 06:01:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38008#M178680</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-27T06:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38009#M178681</link>
      <description>&lt;P&gt;Thank you for your kindly help first. The problem for me is there might be only a fielda in log event without fieldb. So, I can not use regex 3 and we have order assumption for regex 2. The best way for me to use is regex 1. &lt;/P&gt;

&lt;P&gt;Can we specific some option to perform a full match?I use RegexBuddy to test regex1 and it can highlight all result.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Apr 2012 02:45:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38009#M178681</guid>
      <dc:creator>splunkusera</dc:creator>
      <dc:date>2012-04-28T02:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38010#M178682</link>
      <description>&lt;P&gt;Since you're building up a host:: tag based upon the matches from the REGEX, I nominally thought of that as "fielda=host" and "fieldb=domain".  Based upon that, I wrote up this tiny sample:&lt;/P&gt;

&lt;PRE&gt;
Mar 20 22:03:49.335 [RATE] host="bogfly"
Mar 21 10:03:19.335 [RATE] host="wibblenog" domain="bar.com"
&lt;/PRE&gt;

&lt;P&gt;I then used this regex to capture appropriately:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host="(?&amp;lt;AAA&amp;gt;[^"]*)".*(domain="(?&amp;lt;BBB&amp;gt;[^"]*)")?"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The BBB value is now in $3.  The whole match for fieldb (in this case, "domain") is now optional.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2012 18:45:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38010#M178682</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2012-04-30T18:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38011#M178683</link>
      <description>&lt;P&gt;Still failed:-). Is there anything wrong with my configuration?&lt;/P&gt;

&lt;P&gt;In props.conf I add following section.&lt;BR /&gt;
[HostRewrite]&lt;BR /&gt;
SHOULD_LINEMERGE = false&lt;BR /&gt;
TRANSFORMS-ZYHostTrans = ZYHostTrans&lt;BR /&gt;
NO_BINARY_CHECK = 1&lt;BR /&gt;
pulldown_type = 1&lt;/P&gt;

&lt;P&gt;In transforms.conf I add following section:&lt;BR /&gt;
[ZYHostTrans]&lt;BR /&gt;
REGEX = host="(?&lt;AAA&gt;[^"]&lt;EM&gt;)".&lt;/EM&gt;(domain="(?&lt;BBB&gt;[^"]*)")?"&lt;BR /&gt;
FORMAT = host::$1.$3&lt;BR /&gt;
DEST_KEY = MetaData:Host&lt;/BBB&gt;&lt;/AAA&gt;&lt;/P&gt;

&lt;P&gt;My log content is as following:&lt;BR /&gt;
Mar 20 22:03:49.335 [RATE] host="bogfly"&lt;BR /&gt;
Mar 21 10:03:19.335 [RATE] host="wibblenog" domain="bar.com"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38011#M178683</guid>
      <dc:creator>splunkusera</dc:creator>
      <dc:date>2020-09-28T11:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38012#M178684</link>
      <description>&lt;P&gt;I got two host values.&lt;BR /&gt;
One is my pc hostname which is for the first event.&lt;BR /&gt;
The other is "wibblenog." which is for the second one.&lt;BR /&gt;
BTW, I test it in splunk 4.3.1 evaluation version in windows 7.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2012 03:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38012#M178684</guid>
      <dc:creator>splunkusera</dc:creator>
      <dc:date>2012-05-02T03:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: I failed to get parameter value from Splunk regex query result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38013#M178685</link>
      <description>&lt;P&gt;We finally resolve the issue with another regular expression. The expression is &lt;BR /&gt;
  host="(?&lt;AAA&gt;[^"]&lt;EM&gt;)".*domain="(?&lt;BBB&gt;[^"]&lt;/BBB&gt;&lt;/EM&gt;)"|host=(?&lt;AAA&gt;[^"]*)"&lt;/AAA&gt;&lt;/AAA&gt;&lt;/P&gt;

&lt;P&gt;The reason we can match is for NFA engine Splunk uses, we will match alternatives one by one if there are multiple alternatives. That is it tries to match first alternative first and then second with order.&lt;/P&gt;

&lt;P&gt;Thanks a lot for all your help, Splunk guys.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:48:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/I-failed-to-get-parameter-value-from-Splunk-regex-query-result/m-p/38013#M178685</guid>
      <dc:creator>splunkusera</dc:creator>
      <dc:date>2020-09-28T11:48:34Z</dc:date>
    </item>
  </channel>
</rss>

