<?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: Set field records &amp; IF Statements in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64956#M16045</link>
    <description>&lt;P&gt;..or do you mean that you want to create a new field (within the search) based on some text in the event?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Accesses = if(match(_raw, "Write Control"), "Write", "Read")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;eval&lt;/CODE&gt; will create the field &lt;CODE&gt;Accesses&lt;/CODE&gt; (or change it if it already exists). If the string "Write Control" exists within the event (&lt;CODE&gt;_raw&lt;/CODE&gt; is the whole event), &lt;CODE&gt;Accesses&lt;/CODE&gt; will be set to "Write", otherwise it will be set to "Read".&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2013 08:39:40 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-06-17T08:39:40Z</dc:date>
    <item>
      <title>Set field records &amp; IF Statements</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64954#M16043</link>
      <description>&lt;P&gt;When I search my results I want it to update the field accordingly.&lt;/P&gt;

&lt;P&gt;For example in my case when i search my Audit logs , The log contains the words "write control" and "Read control" within the text of the log but the field is set to Read Control instead of Write.&lt;/P&gt;

&lt;P&gt;So if the log contains the word Write i want it to replace the field Accesses to Write instead of Read.&lt;/P&gt;

&lt;P&gt;This is the search I am using&lt;/P&gt;

&lt;P&gt;EventCode="5145" NOT Relative_Target_Name="Desktop.ini" NOT Share_Name="\*\IPC$" NOT Relative_Target_Name="\" | table Account_Name,Accesses, Share_Name,Relative_Target_Name,Da_te,Ti_me,AM_PM&lt;/P&gt;

&lt;P&gt;Any help with this will be great...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:06:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64954#M16043</guid>
      <dc:creator>Kdeep</dc:creator>
      <dc:date>2020-09-28T14:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Set field records &amp; IF Statements</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64955#M16044</link>
      <description>&lt;P&gt;It is not really clear what you want to achieve. Do you have problems with the field extraction?&lt;/P&gt;

&lt;P&gt;Or do you want to rename the field, based on its value?&lt;/P&gt;

&lt;P&gt;Please post a few sample events.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2013 08:30:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64955#M16044</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-06-17T08:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Set field records &amp; IF Statements</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64956#M16045</link>
      <description>&lt;P&gt;..or do you mean that you want to create a new field (within the search) based on some text in the event?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Accesses = if(match(_raw, "Write Control"), "Write", "Read")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;eval&lt;/CODE&gt; will create the field &lt;CODE&gt;Accesses&lt;/CODE&gt; (or change it if it already exists). If the string "Write Control" exists within the event (&lt;CODE&gt;_raw&lt;/CODE&gt; is the whole event), &lt;CODE&gt;Accesses&lt;/CODE&gt; will be set to "Write", otherwise it will be set to "Read".&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2013 08:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-field-records-IF-Statements/m-p/64956#M16045</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-06-17T08:39:40Z</dc:date>
    </item>
  </channel>
</rss>

