<?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: Conditional rename using multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658145#M227344</link>
    <description>&lt;P&gt;Fields have a name and values.&amp;nbsp; They can be renamed.&amp;nbsp; Values do not have names so they cannot be renamed.&lt;/P&gt;&lt;P&gt;To change a value of a field, use the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; command to assign a new value.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Device_Interface="x_y_z"&lt;/LI-CODE&gt;&lt;P&gt;To change selected values of a field, use a condition within the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Device_Interface = if(Device_Interface="foo", "bar", Device_Interface)&lt;/LI-CODE&gt;&lt;P&gt;Putting the field name in the else clause leaves the value unchanged if the condition is not met.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2023 14:57:46 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-09-20T14:57:46Z</dc:date>
    <item>
      <title>How to rename a conditional field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658120#M227334</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;
&lt;P&gt;I need some help trying to rename a specific field on condition that the renamed field is associated with one or more separate fields.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Fields:

Device_Name
Device_Interface
SomeField

Pseudocode:

&amp;lt;some query&amp;gt;
| if(Device_Name="Value1" AND Device_Interface="Value2" AND SomeField&amp;gt;="NumberX") --&amp;gt; rename Value2 as "This String"
| if(Device_Name="Value1A" AND Device_Interface="Value2A" AND SomeField&amp;lt;"NumberY") --&amp;gt; rename Value2A as "This Other String"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 20:10:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658120#M227334</guid>
      <dc:creator>JohnEGones</dc:creator>
      <dc:date>2023-09-20T20:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658132#M227338</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258618"&gt;@JohnEGones&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you have to use eval with if or case, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_seaRCH&amp;gt;
| eval Value2=if(Device_Name="Value1" AND Device_Interface="Value2" AND SomeField&amp;gt;="NumberX"),"This String",Value2)
| eval Value2A=if(Device_Name="Value1A" AND Device_Interface="Value2A" AND SomeField&amp;lt;"NumberY"),"This Other String",Value2A)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 14:12:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658132#M227338</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-20T14:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658138#M227340</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;rename&lt;/FONT&gt; command can't use conditions, but &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; can.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;some query&amp;gt;
| eval "This String" = if(Device_Name="Value1" AND Device_Interface="Value2" AND SomeField&amp;gt;="NumberX", Value2, null())
| eval "This Other String" = if(Device_Name="Value1A" AND Device_Interface="Value2A" AND SomeField&amp;lt;"NumberY", Value2A, null())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 14:24:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658138#M227340</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-09-20T14:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658140#M227342</link>
      <description>&lt;P&gt;Hi Rich (and Giuseppe),&lt;BR /&gt;&lt;BR /&gt;I appreciate the prompt response, I realized that I messed up what I was asking, so some clarification:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;some search&amp;gt;
| stats count by Device_Name, Device_Interface, SomeField
| (here I want to rename the field *values* in Device_Interface that match the previous conditions, not rename the fieldname itself.)

So here I am renaming the below field value:
Device_Interface="xyz" ==&amp;gt; Device_Interface="x_y_z"

BEFORE rename (this is a sample line from the stats output):
DeviceName, xyz, someValue

AFTER rename:
DeviceName, x_y_z, someValue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 14:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658140#M227342</guid>
      <dc:creator>JohnEGones</dc:creator>
      <dc:date>2023-09-20T14:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658143#M227343</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258618"&gt;@JohnEGones&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;probably there's a terms misunderstanding:&lt;/P&gt;&lt;P&gt;do you want to rename the field name or assign a value to the field based on a condition?&lt;/P&gt;&lt;P&gt;if the first case, please, define the old and the new name to assign to the field and the conditions.&lt;/P&gt;&lt;P&gt;If the second, please define the field to assign the value and the conditions for all the values.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 14:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658143#M227343</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-20T14:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658145#M227344</link>
      <description>&lt;P&gt;Fields have a name and values.&amp;nbsp; They can be renamed.&amp;nbsp; Values do not have names so they cannot be renamed.&lt;/P&gt;&lt;P&gt;To change a value of a field, use the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; command to assign a new value.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Device_Interface="x_y_z"&lt;/LI-CODE&gt;&lt;P&gt;To change selected values of a field, use a condition within the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Device_Interface = if(Device_Interface="foo", "bar", Device_Interface)&lt;/LI-CODE&gt;&lt;P&gt;Putting the field name in the else clause leaves the value unchanged if the condition is not met.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 14:57:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658145#M227344</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-09-20T14:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658149#M227346</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eval Device_Interface=case(Device_Name="Value1" AND Device_Interface="Value2" AND SomeField&amp;gt;="NumberX","This String",Device_Name="Value1A" AND Device_Interface="Value2A" AND SomeField&amp;lt;"NumberY","This Other String",true(),Device_Interface)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 20 Sep 2023 15:02:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658149#M227346</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-09-20T15:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional rename using multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658150#M227347</link>
      <description>&lt;P&gt;Rich,&lt;BR /&gt;&lt;BR /&gt;Ok, this is it. Thank you.&lt;BR /&gt;&lt;BR /&gt;LOL. Some of this is simple when you see/get it, but SPL's versatility sometimes makes simple things opaque/unobvious to me.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Hi Giuseppe,&lt;BR /&gt;&lt;BR /&gt;Thank you for your responses as well&lt;/P&gt;&lt;P&gt;Yeah, it is the second one, but I guess I was unsure if it is better to say, do this as a lookup, based on the number of potential renames, or whether it is less effort to just define the conditions to trigger the rename based on the results from the stats output, since it isn't always the case that a specific interface value will populate.&lt;/P&gt;&lt;P&gt;But coming back to original question, I have clarity on how to proceed given Rich's response.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 15:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rename-a-conditional-field/m-p/658150#M227347</guid>
      <dc:creator>JohnEGones</dc:creator>
      <dc:date>2023-09-20T15:02:28Z</dc:date>
    </item>
  </channel>
</rss>

