<?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 Creating a Conditional Field using Field Extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484669#M135644</link>
    <description>&lt;P&gt;Hey everyone, &lt;/P&gt;

&lt;P&gt;I am new to Splunk, and I need to create a new sourcetype along with field extractions. I am using regex expressions in props.conf and so far it is working well. But for the next field, the field name will depend on the value of two other fields that I have already successful extracted. Hence, my question is: is it possible to have a field that is only extracted depending on the values of other fields? And if these conditions aren't met then the field is not extracted at all?  &lt;/P&gt;

&lt;P&gt;For example, say we have two fields with these values in the logs. &lt;BR /&gt;
    If field_a = 1 AND field_b = a , then extract a field called c1 (which equals 1).&lt;BR /&gt;
    If field_a = 1 AND field_b != b , then do not extract anything.&lt;BR /&gt;
    If field_a = 4 AND field_b = b , then extract a field called c2 (which equals 4).&lt;/P&gt;

&lt;P&gt;I know that this is easy to do in the search app interface on the web using SPL. But I want to be able to create this in the props.conf and so the field would be readily available while searching. Also, if this is possible, it would be a cool trick to learn. &lt;/P&gt;

&lt;P&gt;Thank you. &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:58:47 GMT</pubDate>
    <dc:creator>notimp47</dc:creator>
    <dc:date>2020-09-30T02:58:47Z</dc:date>
    <item>
      <title>Creating a Conditional Field using Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484669#M135644</link>
      <description>&lt;P&gt;Hey everyone, &lt;/P&gt;

&lt;P&gt;I am new to Splunk, and I need to create a new sourcetype along with field extractions. I am using regex expressions in props.conf and so far it is working well. But for the next field, the field name will depend on the value of two other fields that I have already successful extracted. Hence, my question is: is it possible to have a field that is only extracted depending on the values of other fields? And if these conditions aren't met then the field is not extracted at all?  &lt;/P&gt;

&lt;P&gt;For example, say we have two fields with these values in the logs. &lt;BR /&gt;
    If field_a = 1 AND field_b = a , then extract a field called c1 (which equals 1).&lt;BR /&gt;
    If field_a = 1 AND field_b != b , then do not extract anything.&lt;BR /&gt;
    If field_a = 4 AND field_b = b , then extract a field called c2 (which equals 4).&lt;/P&gt;

&lt;P&gt;I know that this is easy to do in the search app interface on the web using SPL. But I want to be able to create this in the props.conf and so the field would be readily available while searching. Also, if this is possible, it would be a cool trick to learn. &lt;/P&gt;

&lt;P&gt;Thank you. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:58:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484669#M135644</guid>
      <dc:creator>notimp47</dc:creator>
      <dc:date>2020-09-30T02:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Conditional Field using Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484670#M135645</link>
      <description>&lt;P&gt;I just noticed you have different destination fields for different conditions.  Updated to reflect that. &lt;/P&gt;

&lt;P&gt;The best bet might be to use an EVAL- statement in props.conf, using the case command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-c1 = CASE(field_a=="1" AND field_b=="a",field_a)
EVAL-c2 = CASE(field_a=="4" AND field_b=="b",field_a)   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assumes you're trying to set the value c1 to whatever the field_a value is in certain conditions.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 18:33:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484670#M135645</guid>
      <dc:creator>wenthold</dc:creator>
      <dc:date>2019-11-13T18:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Conditional Field using Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484671#M135646</link>
      <description>&lt;P&gt;You probably want a Calculated field.  See Settings-&amp;gt;Fields-&amp;gt;Calculated fields.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 18:35:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484671#M135646</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-11-13T18:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Conditional Field using Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484672#M135647</link>
      <description>&lt;P&gt;Thanks, this worked really well. &lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 09:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484672#M135647</guid>
      <dc:creator>notimp47</dc:creator>
      <dc:date>2019-11-14T09:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Conditional Field using Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484673#M135648</link>
      <description>&lt;P&gt;Yes, this is results the same as the answer by wenthold. For people that prefer to use the web interface, they can use this approach. Thanks for your answer.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 09:58:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-Conditional-Field-using-Field-Extraction/m-p/484673#M135648</guid>
      <dc:creator>notimp47</dc:creator>
      <dc:date>2019-11-14T09:58:57Z</dc:date>
    </item>
  </channel>
</rss>

