<?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 do I rename a field I don't know the name of or will be different into something I know e.g. X in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424374#M121716</link>
    <description>&lt;P&gt;effectively I want &lt;CODE&gt;Y2 = eval *X*&lt;/CODE&gt; but not sure how to do it.&lt;BR /&gt;
Y2 the new field that I know the name of &lt;BR /&gt;
&lt;EM&gt;X&lt;/EM&gt; the field that I partially know the name of&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jan 2019 21:47:20 GMT</pubDate>
    <dc:creator>HattrickNZ</dc:creator>
    <dc:date>2019-01-30T21:47:20Z</dc:date>
    <item>
      <title>How do I rename a field I don't know the name of or will be different into something I know e.g. X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424369#M121711</link>
      <description>&lt;P&gt;How do I rename a field I don't know the name of or will be different into something I know e.g. X??&lt;/P&gt;

&lt;P&gt;So, Imagine I have a field name I  don't know the name of, and I want to change it to a name I do know. How would I do this? &lt;/P&gt;

&lt;P&gt;I was thinking rename * as X&lt;/P&gt;

&lt;P&gt;So instead of this output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date    How do i rename a field I dont't know the name of or will be different into something I know e.g. X
1   1-Sep   0
2   2-Sep   0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would have this output, but I don't know the name of the field to  change it to X.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date    X
1   1-Sep   0
2   2-Sep   0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Some sample serch/data: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval data = "
  1-Sep    0;
  2-Sep    0; 
  " 
 | makemv delim=";" data 
 | mvexpand data 
 | rex field=data "(?&amp;lt;Date&amp;gt;\d+-\w+)\s+(?&amp;lt;kpi1&amp;gt;\d+)" 
 | fields + Date kpi1 | rename kpi1 as "a name with spaces"
 | fields - _time
 | search Date=*
 | rename  "a name with spaces" as "How do i rename a field I dont't know the name of or will be different into something I know e.g. X"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Jan 2019 22:14:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424369#M121711</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2019-01-24T22:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename a field I don't know the name of or will be different into something I know e.g. X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424370#M121712</link>
      <description>&lt;P&gt;If you at least know a regex pattern you can use to extract the field name and value combinations you can use an EXTRACT statement in props, or a combination of props and transforms, to extract your field names and values.&lt;/P&gt;

&lt;P&gt;If, for example your events have something like "field=value" you could use &lt;CODE&gt;(?&amp;lt;_KEY_1&amp;gt;[a-z]+)=(?&amp;lt;_VAL_1&amp;gt;[a-z]+)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Here's an example of a config I've created in props to solve this very issue:&lt;BR /&gt;
 &lt;CODE&gt;[mysourcetype]&lt;BR /&gt;
EXTRACT-custom_sourcetype_extract= (?&amp;lt;_KEY_1&amp;gt;[\w\s]+)\:\s?(?&amp;lt;_VAL_1&amp;gt;[^\n]+)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;For reference: &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/Data/Configureindex-timefieldextraction#Add_a_regex_stanza_for_the_new_field_to_transforms.conf"&gt;Regex Field Name Extraction&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 22:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424370#M121712</guid>
      <dc:creator>dflodstrom</dc:creator>
      <dc:date>2019-01-24T22:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename a field I don't know the name of or will be different into something I know e.g. X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424371#M121713</link>
      <description>&lt;P&gt;tks, but I was hoping to do it in the search not in the config(props and transform), that is if I understand correctly.&lt;/P&gt;

&lt;P&gt;but I did try rex but I think I still need to know the fieldname, but good idea to think to use regex to work on the pattern, I will see if i can do anything more with it. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
  | eval data = "
   1-Sep    0;
   2-Sep    0; 
   " 
  | makemv delim=";" data 
  | mvexpand data 
  | rex field=data "(?&amp;lt;Date&amp;gt;\d+-\w+)\s+(?&amp;lt;kpi1&amp;gt;\d+)" 
  | fields + Date kpi1 | rename kpi1 as "a name with spaces"
  | fields - _time
  | search Date=*
  | rename  "a name with spaces" as "kpi1"
  | rex field=kpi1 "(?&amp;lt;host&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 01:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424371#M121713</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2019-01-25T01:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename a field I don't know the name of or will be different into something I know e.g. X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424372#M121714</link>
      <description>&lt;P&gt;Would something like do work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1
| eval data = "
1-Sep    0;
2-Sep    0; 
" 
| makemv delim=";" data 
| mvexpand data 
| rex field=data "(?&amp;lt;Date&amp;gt;\d+-\w+)\s+(?&amp;lt;kpi1&amp;gt;\d+)" 
| fields + Date kpi1 | rename kpi1 as "a name with spaces"
| fields - _time
| search Date=*
| rename  "a name with spaces" as "How do i rename a field I dont't know the name of or will be different into something I know e.g. X"  | eval X=null()
| foreach * [ eval X=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"!="Date" OR "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"!="OtherFieldsYouWantToKeep",'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',X) ] | table Date OtherFieldsYouWantToKeep X
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 02:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424372#M121714</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-01-25T02:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename a field I don't know the name of or will be different into something I know e.g. X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424373#M121715</link>
      <description>&lt;P&gt;I could not follow that. But it got me thinknig of something like this &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| foreach *X* [ rename '&amp;lt;FIELD&amp;gt;' as Y2]&lt;/CODE&gt;&lt;BR /&gt;
So lets say I have a  field name &lt;CODE&gt;aXa&lt;/CODE&gt; (I only know it has an X in the middle). Can I change the fieldname to something I know e.g. &lt;CODE&gt;Y2&lt;/CODE&gt; ??&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 21:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424373#M121715</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2019-01-30T21:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename a field I don't know the name of or will be different into something I know e.g. X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424374#M121716</link>
      <description>&lt;P&gt;effectively I want &lt;CODE&gt;Y2 = eval *X*&lt;/CODE&gt; but not sure how to do it.&lt;BR /&gt;
Y2 the new field that I know the name of &lt;BR /&gt;
&lt;EM&gt;X&lt;/EM&gt; the field that I partially know the name of&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 21:47:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-rename-a-field-I-don-t-know-the-name-of-or-will-be/m-p/424374#M121716</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2019-01-30T21:47:20Z</dc:date>
    </item>
  </channel>
</rss>

