<?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 extract fields from my sample data and include these results in an email alert? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137475#M37671</link>
    <description>&lt;P&gt;For the regex, you can first test with in an inline REX using multiline capture:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search] | rex field=_raw "(?s)payload contents = (?&amp;lt;myfield&amp;gt;[^\*]+)\n\*+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;May need to adjust that a bit, I dont have time right now to run that through a regex validator.. Once that fields extracted, you can reference the field in alerts.. One way is to add the ... | table _time myfield ...   to the end of your savedsearch..&lt;/P&gt;</description>
    <pubDate>Wed, 08 Apr 2015 01:37:20 GMT</pubDate>
    <dc:creator>esix_splunk</dc:creator>
    <dc:date>2015-04-08T01:37:20Z</dc:date>
    <item>
      <title>How to extract fields from my sample data and include these results in an email alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137474#M37670</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm evaluating splunk to capture data for raising data alerts, raising technical alerts etc.&lt;BR /&gt;
Most of data generated is using Log4J2.  I'm able to forward data from an Linux machine to a receiver (in windows PC).&lt;BR /&gt;
I'm able to view real-time search.  Now I need to filter the data based on regex or any expression and link it to email Alerts.&lt;BR /&gt;
I tried using fields, but it seems complex to extract data from my search results.&lt;BR /&gt;
Below is sample data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2015-04-07 17:05:09,019 ERROR o.m.e.DefaultMessagingExceptionStrategy [[SplunkErrorProducer-vv3].SplunkErrorProducerFlow.stage1.02] 
********************************************************************************
Message               : Component that caused exception is: DefaultJavaComponent{SplunkErrorProducerFlow.component.207509504}. Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. payload contents =
Printing: 
CommonProductResult #0 {..... 250 lines more ...}
*********************************************************************************
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My questions are:&lt;BR /&gt;
1) How do I extract data beginning from "payload contents" to the "********" line (around 250 lines - which are not fixed).&lt;BR /&gt;
2) Even if I define a field, how can the field data be part of the email body for an alert?&lt;/P&gt;

&lt;P&gt;Could you help me on this? Is field object necessary or any other way to extract data based on specific pattern and link it to email Alerts?&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Ananth&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2015 16:12:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137474#M37670</guid>
      <dc:creator>krishananth</dc:creator>
      <dc:date>2015-04-07T16:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from my sample data and include these results in an email alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137475#M37671</link>
      <description>&lt;P&gt;For the regex, you can first test with in an inline REX using multiline capture:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search] | rex field=_raw "(?s)payload contents = (?&amp;lt;myfield&amp;gt;[^\*]+)\n\*+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;May need to adjust that a bit, I dont have time right now to run that through a regex validator.. Once that fields extracted, you can reference the field in alerts.. One way is to add the ... | table _time myfield ...   to the end of your savedsearch..&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 01:37:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137475#M37671</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2015-04-08T01:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from my sample data and include these results in an email alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137476#M37672</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm using the following search query to pick the payload contents.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=MY_DEV source="/my_esb/logs/splunkerrorproducer.log" ERROR | rex field=_raw "(?s)payload contents =(?&amp;lt;my_field&amp;gt;[^\*]+)\n\*+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However when I view the alert, it contains all additional information and it is due to the ERROR in the query.  If I remove ERROR, the search returns no results.&lt;/P&gt;

&lt;P&gt;I think there is some problem with regex in the search.  The above search works without &lt;CODE&gt;?&amp;lt; my_field &amp;gt;&lt;/CODE&gt; in an online regex tool.&lt;BR /&gt;
Is there anything missing to use regex and fields?&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Ananth&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 08 Apr 2015 11:05:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137476#M37672</guid>
      <dc:creator>krishananth</dc:creator>
      <dc:date>2015-04-08T11:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from my sample data and include these results in an email alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137477#M37673</link>
      <description>&lt;P&gt;Hi Esix_splunk,&lt;/P&gt;

&lt;P&gt;I was bit unclear on the pipe symbol (assuming it as OR).  Now, I'm able to extract exception message based on regex pattern, refer it to a field, create an alert with 2 columns (_time and my field).  This looks better now.&lt;/P&gt;

&lt;P&gt;Thanks for your answer.&lt;/P&gt;

&lt;P&gt;Ananth&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2015 15:40:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-my-sample-data-and-include-these/m-p/137477#M37673</guid>
      <dc:creator>krishananth</dc:creator>
      <dc:date>2015-04-10T15:40:26Z</dc:date>
    </item>
  </channel>
</rss>

