<?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: Substract two search in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619259#M9114</link>
    <description>&lt;P&gt;Yep silly me the query were wrong, thanks&amp;nbsp; lot!&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2022 09:43:25 GMT</pubDate>
    <dc:creator>politrons</dc:creator>
    <dc:date>2022-11-02T09:43:25Z</dc:date>
    <item>
      <title>How do I subtract two search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618836#M9104</link>
      <description>&lt;P&gt;I´m making a union of two search, and now I´m trying to make a subtract of the two variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| set union [search "Output MeshRequestId" | stats avg(time) as avgTimeOut ] [search "Input MeshRequestId" | stats avg(time) as avgTimeInt ]  |stats count(eval(diff=avgTimeOut-avgTimeInt)) as TimeInThrottler&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything fine before the latest count. I can see the definition of two avg variables.&lt;/P&gt;
&lt;P&gt;But when I do the &lt;STRONG&gt;stats count(eval(diff=avgTimeOut-avgTimeInt)) as TimeInThrottler&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Always return 0. Any idea what is wrong&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 09:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618836#M9104</guid>
      <dc:creator>politrons</dc:creator>
      <dc:date>2022-10-31T09:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618839#M9105</link>
      <description>&lt;P&gt;union is producing 2 events, one with avgTimeOut and one with avgTimeInt - the calculation is working on one event at a time from the pipeline, so for each event, one of the fields is null.&lt;/P&gt;&lt;P&gt;Have you considered using appendcols in this scenario?&lt;/P&gt;</description>
      <pubDate>Sun, 30 Oct 2022 11:16:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618839#M9105</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-30T11:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618845#M9106</link>
      <description>&lt;P&gt;Thanks for the answer, any example that I can refer of how it should be done using appendcols for this use case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Oct 2022 14:35:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618845#M9106</guid>
      <dc:creator>politrons</dc:creator>
      <dc:date>2022-10-30T14:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618893#M9107</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search "Output MeshRequestId" | stats avg(time) as avgTimeOut 
| appendcols [search "Input MeshRequestId" | stats avg(time) as avgTimeInt ]  | stats count(eval(diff=avgTimeOut-avgTimeInt)) as TimeInThrottler&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 09:12:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618893#M9107</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-31T09:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618908#M9108</link>
      <description>&lt;P&gt;At that point you could also simply replace that last stats by an eval. (Unless I'm somehow completely missing what you're trying to achieve with that stats)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search "Output MeshRequestId"
| stats avg(time) as avgTimeOut 
| appendcols [search "Input MeshRequestId" | stats avg(time) as avgTimeInt ]  | eval TimeInThrottler = avgTimeOut - avgTimeInt&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 12:36:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/618908#M9108</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2022-10-31T12:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619247#M9110</link>
      <description>&lt;P&gt;Thanks for all the answers, after apply both option of union and append. I got same result&lt;/P&gt;&lt;P&gt;Only avgTimeInt is present, and I cannot show the total Difference.&lt;/P&gt;&lt;P&gt;Also I would like to use the result in stats or timechar if is possible&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splunk_issues.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22278i4475F18C28DC1EFC/image-size/large?v=v2&amp;amp;px=999" role="button" title="splunk_issues.PNG" alt="splunk_issues.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 08:42:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619247#M9110</guid>
      <dc:creator>politrons</dc:creator>
      <dc:date>2022-11-02T08:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619252#M9112</link>
      <description>&lt;P&gt;It looks like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"Output MeshRequestId"
| stats avg(time) as avgTimeOut &lt;/LI-CODE&gt;&lt;P&gt;is not producing any results - please check the events from the search to make sure they have the time field with that exact name.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 08:57:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619252#M9112</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-02T08:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two search</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619259#M9114</link>
      <description>&lt;P&gt;Yep silly me the query were wrong, thanks&amp;nbsp; lot!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 09:43:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-subtract-two-search/m-p/619259#M9114</guid>
      <dc:creator>politrons</dc:creator>
      <dc:date>2022-11-02T09:43:25Z</dc:date>
    </item>
  </channel>
</rss>

