<?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 Trouble with REX command on a multi-line event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331386#M174922</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;
I'm running a streamstats command that prints out a series of previously-searched events. There are often more than one "ERROR" events within each group. As such, I want to rex the entire ERROR message (composed of multiple lines). Below is an example ERROR event (in &lt;STRONG&gt;BOLD&lt;/STRONG&gt;).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2017-03-08 10:34:34,067 [ WARN] {Application Queue} (com.iba.tcs.beam.bds.devices.impl.gateway.rpc.ScanningControllerProxy) - ScanningController failure: NECU Transitioned to Error State NECU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 FCU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 RCU Error: [0x1] Threshold Violation : Timeslice: 162 Submap: 83 (X_VOLT_SEC_FB: -1.858963 V MapThresholdLow: -6.005e-02 MapThresholdHigh: 4.256e-01) SGCU Error: [0x10] _FilteringAbsolute : Timeslice: 159 Submap: 83 (MIN_CHARGE_PRIM: 6.159e-10 C AbsoluteThresholdLow: 7.119e-10 AbsoluteThresholdHigh: 7.569e-10)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;As you can see, there are multiple lines for a single timestamp. I want to rex everything after the "ScanningController failure:" string. So the result would simply look like this:&lt;/P&gt;

&lt;P&gt;NECU Transitioned to Error State NECU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 FCU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 RCU Error: [0x1] Threshold Violation : Timeslice: 162 Submap: 83 (X_VOLT_SEC_FB: -1.858963 V MapThresholdLow: -6.005e-02 MapThresholdHigh: 4.256e-01) SGCU Error: [0x10] _FilteringAbsolute : Timeslice: 159 Submap: 83 (MIN_CHARGE_PRIM: 6.159e-10 C AbsoluteThresholdLow: 7.119e-10 AbsoluteThresholdHigh: 7.569e-10)&lt;/P&gt;

&lt;P&gt;How do I do this? I tried the following but it does not work: | rex "Transitioned to Error State: .&lt;EM&gt;?(?&amp;lt;_error_msg&amp;gt;.&lt;/EM&gt;?)$"&lt;/P&gt;

&lt;P&gt;It would also be nice to extract that timestamp as well and place it in a variable if someone can help me do so!&lt;/P&gt;

&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:40:50 GMT</pubDate>
    <dc:creator>like2splunk</dc:creator>
    <dc:date>2020-09-29T13:40:50Z</dc:date>
    <item>
      <title>Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331386#M174922</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I'm running a streamstats command that prints out a series of previously-searched events. There are often more than one "ERROR" events within each group. As such, I want to rex the entire ERROR message (composed of multiple lines). Below is an example ERROR event (in &lt;STRONG&gt;BOLD&lt;/STRONG&gt;).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2017-03-08 10:34:34,067 [ WARN] {Application Queue} (com.iba.tcs.beam.bds.devices.impl.gateway.rpc.ScanningControllerProxy) - ScanningController failure: NECU Transitioned to Error State NECU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 FCU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 RCU Error: [0x1] Threshold Violation : Timeslice: 162 Submap: 83 (X_VOLT_SEC_FB: -1.858963 V MapThresholdLow: -6.005e-02 MapThresholdHigh: 4.256e-01) SGCU Error: [0x10] _FilteringAbsolute : Timeslice: 159 Submap: 83 (MIN_CHARGE_PRIM: 6.159e-10 C AbsoluteThresholdLow: 7.119e-10 AbsoluteThresholdHigh: 7.569e-10)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;As you can see, there are multiple lines for a single timestamp. I want to rex everything after the "ScanningController failure:" string. So the result would simply look like this:&lt;/P&gt;

&lt;P&gt;NECU Transitioned to Error State NECU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 FCU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 RCU Error: [0x1] Threshold Violation : Timeslice: 162 Submap: 83 (X_VOLT_SEC_FB: -1.858963 V MapThresholdLow: -6.005e-02 MapThresholdHigh: 4.256e-01) SGCU Error: [0x10] _FilteringAbsolute : Timeslice: 159 Submap: 83 (MIN_CHARGE_PRIM: 6.159e-10 C AbsoluteThresholdLow: 7.119e-10 AbsoluteThresholdHigh: 7.569e-10)&lt;/P&gt;

&lt;P&gt;How do I do this? I tried the following but it does not work: | rex "Transitioned to Error State: .&lt;EM&gt;?(?&amp;lt;_error_msg&amp;gt;.&lt;/EM&gt;?)$"&lt;/P&gt;

&lt;P&gt;It would also be nice to extract that timestamp as well and place it in a variable if someone can help me do so!&lt;/P&gt;

