<?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: Substracting chart contents over a range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77981#M19722</link>
    <description>&lt;P&gt;well, this should work. Create three counts (c, IN and OUT) in the stats function, and just &lt;CODE&gt;eval&lt;/CODE&gt; the difference from the constant after the &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=syslog |... 
| eval range = if(date_hour &amp;gt;= 3 OR date_hour &amp;lt;= 4, "in", "out") 
| stats c c(eval(range="in")) as IN c(eval(range="out")) as OUT 
| eval Difference = 100 - c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jan 2013 08:47:37 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-01-04T08:47:37Z</dc:date>
    <item>
      <title>Substracting chart contents over a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77980#M19721</link>
      <description>&lt;P&gt;I have a question about constants and timechart/chart/stats&lt;/P&gt;

&lt;P&gt;I have a search like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="syslog" | ... | eval target = 100 | eval range=case( (date_hour&amp;gt;=3 AND date_hour&amp;lt;=4), "in", (date_hour&amp;lt;3 OR date_hour&amp;gt;4), "out" ) | stats count by range
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to be able to add a &lt;CODE&gt;| append&lt;/CODE&gt;  such that i can print the difference.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Difference = 100 - "in" - "out"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas on how stats works in the context of deducting two values gathered over time from a constant and displaying it on the exact same time chart ? &lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 01:42:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77980#M19721</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2013-01-04T01:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting chart contents over a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77981#M19722</link>
      <description>&lt;P&gt;well, this should work. Create three counts (c, IN and OUT) in the stats function, and just &lt;CODE&gt;eval&lt;/CODE&gt; the difference from the constant after the &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=syslog |... 
| eval range = if(date_hour &amp;gt;= 3 OR date_hour &amp;lt;= 4, "in", "out") 
| stats c c(eval(range="in")) as IN c(eval(range="out")) as OUT 
| eval Difference = 100 - c
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 08:47:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77981#M19722</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-01-04T08:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting chart contents over a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77982#M19723</link>
      <description>&lt;P&gt;And for timechart / chart its as simple as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    sourcetype="syslog" | ... | eval target = 100 | eval range=case( (date_hour&amp;gt;=3 AND date_hour&amp;lt;=4), "in", (date_hour&amp;lt;3 OR date_hour&amp;gt;4), "out" ) | timechart count by range | eval Difference=100-in-out
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jan 2013 11:31:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77982#M19723</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-04T11:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting chart contents over a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77983#M19724</link>
      <description>&lt;P&gt;Hi, What if its not a constant like 100.&lt;/P&gt;

&lt;P&gt;What if its read from a an inputlookup like so&lt;/P&gt;

&lt;P&gt;| inputlookup constantTable | where OrgId=100 | field CONSTANT&lt;/P&gt;

&lt;P&gt;CONSTANT = 100&lt;/P&gt;

&lt;P&gt;How do I incorporate an appendpipe into this without losing "in" and "out" ?&lt;/P&gt;

&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 18:30:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Substracting-chart-contents-over-a-range/m-p/77983#M19724</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2013-01-04T18:30:03Z</dc:date>
    </item>
  </channel>
</rss>

