<?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: Trying to manually Create Regex for search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410461#M118438</link>
    <description>&lt;P&gt;Example: &lt;/P&gt;

&lt;P&gt;{"MessageId": "28e14-4ed-42c-a3-f14816394", "Attributes": {"SentTimestamp": "1583", "SenderId": "AIDAIYLBIEIX46", "ApproximateReceiveCount": "1", "ApproximateFirstReceiveTimestamp": "152"}, "Body": "{\n \"Type\" : \"Notification\",\n \"MessageId\" : \"524-63-9-7-6096\",\n \"TopicArn\" : \"arn:aws:sns\",\n \"Message\" : \"{\\"notificationType\\":\\"Bounce\\",\\"bounce\\":{\\"bounceType\\":\\"Permanent\\",\\"bounceSubType\\":\\"General\\",\\"bouncedRecipients\\":[{\\"emailAddress\\":\\"&lt;A href="mailto:emailaddress@domain.com"&gt;emailaddress@domain.com&lt;/A&gt;\\",\\"action\\":\\"failed\\",\\"status\\":\\"5.1.1\\",\\"diagnosticCode\\":\\"smtp; 550 5.1.1  invalid recipient - Refer to Error Codes section at &lt;A href="http://postmaster.cox.net/confluence/display/postmaster/Error+Codes"&gt;http://postmaster.cox.net/confluence/display/postmaster/Error+Codes&lt;/A&gt; for more information.\\"}],\\"timestamp\\":\\"2018\\",\\"feedbackId\\":\\"0101016640d3e5-a8c4-edf00\\",\\"remoteMtaIp\\":\\"1.1.1.1\\",\\"reportingMTA\\":\\"dsn; &lt;A href="http://www.aws.com%5C%5C%5C%22%7D,%5C%5C%5C%22mail%5C%5C%5C%22:%7B%5C%5C%5C%22timestamp%5C%5C%5C%22:%5C%5C%5C%222018%5C%5C%5C%22,%5C%5C%5C%22source%5C%5C%5C%22:%5C%5C%5C%22no-reply@domain.com%5C%5C%5C%22,%5C%5C%5C%22sourceArn%5C%5C%5C%22:%5C%5C%5C%22arn:aws:ses:emailaddress@domain.com%5C%5C%5C%22,%5C%5C%5C%22sourceIp%5C%5C%5C%22:%5C%5C%5C%221.1.1.1%5C%5C%5C%22,%5C%5C%5C%22sendingAccountId%5C%5C%5C%22:%5C%5C%5C%22111111111%5C%5C%5C%22,%5C%5C%5C%22messageId%5C%5C%5C%22:%5C%5C%5C%22010101010101%5C%5C%5C%22,%5C%5C%5C%22destination%5C%5C%5C%22:%5B%5C%5C%5C%22emailaddress@domain.com%5C%5C%5C%22%5D"&gt;www.aws.com\\\"},\\\"mail\\\":{\\\"timestamp\\\":\\\"2018\\\",\\\"source\\\":\\\"no-reply@domain.com\\\",\\\"sourceArn\\\":\\\"arn:aws:ses:emailaddress@domain.com\\\",\\\"sourceIp\\\":\\\"1.1.1.1\\\",\\\"sendingAccountId\\\":\\\"111111111\\\",\\\"messageId\\\":\\\"010101010101\\\",\\\"destination\\\":[\\\"emailaddress@domain.com\\\"]&lt;/A&gt;,&lt;/P&gt;</description>
    <pubDate>Tue, 09 Oct 2018 16:26:45 GMT</pubDate>
    <dc:creator>sgoodman26</dc:creator>
    <dc:date>2018-10-09T16:26:45Z</dc:date>
    <item>
      <title>Trying to manually Create Regex for search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410458#M118435</link>
      <description>&lt;P&gt;We have been trying to create a search for AWS:Simple Email Services to locate any Bounce Back emails that come in; Specifically all Bounces and Complaints. We need the Fields created from the following points of data:&lt;/P&gt;

&lt;P&gt;notificationType&lt;BR /&gt;
emailAddress&lt;BR /&gt;
diagnosticCode&lt;/P&gt;

&lt;P&gt;We've tried using the Extract Fields, but since each data entry is formatted differently, it will only find the information on some, none on others. The issue we are running into is when trying to create a RegEx code manually; we've been using Reg101 which is able to pull the information that we need using these expressions:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;diagnosticCode[^a-zA_Z0-9]*([^\\"]*)(?P&amp;lt;Diagnostic_Code&amp;gt;\\)

emailAddress[^a-zA_Z0-9]*(?P&amp;lt;ses_emailaddress&amp;gt;\\) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When plugging that into Splunk, that does not work, and pulls either random numbers or just . When looking at the code that is generated from the Extract Field generator, this is what comes up:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?:[^,\n]*,){10}\\\\\\"\w+\\\\\\":\\\\\\"(?P[^\\]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After reading all of the information in the About Splunk Regular Expressions document, I'm thinking that there is a different format that would be needed for the expression. One that is a bit more precise on where to look. Any help would be appreciative!&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 04:43:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410458#M118435</guid>
      <dc:creator>sgoodman26</dc:creator>
      <dc:date>2018-10-06T04:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to manually Create Regex for search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410459#M118436</link>
      <description>&lt;P&gt;can you give some sample events?&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 15:25:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410459#M118436</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-10-06T15:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to manually Create Regex for search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410460#M118437</link>
      <description>&lt;P&gt;have you tried tried creating the extractions manually in the web instead of using the extract field generator?  Settings -&amp;gt; Fields -&amp;gt; Field extractions -&amp;gt; New Field Extraction?&lt;/P&gt;

&lt;P&gt;You should be able to use the same regex from 101.  Also, maybe delete the ones created from the generator so there aren't any conflicts.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.1.3/Knowledge/Managesearch-timefieldextractions#Add_new_field_extractions_in_Splunk_Web"&gt;https://docs.splunk.com/Documentation/Splunk/7.1.3/Knowledge/Managesearch-timefieldextractions#Add_new_field_extractions_in_Splunk_Web&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 13:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410460#M118437</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2018-10-07T13:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to manually Create Regex for search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410461#M118438</link>
      <description>&lt;P&gt;Example: &lt;/P&gt;

&lt;P&gt;{"MessageId": "28e14-4ed-42c-a3-f14816394", "Attributes": {"SentTimestamp": "1583", "SenderId": "AIDAIYLBIEIX46", "ApproximateReceiveCount": "1", "ApproximateFirstReceiveTimestamp": "152"}, "Body": "{\n \"Type\" : \"Notification\",\n \"MessageId\" : \"524-63-9-7-6096\",\n \"TopicArn\" : \"arn:aws:sns\",\n \"Message\" : \"{\\"notificationType\\":\\"Bounce\\",\\"bounce\\":{\\"bounceType\\":\\"Permanent\\",\\"bounceSubType\\":\\"General\\",\\"bouncedRecipients\\":[{\\"emailAddress\\":\\"&lt;A href="mailto:emailaddress@domain.com"&gt;emailaddress@domain.com&lt;/A&gt;\\",\\"action\\":\\"failed\\",\\"status\\":\\"5.1.1\\",\\"diagnosticCode\\":\\"smtp; 550 5.1.1  invalid recipient - Refer to Error Codes section at &lt;A href="http://postmaster.cox.net/confluence/display/postmaster/Error+Codes"&gt;http://postmaster.cox.net/confluence/display/postmaster/Error+Codes&lt;/A&gt; for more information.\\"}],\\"timestamp\\":\\"2018\\",\\"feedbackId\\":\\"0101016640d3e5-a8c4-edf00\\",\\"remoteMtaIp\\":\\"1.1.1.1\\",\\"reportingMTA\\":\\"dsn; &lt;A href="http://www.aws.com%5C%5C%5C%22%7D,%5C%5C%5C%22mail%5C%5C%5C%22:%7B%5C%5C%5C%22timestamp%5C%5C%5C%22:%5C%5C%5C%222018%5C%5C%5C%22,%5C%5C%5C%22source%5C%5C%5C%22:%5C%5C%5C%22no-reply@domain.com%5C%5C%5C%22,%5C%5C%5C%22sourceArn%5C%5C%5C%22:%5C%5C%5C%22arn:aws:ses:emailaddress@domain.com%5C%5C%5C%22,%5C%5C%5C%22sourceIp%5C%5C%5C%22:%5C%5C%5C%221.1.1.1%5C%5C%5C%22,%5C%5C%5C%22sendingAccountId%5C%5C%5C%22:%5C%5C%5C%22111111111%5C%5C%5C%22,%5C%5C%5C%22messageId%5C%5C%5C%22:%5C%5C%5C%22010101010101%5C%5C%5C%22,%5C%5C%5C%22destination%5C%5C%5C%22:%5B%5C%5C%5C%22emailaddress@domain.com%5C%5C%5C%22%5D"&gt;www.aws.com\\\"},\\\"mail\\\":{\\\"timestamp\\\":\\\"2018\\\",\\\"source\\\":\\\"no-reply@domain.com\\\",\\\"sourceArn\\\":\\\"arn:aws:ses:emailaddress@domain.com\\\",\\\"sourceIp\\\":\\\"1.1.1.1\\\",\\\"sendingAccountId\\\":\\\"111111111\\\",\\\"messageId\\\":\\\"010101010101\\\",\\\"destination\\\":[\\\"emailaddress@domain.com\\\"]&lt;/A&gt;,&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 16:26:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410461#M118438</guid>
      <dc:creator>sgoodman26</dc:creator>
      <dc:date>2018-10-09T16:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to manually Create Regex for search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410462#M118439</link>
      <description>&lt;P&gt;try this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    |rex "notificationType\\\\\\\":\\\\\\\"(?&amp;lt;notificationType&amp;gt;[^\\]+)"
|rex "emailAddress\\\\\\\":\\\\\\\"(?&amp;lt;emailAddress&amp;gt;[^\\]+)"
|rex "diagnosticCode\\\\\\\":\\\\\\\"(?&amp;lt;diagnosticCode&amp;gt;[^\\]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/Qm1nAu/1"&gt;https://regex101.com/r/Qm1nAu/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;also you can do search time extraction in props.conf file&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 17:06:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410462#M118439</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-10-09T17:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to manually Create Regex for search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410463#M118440</link>
      <description>&lt;P&gt;Okay, one part of the problem here is your regex is either oversimplifying or overcomplicating the extraction ,depending on how you want to look at it.  &lt;/P&gt;

&lt;P&gt;Inside of this chunk...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[{\\\"emailAddress\\\":\\\"emailaddress@domain.com\\\",\\\"action\\\":\\\"failed\\\",\\\"status\\\":\\\"5.1.1\\\",\\\"diagnosticCode\\\":\\\"smtp; 550 5.1.1 invalid recipient - Refer to Error Codes section at &lt;A href="http://postmaster.cox.net/confluence/display/postmaster/Error+Codes" target="test_blank"&gt;http://postmaster.cox.net/confluence/display/postmaster/Error+Codes&lt;/A&gt; for more information.\\\"}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...you want to find the words &lt;CODE&gt;diagnosticCode&lt;/CODE&gt;, and if found, you want to extract everything that follows a set of multi-escaped quotes, a colon, and another set of multi-escaped quotes.  In regex, that looks like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; diagnosticCode[\"\\\\]+:[\"\\\\]+(?&amp;lt;capturename&amp;gt;......some capture match goes here....)[\"\\\\]+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, each of those plusses probably has a minimum number of matches it's going to need to do to be proper.  It looks like exactly 3 in the data you gave us, so it may be that  each &lt;CODE&gt;[\"\\\\]+&lt;/CODE&gt; should be &lt;CODE&gt;[\"\\\\]{3}&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Here's a run-anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval junk="\\"."\\"."\\\"" 
| eval _raw = "
[{".junk."emailAddress".junk.":".junk."emailaddress@domain.com".junk.",".junk."action".junk.":".junk."failed".junk.",".junk."status".junk.":".junk."5.1.1".junk.",".junk."diagnosticCode".junk.":".junk."smtp; 550 5.1.1 invalid recipient - Refer to Error Codes section at &lt;A href="http://postmaster.cox.net/confluence/display/postmaster/Error+Codes" target="test_blank"&gt;http://postmaster.cox.net/confluence/display/postmaster/Error+Codes&lt;/A&gt; for more information.".junk."}]"
| rex "diagnosticCode[\"\\\\]+:[\"\\\\]+(?&amp;lt;capturename&amp;gt;.+)(?&amp;lt;![\"\\\\])[\"\\\\]+"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Oct 2018 16:30:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Trying-to-manually-Create-Regex-for-search/m-p/410463#M118440</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-10-10T16:30:14Z</dc:date>
    </item>
  </channel>
</rss>

