<?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 How to do a common eval operation with dynamic field values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421198#M120997</link>
    <description>&lt;P&gt;I have a splunk query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=xyz | timechart by field1 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me data like&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time column1 cloumn2 column3 ..... coulumnN&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Now , I want to do a common eval operation on all of these columns. But I do not want to HARD CODE the column names (as I do not know before hand the values of field1)&lt;/P&gt;

&lt;P&gt;Right now I am doing like this &lt;BR /&gt;
&lt;CODE&gt;index=abc sourcetype=xyz | timechart by field1 | eval column1=  column1 + 100 | eval column2= column2 + 100 | eval coulmn3 = column3 +100&lt;/CODE&gt;........ and so on.&lt;/P&gt;

&lt;P&gt;That way I am having multiple eval statements, even though I am performing the same operation eval column=  column + 100&lt;/P&gt;

&lt;P&gt;Can someone guide me a better approach of doing this?&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jul 2018 15:58:32 GMT</pubDate>
    <dc:creator>joydeep741</dc:creator>
    <dc:date>2018-07-05T15:58:32Z</dc:date>
    <item>
      <title>How to do a common eval operation with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421198#M120997</link>
      <description>&lt;P&gt;I have a splunk query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=xyz | timechart by field1 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me data like&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time column1 cloumn2 column3 ..... coulumnN&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Now , I want to do a common eval operation on all of these columns. But I do not want to HARD CODE the column names (as I do not know before hand the values of field1)&lt;/P&gt;

&lt;P&gt;Right now I am doing like this &lt;BR /&gt;
&lt;CODE&gt;index=abc sourcetype=xyz | timechart by field1 | eval column1=  column1 + 100 | eval column2= column2 + 100 | eval coulmn3 = column3 +100&lt;/CODE&gt;........ and so on.&lt;/P&gt;

&lt;P&gt;That way I am having multiple eval statements, even though I am performing the same operation eval column=  column + 100&lt;/P&gt;

&lt;P&gt;Can someone guide me a better approach of doing this?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 15:58:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421198#M120997</guid>
      <dc:creator>joydeep741</dc:creator>
      <dc:date>2018-07-05T15:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a common eval operation with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421199#M120998</link>
      <description>&lt;P&gt;You got forearch command for it. Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=xyz | timechart by field1
| foreach * [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'+100]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using &lt;CODE&gt;*&lt;/CODE&gt; in foreach will process all fields whose name doesn't start with underscore (which are internal fields). The construct &lt;CODE&gt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;&lt;/CODE&gt; (used with double quotes in LHS of equal sign and used with single quotes on RHS, just in case column names may contain special characters) should be use as is. See this for more information:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.1/SearchReference/Foreach"&gt;http://docs.splunk.com/Documentation/Splunk/7.1.1/SearchReference/Foreach&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 16:04:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421199#M120998</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-05T16:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a common eval operation with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421200#M120999</link>
      <description>&lt;P&gt;You can iterate over fields with the &lt;CODE&gt;foreach&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | foreach col* [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + 100]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jul 2018 16:09:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-a-common-eval-operation-with-dynamic-field-values/m-p/421200#M120999</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-07-05T16:09:48Z</dc:date>
    </item>
  </channel>
</rss>

