<?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 add new fields in indexing time depending on condition in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224279#M43912</link>
    <description>&lt;P&gt;Hi snehalk, &lt;/P&gt;

&lt;P&gt;Yes, you can overwrite the raw data to add a new field at index time using the same method for masking sensitive data. &lt;/P&gt;

&lt;P&gt;For example, suppose your original log file goes like this: &lt;/P&gt;

&lt;P&gt;[22/Apr/2014:00:46:27] VendorID=0001 mynum=4 Code=A&lt;BR /&gt;
[22/Apr/2014:00:48:40] VendorID=0002 mynum=5 Code=B&lt;BR /&gt;
[22/Apr/2014:00:50:02] VendorID=0003 mynum=6 Code=C&lt;/P&gt;

&lt;P&gt;Assuming your mynum value ranges from 0-9, you can use the REGEX pattern to find identify two brackets of mynum values in your source file (0-5, 6-9), performs transformations based on the values, and overwrites the raw data during the indexing processs. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::...\\mylog.log]
TRANSFORMS-fail = fail
TRANSFORMS-pass = pass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[fail]
REGEX = (.*mynum=[0-5])(\s.*)
DEST_KEY = _raw
FORMAT = $1 check=fail $2

[pass]
REGEX = (.*mynum=[6-9])(\s.*)
DEST_KEY = _raw
FORMAT = $1 check=pass $2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps. Thanks!&lt;BR /&gt;
Hunter&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2016 14:22:37 GMT</pubDate>
    <dc:creator>hunters_splunk</dc:creator>
    <dc:date>2016-11-09T14:22:37Z</dc:date>
    <item>
      <title>How to add new fields in indexing time depending on condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224278#M43911</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;Is this possible in Splunk where we can add new fields and there value will depends on condition? in &lt;CODE&gt;transforms.conf&lt;/CODE&gt; file? or in &lt;CODE&gt;fields.conf&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;eg: while indexing we have field called mynum=6 when this found then splunk need to add new field (at end of each event) called "check" and the value is pass/fail depending on condition and the condition for pass is mynum&amp;gt;5?&lt;/P&gt;

&lt;P&gt;something like when i indexed the data in splunk&lt;/P&gt;

&lt;P&gt;....my sample log....,check=pass&lt;/P&gt;

&lt;P&gt;Can any one help me on this?&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 11:41:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224278#M43911</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2016-11-09T11:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new fields in indexing time depending on condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224279#M43912</link>
      <description>&lt;P&gt;Hi snehalk, &lt;/P&gt;

&lt;P&gt;Yes, you can overwrite the raw data to add a new field at index time using the same method for masking sensitive data. &lt;/P&gt;

&lt;P&gt;For example, suppose your original log file goes like this: &lt;/P&gt;

&lt;P&gt;[22/Apr/2014:00:46:27] VendorID=0001 mynum=4 Code=A&lt;BR /&gt;
[22/Apr/2014:00:48:40] VendorID=0002 mynum=5 Code=B&lt;BR /&gt;
[22/Apr/2014:00:50:02] VendorID=0003 mynum=6 Code=C&lt;/P&gt;

&lt;P&gt;Assuming your mynum value ranges from 0-9, you can use the REGEX pattern to find identify two brackets of mynum values in your source file (0-5, 6-9), performs transformations based on the values, and overwrites the raw data during the indexing processs. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::...\\mylog.log]
TRANSFORMS-fail = fail
TRANSFORMS-pass = pass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[fail]
REGEX = (.*mynum=[0-5])(\s.*)
DEST_KEY = _raw
FORMAT = $1 check=fail $2

[pass]
REGEX = (.*mynum=[6-9])(\s.*)
DEST_KEY = _raw
FORMAT = $1 check=pass $2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps. Thanks!&lt;BR /&gt;
Hunter&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 14:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224279#M43912</guid>
      <dc:creator>hunters_splunk</dc:creator>
      <dc:date>2016-11-09T14:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new fields in indexing time depending on condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224280#M43913</link>
      <description>&lt;P&gt;Hello Hunter,&lt;/P&gt;

&lt;P&gt;Thanks for reply, is it possible to use like condition mynum&amp;gt;5 because the number can change instate of using regular expression? can we use any arithmetic operator? &lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 08:22:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224280#M43913</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2016-11-10T08:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new fields in indexing time depending on condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224281#M43914</link>
      <description>&lt;P&gt;I'm afraid not, snehalk. Only regex is supported here in transforms.conf. However, if you are dealing with 2-digit or 3-digit numbers, you can still capture them using an appropriate regex expression. Not sure if this helps. Thanks! &lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 12:24:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224281#M43914</guid>
      <dc:creator>hunters_splunk</dc:creator>
      <dc:date>2016-11-10T12:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new fields in indexing time depending on condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224282#M43915</link>
      <description>&lt;P&gt;No problem Hunters, Thank you for your inputs. &lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 13:19:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-new-fields-in-indexing-time-depending-on-condition/m-p/224282#M43915</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2016-11-10T13:19:54Z</dc:date>
    </item>
  </channel>
</rss>

