<?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 to subtract static value from timechart? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248634#M74246</link>
    <description>&lt;P&gt;The foreach would be better approach as it eliminates hard-coding of column names.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2016 14:51:56 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-03-15T14:51:56Z</dc:date>
    <item>
      <title>How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248629#M74241</link>
      <description>&lt;P&gt;I have a timechart which tracks tax calls per half hour. We have monitoring set up which will hit our web service every 1 minute, there is no way to distinguish between a customer or monitor tax call in that index, it only shows the method and tax call. So I need to subtract 30 from each time slot so I can get rid of the monitoring from our results.&lt;/P&gt;

&lt;P&gt;I have an extracted field called Tax which is the name of our web service name (CalculateTax and LookupTax). &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;BEFORE &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                               CalculateTax     LookUpTax
2016-03-14 00:00:00                 143           118
2016-03-14 00:30:00                 151           111
2016-03-14 01:00:00                 103            96
2016-03-14 01:30:00                    125               98
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;AFTER &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                               CalculateTax     LookUpTax
    2016-03-14 00:00:00                 113           88
    2016-03-14 00:30:00                 121           81
    2016-03-14 01:00:00                 73             66
    2016-03-14 01:30:00                    95               68
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Here's my current query&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access   Tax="*" | timechart  count by Tax
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 14:06:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248629#M74241</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T14:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248630#M74242</link>
      <description>&lt;P&gt;You could just add a couple of eval's on the end of your search ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access Tax=* | timechart count by Tax | eval CalculateTax = CalculateTax - 30 | eval LookUpTax = LookupTax - 30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively you could use the foreach command to recalculate both fields at once ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access Tax=* | timechart count by Tax | foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;-30]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 14:22:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248630#M74242</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2016-03-15T14:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248631#M74243</link>
      <description>&lt;P&gt;Unless I didn't understand your question I would use foreach:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=vertex7-access   Tax="*" 
| timechart  count by Tax
| foreach *Tax [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' - 30]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 14:23:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248631#M74243</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-03-15T14:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248632#M74244</link>
      <description>&lt;P&gt;This is very close to what I'm looking for. When I used your first search (The evals) it produced 4 columns.. It had my 2 original tax columns then it had the 2 new columns which were defined int he eval. How do I get rid of the 2 old columns and only keep the 2 new eval columns? &lt;/P&gt;

&lt;P&gt;Here's my new search (This is producing an error now)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access  Tax="*"  | eval CalculateTax = CalculateTax - 30 | eval LookUpTax = LookupTaxAreas - 30 | timechart count by CalculateTax, LookUpTax
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 14:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248632#M74244</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T14:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248633#M74245</link>
      <description>&lt;P&gt;The evals must go after the timechart command - does it still give you two extra columns then? It shouldn't as you are just replacing the two fields that have already been created - CalculateTax and LookupTax. What were the four columns?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 14:43:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248633#M74245</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2016-03-15T14:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248634#M74246</link>
      <description>&lt;P&gt;The foreach would be better approach as it eliminates hard-coding of column names.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 14:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248634#M74246</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-15T14:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248635#M74247</link>
      <description>&lt;P&gt;Yes, this search gave me 4 columns (2 old and 2 new) &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access Tax=* | timechart count by Tax | eval CalculateTax = CalculateTax - 30 | eval LookUpTax = LookupTax - 30
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248635#M74247</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T15:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248636#M74248</link>
      <description>&lt;P&gt;I do agree on not hardcoding my values, but in this case, these web service calls will not change for a long time so it should be safe. I'll take a foreach approach and see if that works &lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:15:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248636#M74248</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T15:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248637#M74249</link>
      <description>&lt;P&gt;Ok, can you tell me the column names? What did the foreach command give you?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:24:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248637#M74249</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2016-03-15T15:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248638#M74250</link>
      <description>&lt;P&gt;Thanks for your input! The issue I'm having with this is that I made an extracted field called Tax which extracts both CalculateTax and LookUpTax. So that Tax field will have 2 values.. I tried taking this approach below but it did not work. CalculateTax70 and LookUpTaxAreas70 is the name of the web service calls which make up the field Tax &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access   Tax="*"  | timechart count by Tax | foreach *Tax [eval CalculateTax = CalculateTax70 - 30, LookUpTax = LookUpTaxAreas70 - 30]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:27:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248638#M74250</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T15:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248639#M74251</link>
      <description>&lt;P&gt;The column names are 'CalculateTax', 'CalculateTax70', LookUpTax', and 'LookupTaxAreas70'.. The new columns which are correctly subtracting 30 are called 'CalculateTax' and 'LookUpTax'.. So I need to get rid of the other 2 columns &lt;/P&gt;

&lt;P&gt;The 2 values which make up the extracted 'Tax' field are called 'CalculateTax70' and 'LookupTaxAreas70' &lt;/P&gt;

&lt;P&gt;Here's my query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vertex7-access Tax="*"  | timechart count by Tax | eval CalculateTax = CalculateTax70 - 30 | eval LookUpTax = LookupTaxAreas70 - 30
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:32:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248639#M74251</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T15:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248640#M74252</link>
      <description>&lt;P&gt;I went ahead and tacked on &lt;CODE&gt;| fields - CalculateTax70, LookupTaxAreas70&lt;/CODE&gt; at the end of my search and it successfully removed the old columns that I don't want.&lt;/P&gt;

&lt;P&gt;I know this is an ugly query and there are better ways of doing it but I don't have a lot of time to doll it up and need a quick fix. Thanks for your help! &lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248640#M74252</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-03-15T15:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract static value from timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248641#M74253</link>
      <description>&lt;P&gt;OK well that makes sense why you are getting 4 columns, you are calling the new fields something different. You can just add this to the end of your search...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields - CalculateTax70, LookupTaxAreas70
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However as somesoni2 said, you are probably better using foreach instead. You don't need to substitute the &amp;lt;&amp;gt; part, just leave it as is.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-static-value-from-timechart/m-p/248641#M74253</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2016-03-15T15:49:32Z</dc:date>
    </item>
  </channel>
</rss>

