<?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 plot differences of values over time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638536#M221272</link>
    <description>&lt;P&gt;hi all&lt;/P&gt;
&lt;P&gt;I have a data set like this:&lt;/P&gt;
&lt;P&gt;_time, duration, category&lt;/P&gt;
&lt;P&gt;XXX, 0.145,A&lt;/P&gt;
&lt;P&gt;XXY, 0.177,B&lt;/P&gt;
&lt;P&gt;XXZ, 0.178, A&lt;/P&gt;
&lt;P&gt;XXX, XXY,XXZ are _time&lt;/P&gt;
&lt;P&gt;i plot a graph like timechart avg(duration) by category and it shows two lines perfectly&lt;/P&gt;
&lt;P&gt;but I want to plot a graph over time of the differences between the two averages (two categories). How to do that?&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2023 10:35:53 GMT</pubDate>
    <dc:creator>henry_chiang</dc:creator>
    <dc:date>2023-04-04T10:35:53Z</dc:date>
    <item>
      <title>How to plot differences of values over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638536#M221272</link>
      <description>&lt;P&gt;hi all&lt;/P&gt;
&lt;P&gt;I have a data set like this:&lt;/P&gt;
&lt;P&gt;_time, duration, category&lt;/P&gt;
&lt;P&gt;XXX, 0.145,A&lt;/P&gt;
&lt;P&gt;XXY, 0.177,B&lt;/P&gt;
&lt;P&gt;XXZ, 0.178, A&lt;/P&gt;
&lt;P&gt;XXX, XXY,XXZ are _time&lt;/P&gt;
&lt;P&gt;i plot a graph like timechart avg(duration) by category and it shows two lines perfectly&lt;/P&gt;
&lt;P&gt;but I want to plot a graph over time of the differences between the two averages (two categories). How to do that?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 10:35:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638536#M221272</guid>
      <dc:creator>henry_chiang</dc:creator>
      <dc:date>2023-04-04T10:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Plot differences of values over time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638574#M221279</link>
      <description>&lt;P&gt;If you examine the stats table after timechart commands, you will see two columns A and B. &amp;nbsp;Treat them the same as field names so you can calculate the difference. &amp;nbsp;For example,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart avg(duration) by category
| eval diff = A - B
| fields diff&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 07:33:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638574#M221279</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-04T07:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Plot differences of values over time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638718#M221314</link>
      <description>&lt;P&gt;Thanks it works fine!&lt;/P&gt;&lt;P&gt;but what if I did&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timechart avg(duration),p95(duration) by category&lt;/LI-CODE&gt;&lt;P&gt;then how do I properly rename the fields to do the calculation between the averages and the p95s?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 21:27:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638718#M221314</guid>
      <dc:creator>henry_chiang</dc:creator>
      <dc:date>2023-04-04T21:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Plot differences of values over time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638729#M221318</link>
      <description>&lt;P&gt;When you use timechart with split by, the columns are named with the aggregation + the split, so use this technique&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=15m avg(duration) as avg p95(duration) as p95 by category
| foreach avg* [ eval "diff&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"='p95&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;'-'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' ]&lt;/LI-CODE&gt;&lt;P&gt;By using '&lt;STRONG&gt;as avg'&lt;/STRONG&gt; and '&lt;STRONG&gt;as p95&lt;/STRONG&gt;' means you have consistent naming and you can then use the foreach, which will iterate all the &lt;STRONG&gt;avg: category&lt;/STRONG&gt; fields and use the foreach tokens &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; and &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; to reference the other fields.&lt;/P&gt;&lt;P&gt;So this will create fields&amp;nbsp;&lt;STRONG&gt;diff:&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;category&lt;/STRONG&gt; which is the p95 - the avg. Note the use of SINGLE quotes on the right hand side and double quotes on the left!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 23:17:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/638729#M221318</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-04-04T23:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot differences of values over time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/639672#M221667</link>
      <description>&lt;P&gt;Just add this:&lt;BR /&gt;| eval diff = B-A&lt;BR /&gt;| fields - A B&lt;BR /&gt;&lt;BR /&gt;Like this:&lt;BR /&gt;index="_internal" AND source="*metrics.log" AND kb&lt;BR /&gt;| eval category=ev%2&lt;BR /&gt;| eval category = if(category==0, "A", "B")&lt;BR /&gt;| timechart avg(kb) BY category&lt;BR /&gt;| eval diff = B-A&lt;BR /&gt;| fields - A B&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 17:25:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-plot-differences-of-values-over-time/m-p/639672#M221667</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-12T17:25:56Z</dc:date>
    </item>
  </channel>
</rss>

