<?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 Why does fieldformat not work if field is renamed? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459995#M129777</link>
    <description>&lt;P&gt;I have reviewed &lt;A href="https://answers.splunk.com/answers/63730/using-fieldformat-and-rename.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev"&gt;https://answers.splunk.com/answers/63730/using-fieldformat-and-rename.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev&lt;/A&gt; and that gives me a work-around, but I am wondering what is going on behind the interface that breaks "fieldformat" if the field name is then renamed for a better user experience when reviewing the dashboard? If I code my query with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval date=date/1000 | 
eval date=date-(strptime(strftime(date,"%Y-%m-%dT%H:%M:%S.%3N")." PDT","%Y-%m-%dT%H:%M:%S.%N%Z")-date) | 
table date, userid, username, role, page, account | 
fieldformat date=strftime(date, "%F %T") | 
rename date as "Pacific Time"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the resulting table shows the field "Pacific Time" as an epoch timestamp. If I remove the "rename" command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval date=date/1000 | 
eval date=date-(strptime(strftime(date,"%Y-%m-%dT%H:%M:%S.%3N")." PDT","%Y-%m-%dT%H:%M:%S.%N%Z")-date) | 
table date, userid, username, role, page, account | 
fieldformat date=strftime(date, "%F %T") | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the "date" field properly formatted. Why? And am I stuck with not being able to rename a field that I wish to reformat?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;John&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 20:33:40 GMT</pubDate>
    <dc:creator>seomaniv</dc:creator>
    <dc:date>2019-08-22T20:33:40Z</dc:date>
    <item>
      <title>Why does fieldformat not work if field is renamed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459995#M129777</link>
      <description>&lt;P&gt;I have reviewed &lt;A href="https://answers.splunk.com/answers/63730/using-fieldformat-and-rename.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev"&gt;https://answers.splunk.com/answers/63730/using-fieldformat-and-rename.html?utm_source=typeahead&amp;amp;utm_medium=newquestion&amp;amp;utm_campaign=no_votes_sort_relev&lt;/A&gt; and that gives me a work-around, but I am wondering what is going on behind the interface that breaks "fieldformat" if the field name is then renamed for a better user experience when reviewing the dashboard? If I code my query with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval date=date/1000 | 
eval date=date-(strptime(strftime(date,"%Y-%m-%dT%H:%M:%S.%3N")." PDT","%Y-%m-%dT%H:%M:%S.%N%Z")-date) | 
table date, userid, username, role, page, account | 
fieldformat date=strftime(date, "%F %T") | 
rename date as "Pacific Time"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the resulting table shows the field "Pacific Time" as an epoch timestamp. If I remove the "rename" command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval date=date/1000 | 
eval date=date-(strptime(strftime(date,"%Y-%m-%dT%H:%M:%S.%3N")." PDT","%Y-%m-%dT%H:%M:%S.%N%Z")-date) | 
table date, userid, username, role, page, account | 
fieldformat date=strftime(date, "%F %T") | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the "date" field properly formatted. Why? And am I stuck with not being able to rename a field that I wish to reformat?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 20:33:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459995#M129777</guid>
      <dc:creator>seomaniv</dc:creator>
      <dc:date>2019-08-22T20:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why does fieldformat not work if field is renamed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459996#M129778</link>
      <description>&lt;P&gt;The &lt;CODE&gt;fieldformat&lt;/CODE&gt; command doesn't change anything - it's just creates display-time instructions.  If you rename the field then the display-time instructions fail because there is no longer a field by the specified name.&lt;/P&gt;

&lt;P&gt;The solution is to apply &lt;CODE&gt;fieldformat&lt;/CODE&gt; to the final name of the field.  &lt;CODE&gt;fieldformat "Pacific Time" = strftime("Pacific Time", "%F %T")&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 20:57:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459996#M129778</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-08-22T20:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why does fieldformat not work if field is renamed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459997#M129779</link>
      <description>&lt;P&gt;Thanks, Rich, but I'm still not getting it to work if I use "rename":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table Date, userid, username, role, page, account | 
rename Date as "Pacific Time", page as Path, userid as "Associate's ID", username as "Associate's Name", role as "Access Level", account as "Account Number" | 
fieldformat "Pacific Time" = strftime("Pacific Time", "%F %T")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives me a column of "Pacific Time" that is blank, whereas:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table Date, userid, username, role, page, account | 
fieldformat Date = strftime(Date, "%F %T") | 
rename Date as "Pacific Time", page as Path, userid as "Associate's ID", username as "Associate's Name", role as "Access Level", account as "Account Number"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives me a column named "Pacific Time" as an epoch timestamp (expected, given what you have said, though I had understood "rename" to re-name the field and drag with it all of the attributes already tied to that field), and:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table Date, userid, username, role, page, account | 
fieldformat Date = strftime(Date, "%F %T") | 
rename page as Path, userid as "Associate's ID", username as "Associate's Name", role as "Access Level", account as "Account Number"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives me a column named Date that is formatted the way I would like. What I do not understand is why the first option gives me a blank column. It is as if, once "rename" has been run on the field, fieldformat will no longer work on that same field. Is it because "rename" changes it from an epoch timestamp to a string (or something else)?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 19:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459997#M129779</guid>
      <dc:creator>seomaniv</dc:creator>
      <dc:date>2019-08-26T19:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why does fieldformat not work if field is renamed?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459998#M129780</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;fieldformat "Pacific Time" = strftime('Pacific Time', "%F %T")&lt;/CODE&gt;.  The single quotes tell Splunk the string is a field name and not literal text.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 03:04:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-fieldformat-not-work-if-field-is-renamed/m-p/459998#M129780</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-08-29T03:04:19Z</dc:date>
    </item>
  </channel>
</rss>

