<?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: Dynamic column name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80574#M20361</link>
    <description>&lt;P&gt;Hi - I have something similar.  I was curious to see if you were able to figure it out?  I am extracting the action from the logs using regex.  Then timecharting.  i have three actions listed and i wanted to rename the column headers.&lt;/P&gt;

&lt;P&gt;Search is:&lt;/P&gt;

&lt;P&gt;index=app_example&lt;BR /&gt;
 sourcetype=provision_example&lt;BR /&gt;
|rex field=_raw "(?logErrorResult\s+[\d+]+:[A-Za-z\s+]+\s+)"&lt;BR /&gt;&lt;BR /&gt;
|search action="*"&lt;BR /&gt;&lt;BR /&gt;
|timechart span=1d count by action &lt;/P&gt;

&lt;P&gt;So displayed is showing something like the following:&lt;/P&gt;

&lt;P&gt;_time                                     action results (code #1)                                   action results (code #2)                        action results  (code #3)&lt;BR /&gt;
2015-01-28                             Rename to User Failure                                 Rename to System Failure                     Rename to User/System&lt;/P&gt;

&lt;P&gt;I want to rename the code # to the message listed below.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:45:00 GMT</pubDate>
    <dc:creator>jldebell</dc:creator>
    <dc:date>2020-09-28T18:45:00Z</dc:date>
    <item>
      <title>Dynamic column name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80571#M20358</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
My search is like given below and my column names are source file names. As the source file name consists of  directory name, timestamp etc, it is too long to be a column name. I have extracted another field log_name with just the name of the source file without any time stamp or other stuffs. but how can i use the log_name variable in the search so that i can replace the source file name with log name.&lt;/P&gt;

&lt;P&gt;I know that, there is an  alternative idea of extracting the log_name during search time but i don't want the search to be some more lengthy, so i didn't do that. I am curious to know whether there is any other alternative for the same. &lt;BR /&gt;
Search Query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=main  source="$sources$" 
| stats values(wrkf) as "Work Name", values(name) as "Name", values(folder) as "Folder Name", values(reponame) as "Repo Name", values(version) as "Version", values(mode) as "Mode",values(order) as "Order"
|transpose 
|rename column as Properties, "row 1" as "$sources$"
|appendcols [ search  index=main  source="$sourcessecond$" 
    | stats values(wrkf) as "Work Name", values(name) as "Name", values(folder) as "Folder Name", values(reponame) as "Repo Name", values(version) as "Version", values(mode) as "Mode",values(order) as "Order"
     |transpose |rename column as Properties, "row 1" as "$sourcessecond$"] 
|where  '$sources$'!=  '$sourcessecond$'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please Help&lt;BR /&gt;
Thank You&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2013 10:28:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80571#M20358</guid>
      <dc:creator>smolcj</dc:creator>
      <dc:date>2013-04-01T10:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic column name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80572#M20359</link>
      <description>&lt;P&gt;If you have extracted a field named &lt;CODE&gt;log_name&lt;/CODE&gt;, you can use it in the search like any other field. For example,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=main log_name=whatever&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2013 07:07:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80572#M20359</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-04-03T07:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic column name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80573#M20360</link>
      <description>&lt;P&gt;thanks lguinn !!! but how can i replace it instead of $sources$ and $sourcessecond$  in &lt;PRE&gt; &lt;CODE&gt;&lt;BR /&gt;
     |rename column as Properties, "row 1" as "$sourcessecond$"] &lt;BR /&gt;
|where  '$sources$'!=  '$sourcessecond$'&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2013 08:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80573#M20360</guid>
      <dc:creator>smolcj</dc:creator>
      <dc:date>2013-04-03T08:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic column name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80574#M20361</link>
      <description>&lt;P&gt;Hi - I have something similar.  I was curious to see if you were able to figure it out?  I am extracting the action from the logs using regex.  Then timecharting.  i have three actions listed and i wanted to rename the column headers.&lt;/P&gt;

&lt;P&gt;Search is:&lt;/P&gt;

&lt;P&gt;index=app_example&lt;BR /&gt;
 sourcetype=provision_example&lt;BR /&gt;
|rex field=_raw "(?logErrorResult\s+[\d+]+:[A-Za-z\s+]+\s+)"&lt;BR /&gt;&lt;BR /&gt;
|search action="*"&lt;BR /&gt;&lt;BR /&gt;
|timechart span=1d count by action &lt;/P&gt;

&lt;P&gt;So displayed is showing something like the following:&lt;/P&gt;

&lt;P&gt;_time                                     action results (code #1)                                   action results (code #2)                        action results  (code #3)&lt;BR /&gt;
2015-01-28                             Rename to User Failure                                 Rename to System Failure                     Rename to User/System&lt;/P&gt;

&lt;P&gt;I want to rename the code # to the message listed below.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:45:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamic-column-name/m-p/80574#M20361</guid>
      <dc:creator>jldebell</dc:creator>
      <dc:date>2020-09-28T18:45:00Z</dc:date>
    </item>
  </channel>
</rss>

