<?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: How to use rex command to extract value from the end of an event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206945#M60300</link>
    <description>&lt;P&gt;I think the structure of your query is fine - your regex just doesn't quite work. The first one you tried is looking for a string of digits, the second one a string of word characters. Neither of these look for spaces so if you are trying to capture a string which contains spaces you will need to add this into your regex as well. So you could use something like this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 | rex "STRING: (?&amp;lt;Sync_Status&amp;gt;[\w\s]+)$" | table Sync_Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, you could open your regex up further, in case other characters might appear in the string, by using .* like this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 | rex "STRING: (?&amp;lt;Sync_Status&amp;gt;.*)$" | table Sync_Status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Sep 2016 23:15:41 GMT</pubDate>
    <dc:creator>lquinn</dc:creator>
    <dc:date>2016-09-22T23:15:41Z</dc:date>
    <item>
      <title>How to use rex command to extract value from the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206943#M60298</link>
      <description>&lt;P&gt;I know this type of question has been asked many times before, but I haven't been able to get results from using &lt;CODE&gt;REX&lt;/CODE&gt;.  Time to ask an expert.&lt;/P&gt;

&lt;P&gt;Here's a typical event from a search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;9/22/16
4:55:03.000 PM  

2016-09-22 20:55:03+00:00 server.domain.com F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 = STRING: All devices in the device group are in sync

host = server  
 source = /data/snmp/team_metrics_f5/teamMetricsF5__2016-09-22__server.log  
 sourcetype =team_metrics_snmp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to capture the value after &lt;CODE&gt;STRING: "; e.g "All devices in the device group are in sync&lt;/CODE&gt;.  This won't always be the value of course.&lt;/P&gt;

&lt;P&gt;Here's the search string I was toying with that yielded 0 results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 | rex "STRING: (?&amp;lt;\Sync_Status&amp;gt;\d+)$" | table Sync_Status
index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 | rex "STRING: (?"&amp;lt;\sync_status&amp;gt;\w+)$" | table Sync_Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I couldn't figure out how to get the "&amp;lt;" to show up, so ignore the "\" in the field name&lt;/P&gt;

&lt;P&gt;Thanks everyone!&lt;/P&gt;

&lt;P&gt;--Jarred&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 22:03:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206943#M60298</guid>
      <dc:creator>jambraun</dc:creator>
      <dc:date>2016-09-22T22:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract value from the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206944#M60299</link>
      <description>&lt;P&gt;Hi jambraun,&lt;/P&gt;

&lt;P&gt;your regex either matches only number or any word character. So by changing it into this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 
| rex "STRING: (?&amp;lt;Sync_Status&amp;gt;[^$]+?)$" 
| table Sync_Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you should be able to get everything after &lt;CODE&gt;STRING&lt;/CODE&gt; until the end of line. Tested and working on regex101.com&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 23:14:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206944#M60299</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-09-22T23:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract value from the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206945#M60300</link>
      <description>&lt;P&gt;I think the structure of your query is fine - your regex just doesn't quite work. The first one you tried is looking for a string of digits, the second one a string of word characters. Neither of these look for spaces so if you are trying to capture a string which contains spaces you will need to add this into your regex as well. So you could use something like this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 | rex "STRING: (?&amp;lt;Sync_Status&amp;gt;[\w\s]+)$" | table Sync_Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, you could open your regex up further, in case other characters might appear in the string, by using .* like this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=team_f5_metrics F5-BIGIP-SYSTEM-MIB::sysCmSyncStatusSummary.0 | rex "STRING: (?&amp;lt;Sync_Status&amp;gt;.*)$" | table Sync_Status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 23:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206945#M60300</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2016-09-22T23:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract value from the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206946#M60301</link>
      <description>&lt;P&gt;Brilliant.  Thank you!  I'm still learning syntax.  I know there are about 10 different ways to accomplish this but I particularly like the catch all *.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 00:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206946#M60301</guid>
      <dc:creator>jambraun</dc:creator>
      <dc:date>2016-09-23T00:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract value from the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206947#M60302</link>
      <description>&lt;P&gt;Works as well &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  Thank you for the example.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 00:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-value-from-the-end-of-an-event/m-p/206947#M60302</guid>
      <dc:creator>jambraun</dc:creator>
      <dc:date>2016-09-23T00:03:11Z</dc:date>
    </item>
  </channel>
</rss>