&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:40:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331386#M174922</guid>
      <dc:creator>like2splunk</dc:creator>
      <dc:date>2020-09-29T13:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331387#M174923</link>
      <description>&lt;P&gt;Try this regex string&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ScanningController failure:\s(?&amp;lt;error_msg&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The timestamp is already in a field called &lt;CODE&gt;_time&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;BTW, you shouldn't start your field names with an underscore.  Such fields names are reserved by Splunk.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 12:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331387#M174923</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-04-17T12:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331388#M174924</link>
      <description>&lt;P&gt;Can you try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "^(?P&amp;lt;time&amp;gt;[^\,]*)\,.*ScanningController failure\:\s(?&amp;lt;error_msg&amp;gt;.*)$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Apr 2017 13:06:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331388#M174924</guid>
      <dc:creator>Ravan</dc:creator>
      <dc:date>2017-04-17T13:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331389#M174925</link>
      <description>&lt;P&gt;All I get from your rex is the following: &lt;/P&gt;

&lt;P&gt;"NECU Transitioned to Error State" (this corresponds to the first line only. I need the remaining four lines as well. How do I grab those? &lt;/P&gt;

&lt;P&gt;FYI, the logfile looks like this:&lt;/P&gt;

&lt;P&gt;2017-03-08 10:34:34,067 [ WARN] {Application Queue} (com.iba.tcs.beam.bds.devices.impl.gateway.rpc.ScanningControllerProxy) - ScanningController failure: NECU Transitioned to Error State &lt;/P&gt;

&lt;P&gt;NECU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 &lt;/P&gt;

&lt;P&gt;FCU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 &lt;/P&gt;

&lt;P&gt;RCU Error: [0x1] Threshold Violation : Timeslice: 162 Submap: 83 (X_VOLT_SEC_FB: -1.858963 V MapThresholdLow: -6.005e-02 MapThresholdHigh: 4.256e-01) &lt;/P&gt;

&lt;P&gt;SGCU Error: [0x10] _FilteringAbsolute : Timeslice: 159 Submap: 83 (MIN_CHARGE_PRIM: 6.159e-10 C AbsoluteThresholdLow: 7.119e-10 AbsoluteThresholdHigh: 7.569e-10)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:44:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331389#M174925</guid>
      <dc:creator>like2splunk</dc:creator>
      <dc:date>2020-09-29T13:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331390#M174926</link>
      <description>&lt;P&gt;All I get from your rex is the following: &lt;/P&gt;

&lt;P&gt;"NECU Transitioned to Error State" (this corresponds to the first line only. I need the remaining four lines as well. How do I grab those? &lt;/P&gt;

&lt;P&gt;FYI, the logfile looks like this:&lt;/P&gt;

&lt;P&gt;2017-03-08 10:34:34,067 [ WARN] {Application Queue} (com.iba.tcs.beam.bds.devices.impl.gateway.rpc.ScanningControllerProxy) - ScanningController failure: NECU Transitioned to Error State &lt;/P&gt;

&lt;P&gt;NECU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 &lt;/P&gt;

&lt;P&gt;FCU Error: [0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83 &lt;/P&gt;

&lt;P&gt;RCU Error: [0x1] Threshold Violation : Timeslice: 162 Submap: 83 (X_VOLT_SEC_FB: -1.858963 V MapThresholdLow: -6.005e-02 MapThresholdHigh: 4.256e-01) &lt;/P&gt;

&lt;P&gt;SGCU Error: [0x10] _FilteringAbsolute : Timeslice: 159 Submap: 83 (MIN_CHARGE_PRIM: 6.159e-10 C AbsoluteThresholdLow: 7.119e-10 AbsoluteThresholdHigh: 7.569e-10)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:44:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331390#M174926</guid>
      <dc:creator>like2splunk</dc:creator>
      <dc:date>2020-09-29T13:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331391#M174927</link>
      <description>&lt;P&gt;Try adding the single line flag:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?s)ScanningController failure:\s(?&amp;lt;error_msg&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:54:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331391#M174927</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-04-18T13:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with REX command on a multi-line event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331392#M174928</link>
      <description>&lt;P&gt;Hey there, &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;This should grab all the errors per event into one single field.
&lt;CODE&gt;| rex "Transitioned\sto\sError\sState\s+(?&amp;lt;ALL_ERROR_LINES&amp;gt;[\n\r\s\S\d]+)"&lt;/CODE&gt; &lt;/LI&gt;
&lt;LI&gt;If you want to extract those errors individually.
&lt;CODE&gt;| rex max_match=10 "^(?&amp;lt;AA&amp;gt;[A-Z]+\sError:\s[^\n]+)"&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Or something more granular like field=value (ie: error_type=NECU msg="[0x0] _SynchronizationSGCUTimeout : Timeslice: 163 Submap: 83"), something like this should work.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;CODE&gt;props.conf&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
REPORT-multi_errors = multi_error_values
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;transforms.conf&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[multi_error_values]
REGEX = ^(?&amp;lt;_KEY_1&amp;gt;[A-Z]+\sError):\s(?&amp;lt;_VAL_1&amp;gt;[^\n]+)
REPEAT_MATCH = true
CLEAN_KEYS = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 15:48:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trouble-with-REX-command-on-a-multi-line-event/m-p/331392#M174928</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-04-18T15:48:03Z</dc:date>
    </item>
  </channel>
</rss>

