<?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: subtract value on Subquery in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/subtract-value-on-Subquery/m-p/236980#M46039</link>
    <description>&lt;P&gt;The following search may be closer to what you want. However, you can't have a timechart at the end of this pipeline, because you have factored out &lt;CODE&gt;_time&lt;/CODE&gt; in the stats commands. And you don't need a subsearch.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="service_ppe" source="/var/log/httpClient*.log" OR source="/var/log/request*.log"
| eval type=if(match(source,"/var/log/request.*.log"),"response","external_response")
| chart sum(time_ms) by trace_id type
| eval price_response=response - external_response
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For each trace_id, this calculates the sum of the time_ms. If the time_ms comes from the httpClient log, it is added to the external_response. If the time_ms comes from the request log, it is added to the response. Finally, the difference between the two is calculated for each trace_id. The resulting table will show the trace_id, external_response, response, and price_response.&lt;/P&gt;

&lt;P&gt;If you want a timechart, exactly what do you want to see on the chart?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:26:27 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2020-09-29T12:26:27Z</dc:date>
    <item>
      <title>subtract value on Subquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/subtract-value-on-Subquery/m-p/236979#M46038</link>
      <description>&lt;P&gt;So basically I want to make a subquery where I can use the values founded in the first query to make a subtract from the second subquery&lt;/P&gt;

&lt;P&gt;external_response=Time &lt;/P&gt;

&lt;P&gt;so the idea is get the subquery sum all times for traceId and then subtract the external_time&lt;/P&gt;

&lt;P&gt;Any idea how to accomplish this?&lt;/P&gt;

&lt;P&gt;sourcetype="service_ppe" source="/var/log/httpClient*.log"  | stats sum(time_ms) as external_response by trace_id | join external_response [search sourcetype="service_ppe" source="/var/log/request*.log"  | stats sum(time_ms) as response by trace_id | eval price_response=(response - external_response)  | timechart count(price_response) ]&lt;/P&gt;

&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:26:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/subtract-value-on-Subquery/m-p/236979#M46038</guid>
      <dc:creator>politrons</dc:creator>
      <dc:date>2020-09-29T12:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: subtract value on Subquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/subtract-value-on-Subquery/m-p/236980#M46039</link>
      <description>&lt;P&gt;The following search may be closer to what you want. However, you can't have a timechart at the end of this pipeline, because you have factored out &lt;CODE&gt;_time&lt;/CODE&gt; in the stats commands. And you don't need a subsearch.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="service_ppe" source="/var/log/httpClient*.log" OR source="/var/log/request*.log"
| eval type=if(match(source,"/var/log/request.*.log"),"response","external_response")
| chart sum(time_ms) by trace_id type
| eval price_response=response - external_response
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For each trace_id, this calculates the sum of the time_ms. If the time_ms comes from the httpClient log, it is added to the external_response. If the time_ms comes from the request log, it is added to the response. Finally, the difference between the two is calculated for each trace_id. The resulting table will show the trace_id, external_response, response, and price_response.&lt;/P&gt;

&lt;P&gt;If you want a timechart, exactly what do you want to see on the chart?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:26:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/subtract-value-on-Subquery/m-p/236980#M46039</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2020-09-29T12:26:27Z</dc:date>
    </item>
  </channel>
</rss>

