<?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 Why am I unable to REX out a subset of a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589181#M205184</link>
    <description>&lt;P&gt;I've got an alert I put together and am trying to REX multiple pieces of it out to their own columns. This is against the Splunk internal logging. I had no problem pulling errorCode since it has a clearly defined field-within-a-field, but I'm not able to pull a subset string of another part of the message&lt;/P&gt;
&lt;P&gt;Query&lt;BR /&gt;index=_internal sourcetype=sfdc:object:log log_level=ERROR OR log_level=WARNING&lt;BR /&gt;| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;[^\s]+)\""&lt;BR /&gt;| stats count(stanza_name) by stanza_name, log_level, errorCode, message&lt;/P&gt;
&lt;P&gt;I've got the message at the end just to give me the query error, but what I'd like to do is REX that also like I did to get the errorCode as its own column. Below is a sample message, with the part in bold what I'd like to rex out to its own column. I can't find an example of doing that where there isn't a clear delineation within the message like "errorCode":"&amp;lt;error&amp;gt;"&lt;/P&gt;
&lt;P&gt;[{"message":"\nFoo,Bar,FooBar,FooBar2\n ^\nERROR at Row:1:Column:232\n&lt;STRONG&gt;No such column 'FooBar2' on entity 'MyAwesomeObject'.&lt;/STRONG&gt; If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2022 15:10:13 GMT</pubDate>
    <dc:creator>arist0telis</dc:creator>
    <dc:date>2022-03-16T15:10:13Z</dc:date>
    <item>
      <title>Why am I unable to REX out a subset of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589181#M205184</link>
      <description>&lt;P&gt;I've got an alert I put together and am trying to REX multiple pieces of it out to their own columns. This is against the Splunk internal logging. I had no problem pulling errorCode since it has a clearly defined field-within-a-field, but I'm not able to pull a subset string of another part of the message&lt;/P&gt;
&lt;P&gt;Query&lt;BR /&gt;index=_internal sourcetype=sfdc:object:log log_level=ERROR OR log_level=WARNING&lt;BR /&gt;| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;[^\s]+)\""&lt;BR /&gt;| stats count(stanza_name) by stanza_name, log_level, errorCode, message&lt;/P&gt;
&lt;P&gt;I've got the message at the end just to give me the query error, but what I'd like to do is REX that also like I did to get the errorCode as its own column. Below is a sample message, with the part in bold what I'd like to rex out to its own column. I can't find an example of doing that where there isn't a clear delineation within the message like "errorCode":"&amp;lt;error&amp;gt;"&lt;/P&gt;
&lt;P&gt;[{"message":"\nFoo,Bar,FooBar,FooBar2\n ^\nERROR at Row:1:Column:232\n&lt;STRONG&gt;No such column 'FooBar2' on entity 'MyAwesomeObject'.&lt;/STRONG&gt; If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:10:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589181#M205184</guid>
      <dc:creator>arist0telis</dc:creator>
      <dc:date>2022-03-16T15:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to REX out a subset of a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589187#M205187</link>
      <description>&lt;P&gt;Assuming the desired text always follows "ERROR at Row:*:Column:*" and that "\n" are literal characters then this should do it.&amp;nbsp; If these are not valid assumptions then please clarify the requirements.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal sourcetype=sfdc:object:log log_level=ERROR OR log_level=WARNING
| rex "ERROR at Row:\d+:Column:\d+\\n(?&amp;lt;message&amp;gt;[^\.]+)"
| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;[^\s]+)\""
| stats count(stanza_name) by stanza_name, log_level, errorCode, message&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 15 Mar 2022 20:27:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589187#M205187</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-03-15T20:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to REX out a subset of a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589356#M205227</link>
      <description>&lt;P&gt;Doesn't look like that did it. part of the problem is the added REX is using the protected name&amp;nbsp;&lt;STRONG&gt;message&lt;/STRONG&gt;, which is also the name of the entire field. When you add&amp;nbsp;&lt;STRONG&gt;message&lt;/STRONG&gt; to the stats at the end it does the same thing I had above, it just outputs the entire message without REXing out the part I care about.&lt;/P&gt;&lt;P&gt;And yes, those \n are literals. I did a copy and paste of the exact flat text.&lt;/P&gt;&lt;P&gt;I changed the query to remove the protected names of the fields, "No results found" when I include that new REX trying to pull out the error message.&lt;/P&gt;&lt;P&gt;index=_internal sourcetype=sfdc:object:log log_level=ERROR OR log_level=WARNING&lt;BR /&gt;| rex "ERROR at Row:\d+:Column:\d+\\n(?&amp;lt;&lt;STRONG&gt;msg&lt;/STRONG&gt;&amp;gt;[^\.]+)"&lt;BR /&gt;| rex "\"errorCode\":\"(?&amp;lt;err&amp;gt;[^\s]+)\""&lt;BR /&gt;| stats count(stanza_name) by stanza_name, log_level, err, &lt;STRONG&gt;msg&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you cut off the&amp;nbsp;&lt;STRONG&gt;msg&lt;/STRONG&gt; at the end, I at least get my errorCode column&amp;nbsp;&lt;STRONG&gt;err&lt;/STRONG&gt; back clean so that part works, it's just the new REX still isn't finding and capturing the message.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:07:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589356#M205227</guid>
      <dc:creator>arist0telis</dc:creator>
      <dc:date>2022-03-16T15:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to REX out a subset of a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589361#M205231</link>
      <description>&lt;P&gt;Missing a couple of backslashes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "ERROR at Row:\d+:Column:\d+\\\\n(?&amp;lt;msg&amp;gt;[^\.]+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-unable-to-REX-out-a-subset-of-a-field/m-p/589361#M205231</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-03-16T15:24:53Z</dc:date>
    </item>
  </channel>
</rss>

