<?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 define a data filter in order to apply different fields extractions for 2 different events from the same source? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-a-data-filter-in-order-to-apply-different-fields/m-p/281908#M85090</link>
    <description>&lt;P&gt;Yes, it depends on how you write your regular expression. In fact, I find this easiest to do by editing props.conf directly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetypehere]
EXTRACT-e1=^\d+\s\d+\s(?&amp;lt;field1&amp;gt;\d+)ENV
EXTRACT-e2=ORD(?&amp;lt;field2&amp;gt;\d{4})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With these extractions, only events that match the first pattern (which includes "ENV") will have field1, and only events that match the second pattern (including "ORD") will contain field2&lt;/P&gt;

&lt;P&gt;You can make your regular expressions as complex as they need to be, in order to match &lt;EM&gt;exactly&lt;/EM&gt; and &lt;EM&gt;only&lt;/EM&gt; the data you want. Also, you can have a single EXTRACT line that extracts multiple fields at once. But I often find it is easier to write each field extraction separately, as I have done here, especially when the patterns are different. &lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2015 19:15:33 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2015-12-17T19:15:33Z</dc:date>
    <item>
      <title>How to define a data filter in order to apply different fields extractions for 2 different events from the same source?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-a-data-filter-in-order-to-apply-different-fields/m-p/281907#M85089</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I am new to Splunk Enterprise&lt;/P&gt;

&lt;P&gt;Here is my problem:&lt;BR /&gt;
I have a data source in the form of text files which contains two type of events, and each can be identified by a string &lt;BR /&gt;
Ex : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;line 1 : XXXX XX XXX ENVXXXXXXXXXXX
line 2 : XXXXXXXXXXORDXXXX XXX XXXXX
line 3 : XXXXXXXXXXORDXXXX XXX XXXXX
etc...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'm trying to do is to find a way to extract fields according to each type of event.&lt;BR /&gt;
I've came up with two fields extractors, one for the line that contains "ENV", and one for "ORD", each contain a regex to extract the information I want.&lt;BR /&gt;
However, I don't understand how to use them properly yet.&lt;BR /&gt;
Is there a way to tell Splunk that if it finds lines that contains "ENV", then apply extractor X, otherwise extractor Y ?&lt;/P&gt;

&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 10:40:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-a-data-filter-in-order-to-apply-different-fields/m-p/281907#M85089</guid>
      <dc:creator>dhantran</dc:creator>
      <dc:date>2015-12-17T10:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a data filter in order to apply different fields extractions for 2 different events from the same source?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-define-a-data-filter-in-order-to-apply-different-fields/m-p/281908#M85090</link>
      <description>&lt;P&gt;Yes, it depends on how you write your regular expression. In fact, I find this easiest to do by editing props.conf directly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetypehere]
EXTRACT-e1=^\d+\s\d+\s(?&amp;lt;field1&amp;gt;\d+)ENV
EXTRACT-e2=ORD(?&amp;lt;field2&amp;gt;\d{4})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With these extractions, only events that match the first pattern (which includes "ENV") will have field1, and only events that match the second pattern (including "ORD") will contain field2&lt;/P&gt;

&lt;P&gt;You can make your regular expressions as complex as they need to be, in order to match &lt;EM&gt;exactly&lt;/EM&gt; and &lt;EM&gt;only&lt;/EM&gt; the data you want. Also, you can have a single EXTRACT line that extracts multiple fields at once. But I often find it is easier to write each field extraction separately, as I have done here, especially when the patterns are different. &lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 19:15:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-define-a-data-filter-in-order-to-apply-different-fields/m-p/281908#M85090</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-12-17T19:15:33Z</dc:date>
    </item>
  </channel>
</rss>

