<?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 my rex statement unable to extract the field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209567#M61293</link>
    <description>&lt;P&gt;@jsiker here comes Web-cli App &lt;A href="https://splunkbase.splunk.com/app/1607/"&gt;https://splunkbase.splunk.com/app/1607/&lt;/A&gt; to the rescue  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2015 19:41:06 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2015-09-11T19:41:06Z</dc:date>
    <item>
      <title>Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209558#M61284</link>
      <description>&lt;P&gt;I have this rex with an assigned field: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex _raw="(?&amp;lt;total_GC_time&amp;gt;0?.\d+)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm searching lines like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2015-09-10T16:46:31.320-0400: 861067.833: Total time for which application threads were stopped: 0.0010090 seconds 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and I'm trying to capture the 0.0... for all lines.&lt;/P&gt;

&lt;P&gt;The events come up fine, but when I try to table total_GC_time, all the fields are empty. Is it a problem with the regex _raw call?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:11:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209558#M61284</guid>
      <dc:creator>jsiker</dc:creator>
      <dc:date>2020-09-29T07:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209559#M61285</link>
      <description>&lt;P&gt;Hi jsiker,&lt;/P&gt;

&lt;P&gt;try this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex _raw="(?&amp;lt;total_GC_time&amp;gt;0\.\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will capture only the seconds after &lt;CODE&gt;.. threads were stopped:&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 21:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209559#M61285</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-10T21:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209560#M61286</link>
      <description>&lt;P&gt;btw, you can test your regex with Splunk directly like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/bin/splunk cmd pcregextest mregex="(?&amp;lt;total_GC_time&amp;gt;0\.\d+)" test_str="2015-09-10T16:46:31.320-0400: 861067.833: Total time for which application threads were stopped: 0.0010090 seconds"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the result will look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Original Pattern: '(?&amp;lt;total_GC_time&amp;gt;0\.\d+)'
Expanded Pattern: '(?&amp;lt;total_GC_time&amp;gt;0\.\d+)'
Regex compiled successfully. Capture group count = 1. Named capturing groups = 1.
SUCCESS - match against: '2015-09-10T16:46:31.320-0400: 861067.833: Total time for which application threads were stopped: 0.0010090 seconds'

#### Capturing group data ##### 
Group |            Name | Value
--------------------------------------
    1 |   total_GC_time | 0.0010090
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Sep 2015 22:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209560#M61286</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-10T22:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209561#M61287</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "(?&amp;lt;total_GC_time&amp;gt;[0-9\.]+)\s*seconds$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Sep 2015 22:03:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209561#M61287</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-10T22:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209562#M61288</link>
      <description>&lt;P&gt;awesome! thanks, both work. i realize now i hadn't had a pipe b/w the rex and the rest of my search.  great tip for the testing too, didn't know you could do that!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 22:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209562#M61288</guid>
      <dc:creator>jsiker</dc:creator>
      <dc:date>2015-09-10T22:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209563#M61289</link>
      <description>&lt;P&gt;do i do this in the normal search box? i've been unable to get this to work.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 23:09:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209563#M61289</guid>
      <dc:creator>jsiker</dc:creator>
      <dc:date>2015-09-10T23:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209564#M61290</link>
      <description>&lt;P&gt;Login to your Splunk Server OS and go to your Splunk install directory like &lt;CODE&gt;/opt/splunk/bin&lt;/CODE&gt; and run it there&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 23:11:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209564#M61290</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-10T23:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209565#M61291</link>
      <description>&lt;P&gt;haha, if i had access to our Splunk server, life would be grand. sadly i don't. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:00:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209565#M61291</guid>
      <dc:creator>jsiker</dc:creator>
      <dc:date>2015-09-11T19:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209566#M61292</link>
      <description>&lt;P&gt;Similar, but not as good as @MuS's testing method, specially if you don't have server access&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval _raw="2015-09-10T16:46:31.320-0400: 861067.833: Total time for which application threads were stopped: 0.0010090 seconds" | rex "(?&amp;lt;total_GC_time&amp;gt;[0-9\.]+)\s*seconds$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This can run in any splunk instance, and I use this for testing my regex.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:16:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209566#M61292</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-11T19:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209567#M61293</link>
      <description>&lt;P&gt;@jsiker here comes Web-cli App &lt;A href="https://splunkbase.splunk.com/app/1607/"&gt;https://splunkbase.splunk.com/app/1607/&lt;/A&gt; to the rescue  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:41:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209567#M61293</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-11T19:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my rex statement unable to extract the field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209568#M61294</link>
      <description>&lt;P&gt;I always just use &lt;A href="https://regex101.com/"&gt;https://regex101.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Depending on the complexity and variability in the logs I'm trying to extract fields from I might do something like this to get at the data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype = foo | dedup punct | head 10 | table _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Sep 2015 11:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-rex-statement-unable-to-extract-the-field/m-p/209568#M61294</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-09-12T11:26:52Z</dc:date>
    </item>
  </channel>
</rss>

