<?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 value until specified char &amp; in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298871#M93722</link>
    <description>&lt;P&gt;Try using: &lt;CODE&gt;rex field=_raw "pyActivity=(?&amp;lt;pyActivity&amp;gt;.+?)&amp;amp;"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This will match as few characters as possible up to the first ampersand.  The question mark after the plus sign is what makes this happen.  You also need to name the field in the extraction, which is the &lt;CODE&gt;?&amp;lt;pyActivity&amp;gt;&lt;/CODE&gt; portion of the regex.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2017 02:44:11 GMT</pubDate>
    <dc:creator>mtulett_splunk</dc:creator>
    <dc:date>2017-11-22T02:44:11Z</dc:date>
    <item>
      <title>Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298861#M93712</link>
      <description>&lt;P&gt;I want to extract value until the first occurrence of char &amp;amp; &lt;/P&gt;

&lt;P&gt;My log :&lt;/P&gt;

&lt;P&gt;?pyActivity=FinishAssig&amp;amp;pzPrimaryPageName=pyWorkPage&amp;amp;pzTransactionId=xxxxx&amp;amp;pzFromFrame=pyWorkPage HTTP/1.1" 200 1383&lt;/P&gt;

&lt;P&gt;?pyActivity=Sh-Harness&amp;amp;Purpose=Perform&amp;amp;SkipFrame=true&amp;amp;TaskIndex=1&amp;amp;HarnessMode=ACTION&amp;amp;TaskValue=CAIXXXr_____CA&amp;amp;TaskHTML=CAXXX&amp;amp;ReadOnly=-1&amp;amp;FrameName=pyWorkPage&amp;amp;pzPrimaryPageName=pyWorkPage HTTP/1.1" 200 14547&lt;/P&gt;

&lt;P&gt;?pyActivity=Data-Por.Get&amp;amp;IsBMLogin=true&amp;amp;inStandardsMode=false&amp;amp;AJAXTrackID=1&amp;amp;pzHarnessID=HIDXXXXHTTP/1.1" 200 10&lt;/P&gt;

&lt;P&gt;expected output:&lt;/P&gt;

&lt;P&gt;FinishAssig&lt;BR /&gt;
Sh-Harness&lt;BR /&gt;
Data-Por.Get&lt;/P&gt;

&lt;P&gt;I tried below but it dint work, it will extract values until last occurance of char &amp;amp;&lt;BR /&gt;
rex field=_raw "\?pyActivity=(?.+)&amp;amp;" &lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:11:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298861#M93712</guid>
      <dc:creator>saifullakhalid</dc:creator>
      <dc:date>2017-11-20T20:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298862#M93713</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rex field=_raw "\?pyActivity=([^&amp;amp;]+)&amp;amp;"&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:15:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298862#M93713</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-20T20:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298863#M93714</link>
      <description>&lt;P&gt;can you please modify your post and use the &lt;CODE&gt;code&lt;/CODE&gt; function (mark the text and press either CTRL-K or the &lt;CODE&gt;101010&lt;/CODE&gt; icon) this helps in keeping the log and the regex &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:17:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298863#M93714</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-11-20T20:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298864#M93715</link>
      <description>&lt;P&gt;I tried this it worked, but if you have other options, please suggest.&lt;/P&gt;

&lt;P&gt;rex field=_raw "\?pyActivity=(?\w+)&amp;amp;" &lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 20:40:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298864#M93715</guid>
      <dc:creator>saifullakhalid</dc:creator>
      <dc:date>2017-11-20T20:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298865#M93716</link>
      <description>&lt;P&gt;Did the regex I suggested below work for you? If yours works better, list it as an answer and accept it! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 21:10:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298865#M93716</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-11-20T21:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298866#M93717</link>
      <description>&lt;P&gt;Ideally Splunk should extract key value pair on its own from your _raw data provided &lt;CODE&gt;KV_MODE=none&lt;/CODE&gt; has not been set explicitly in props.conf. Have you run the search in &lt;CODE&gt;SMART&lt;/CODE&gt; or &lt;CODE&gt;VERBOSE&lt;/CODE&gt; mode to check Interesting Fileds list to confirm whether Search Time Field Discovery is working as expected or not?&lt;/P&gt;

