<?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 can I access another field value in foreach? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310605#M58359</link>
    <description>&lt;P&gt;can you elaborate a little?&lt;BR /&gt;
how your fields look like today? how you would like them to look?&lt;BR /&gt;
i guess i did not understand your question in full&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 18:42:08 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2018-04-04T18:42:08Z</dc:date>
    <item>
      <title>How can I access another field value in foreach?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310602#M58356</link>
      <description>&lt;P&gt;I am collecting data from several sources into a lookup and would like to rename the various fields to indicate which source they came from--source1_name, source2_ip, and so on. Since I don't have control over how the original fields are named, I'd like to automatically rename them through foreach by prepending the sourcetype for each event to every fieldname in that event. However, I can't get it to work. I tried &lt;BR /&gt;
&lt;CODE&gt;foreach * [ rename &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; as 'sourcetype'_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] &lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
but that takes the quoted string 'sourcetype' literally, rather than looking up the current event's value for sourcetype. Using angle brackets around sourcetype doesn't work either. Is it possible to automate this renaming, or am I going to have to handle each field manually?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310602#M58356</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2020-09-29T18:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I access another field value in foreach?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310603#M58357</link>
      <description>&lt;P&gt;hello there, &lt;/P&gt;

&lt;P&gt;you can remove the single quotes:&lt;BR /&gt;
&lt;CODE&gt;your search ... | foreach * [ rename &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; as sourcetype_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;i think that automating the filed names will be better done while bringing the data or in search time using props and transforms&lt;BR /&gt;
although you mentioned you dont have access, i will recommend to contact your splunk admin and apply the correct sourcetype configurations and fields extractions to the data set in topic&lt;/P&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 20:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310603#M58357</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-02T20:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I access another field value in foreach?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310604#M58358</link>
      <description>&lt;P&gt;That won't work. It just prepends the string sourcetype. I want the value of the sourcetype field.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 18:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310604#M58358</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2018-04-04T18:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I access another field value in foreach?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310605#M58359</link>
      <description>&lt;P&gt;can you elaborate a little?&lt;BR /&gt;
how your fields look like today? how you would like them to look?&lt;BR /&gt;
i guess i did not understand your question in full&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 18:42:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-access-another-field-value-in-foreach/m-p/310605#M58359</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-04T18:42:08Z</dc:date>
    </item>
  </channel>
</rss>