&lt;P&gt;During search time you can also do this via &lt;CODE&gt;KV&lt;/CODE&gt; command or &lt;CODE&gt;extract command by passing your&lt;/CODE&gt;kvdelim&lt;CODE&gt;and&lt;/CODE&gt;pairdelim&lt;CODE&gt;(besides the&lt;/CODE&gt;rex&lt;CODE&gt;command which is already shared). Following are two run anywhere searches based on your data (PS: Commands till&lt;/CODE&gt;| rename` are used to mock the sample data provided in the question. You can add the KV or extract command directly after your base search filter :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval data="?pyActivity=FinishAssig&amp;amp;pzPrimaryPageName=pyWorkPage&amp;amp;pzTransactionId=xxxxx&amp;amp;pzFromFrame=pyWorkPage HTTP/1.1\" 200 1383;
?pyActivity=Sh-Harness&amp;amp;Purpose=Perform&amp;amp;SkipFrame=true&amp;amp;TaskIndex=1&amp;amp;HarnessMode=ACTION&amp;amp;TaskValue=CAIXXXr_____CA&amp;amp;TaskHTML=CAXXXℜadOnly=-1&amp;amp;FrameName=pyWorkPage&amp;amp;pzPrimaryPageName=pyWorkPage HTTP/1.1\" 200 14547;
?pyActivity=Data-Por.Get&amp;amp;IsBMLogin=true&amp;amp;StandardsMode=false&amp;amp;AJAXTrackID=1&amp;amp;pzHarnessID=HIDXXXXHTTP/1.1\" 200 10"
|  makemv data delim=";"
|  mvexpand data
|  rename data as _raw
|  KV
|  table * _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval data="?pyActivity=FinishAssig&amp;amp;pzPrimaryPageName=pyWorkPage&amp;amp;pzTransactionId=xxxxx&amp;amp;pzFromFrame=pyWorkPage HTTP/1.1\" 200 1383;
?pyActivity=Sh-Harness&amp;amp;Purpose=Perform&amp;amp;SkipFrame=true&amp;amp;TaskIndex=1&amp;amp;HarnessMode=ACTION&amp;amp;TaskValue=CAIXXXr_____CA&amp;amp;TaskHTML=CAXXXℜadOnly=-1&amp;amp;FrameName=pyWorkPage&amp;amp;pzPrimaryPageName=pyWorkPage HTTP/1.1\" 200 14547;
?pyActivity=Data-Por.Get&amp;amp;IsBMLogin=true&amp;amp;StandardsMode=false&amp;amp;AJAXTrackID=1&amp;amp;pzHarnessID=HIDXXXXHTTP/1.1\" 200 10"
|  makemv data delim=";"
|  mvexpand data
|  rename data as _raw
|  extract kvdelim="=" pairdelim="&amp;amp;amp;"
|  table * _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:54:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298866#M93717</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T16:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298867#M93718</link>
      <description>&lt;P&gt;No it dint work I got this error&lt;BR /&gt;
The search job has failed due to an error. You may be able view the job in the Job Inspector.&lt;BR /&gt;
index="clean" | rex field=_raw "\?pyActivity=([^&amp;amp;]+)&amp;amp;"&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 15:19:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298867#M93718</guid>
      <dc:creator>saifullakhalid</dc:creator>
      <dc:date>2017-11-21T15:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298868#M93719</link>
      <description>&lt;P&gt;It did not worked here is the query I am running on search &lt;/P&gt;

&lt;P&gt;index="clean" | makeresults |  eval data="?pyActivity=XXXX-Energy.XXXX&amp;amp;pyPrimaryPageName=pyWorkPage HTTP/1.1" 200 23067  |  makemv data delim=";"&lt;BR /&gt;
|  mvexpand data&lt;BR /&gt;
|  rename data as _raw&lt;BR /&gt;
 |  extract kvdelim="=" pairdelim="&amp;amp;"&lt;BR /&gt;
|  table * _raw&lt;/P&gt;

&lt;P&gt;Error:&lt;BR /&gt;
The search job has failed due to an error. You may be able view the job in the Job Inspector.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 15:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298868#M93719</guid>
      <dc:creator>saifullakhalid</dc:creator>
      <dc:date>2017-11-21T15:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298869#M93720</link>
      <description>&lt;P&gt;This works for me &lt;/P&gt;

&lt;P&gt;index="prod_clean" | rex field=_raw "\?pyActivity=(?([^&amp;amp;]+))" | stats count AS "Count" by PA | table "PA" "Count"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:54:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298869#M93720</guid>
      <dc:creator>saifullakhalid</dc:creator>
      <dc:date>2020-09-29T16:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298870#M93721</link>
      <description>&lt;P&gt;As stated commands till rename were just to mock sample data for testing. After your base i.e. index=clean next command should be extract.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="clean"
| extract kvdelim="=" pairdelim="&amp;amp;"
| table * _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Ideally you should add specific &lt;CODE&gt;sourcetype="&amp;lt;yourSourceTypeNameGoesHere&amp;gt;"&lt;/CODE&gt; to your base search in case your index clean is storing multiple sourcetypes. For optimized query base search should have as many filters as possible.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 01:30:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298870#M93721</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-22T01:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298871#M93722</link>
      <description>&lt;P&gt;Try using: &lt;CODE&gt;rex field=_raw "pyActivity=(?&amp;lt;pyActivity&amp;gt;.+?)&amp;amp;"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This will match as few characters as possible up to the first ampersand.  The question mark after the plus sign is what makes this happen.  You also need to name the field in the extraction, which is the &lt;CODE&gt;?&amp;lt;pyActivity&amp;gt;&lt;/CODE&gt; portion of the regex.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 02:44:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298871#M93722</guid>
      <dc:creator>mtulett_splunk</dc:creator>
      <dc:date>2017-11-22T02:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value until specified char &amp;</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298872#M93723</link>
      <description>&lt;P&gt;@saifullakhalid, can you please confim whether it worked or not?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 04:14:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-value-until-specified-char/m-p/298872#M93723</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-24T04:14:21Z</dc:date>
    </item>
  </channel>
</rss>

