<?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: Display running difference between multiple event counts in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299803#M40107</link>
    <description>&lt;P&gt;I'm attempting to correlate 4 different events (a start and stop for each sensor set) into 2 line graphs (one for each sensor) on a single panel. As there should only ever be a difference of 1 between a sensor set's number of starts and stops, wanted to aggregate the sum of each to show when the sensors reported activity. I chose streamstats as it mentioned aggregated data and running the statistics on each new event, which I felt was what I wanted, though I'm certainly open to a different suggestion if there is a better implementation.&lt;/P&gt;

&lt;P&gt;On another note, do you have any insight as to why the eval on the SM_C.key=&lt;EM&gt;X&lt;/EM&gt; does not return a match? Thank you for all your help.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 13:15:21 GMT</pubDate>
    <dc:creator>pjbuchan596</dc:creator>
    <dc:date>2018-01-11T13:15:21Z</dc:date>
    <item>
      <title>Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299797#M40101</link>
      <description>&lt;P&gt;Hello all, I have two sets of sensors, and want to display a line graph for each of the set of sensors over time, giving whether or not they detect anything. I have 4 different event types, an "on" and "off" for each of the sensor sets that tell when the sensors start detecting something (on) and when they stop detecting something (off). I would like a line graph with a line depicting each of the sensor sets, going between "on" and "off" for each line to show activity. &lt;/P&gt;

&lt;P&gt;As an example for what I'm trying / my thinking, I have this, though I'm getting an error with the streamstats command and recognize this implementation is likely far off. &lt;/P&gt;

&lt;P&gt;index=main (SM_C.key="PresenceMonitor.highConfidenceUsage" OR SM_C.key="PresenceMonitor.highConfidenceUsage.start" OR SM_C.key="RoomMonitor.Occupied" OR SM_C.key="RoomMonitor.UnOccupied") SM_C.value.data.room!="error"&lt;BR /&gt;
| streamstats eval(count(SM_C.key="RoomMonitor.Occupied") - count(SM_C.key="RoomMonitor.UnOccupied")) as A_in_use eval(count(SM_C.key="PresenceMonitor.highConfidenceUsage.start") - count(SM_C.key="PresenceMonitor.highConfidenceUsage")) as B_in_use&lt;BR /&gt;
| eval fan=mvrange(1, 2.0001)&lt;BR /&gt;
| mvexpand fan&lt;BR /&gt;
| eval Usage=case(fan=1,"A", fan=2,"B")&lt;BR /&gt;
| eval Value=case(fan=1,A_in_use, fan=2,B_in_use)&lt;BR /&gt;
| chart values(Value) by Usage&lt;/P&gt;

&lt;P&gt;The PresenceMonitor and the RoomMonitor are the two given sensor sets, with the occupied and start events giving the detection start (respectively) and the UnOccupied / Usage events giving the detection end (respectively). The use of mvexpand and case was an attempt to consolidate the 4 different events into 2 for charting the line graph.&lt;/P&gt;

&lt;P&gt;Thank you for any help!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299797#M40101</guid>
      <dc:creator>pjbuchan596</dc:creator>
      <dc:date>2020-09-29T17:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299798#M40102</link>
      <description>&lt;P&gt;Streamstats can only do aggregation functions, not mathematical.  And your count/eval were switched around.  To accomplish what that streamstats line appears to be attempting, you'd do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count(eval(SM_C.key="RoomMonitor.Occupied")) AS occupied_count, count(SM_C.key="RoomMonitor.UnOccupied") AS unoccupied_count count(eval(SM_C.key="PresenceMonitor.highConfidenceUsage.start")) AS start_count, count(SM_C.key="PresenceMonitor.highConfidenceUsage") AS high_confidence_count
| eval A_in_use=occupied_count-unoccupied_count, B_in_use=start_count-high_confidence_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jan 2018 15:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299798#M40102</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-10T15:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299799#M40103</link>
      <description>&lt;P&gt;When I tried your answer as is I get the following error:&lt;/P&gt;

&lt;P&gt;Error in 'streamstats' command: The eval expression for dynamic field 'eval(SM_C.key="RoomMonitor.Occupied") AS occupied_count, count(SM_C.key="RoomMonitor.UnOccupied")' is invalid. Error='The operator at ') AS occupied_count, count(SM_C.key="RoomMonitor.UnOccupied"' is invalid.' &lt;/P&gt;

&lt;P&gt;Tried making the slight following adjustment, just for kicks, and received "The argument 'as' is invalid:&lt;/P&gt;

&lt;PRE&gt;| streamstats count(eval(SM_C.key="RoomMonitor.Occupied")) AS occupied_count, count(eval(SM_C.key="RoomMonitor.UnOccupied")) AS unoccupied_count as A_in_use count(eval(SM_C.key="PresenceMonitor.highConfidenceUsage.start") AS start_count, count(SM_C.key="PresenceMonitor.highConfidenceUsage")) AS high_confidence_count
| eval A_in_use=occupied_count-unoccupied_count, B_in_use=start_count-high_confidence_count&lt;/PRE&gt;

&lt;P&gt;Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299799#M40103</guid>
      <dc:creator>pjbuchan596</dc:creator>
      <dc:date>2020-09-29T17:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299800#M40104</link>
      <description>&lt;P&gt;Oops, edited to correct &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 17:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299800#M40104</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-10T17:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299801#M40105</link>
      <description>&lt;P&gt;Definitely closer, I added two uses of the "eval" function inside two of the count calls. Looked like it wasn't attempting to match the key otherwise. Now looks as follows:&lt;/P&gt;

&lt;PRE&gt;index=main (SM_C.key="PresenceMonitor.highConfidenceUsage" OR SM_C.key="PresenceMonitor.highConfidenceUsage.start" OR SM_C.key="RoomMonitor.Occupied" OR SM_C.key="RoomMonitor.UnOccupied") SM_C.value.data.room!="error"
| streamstats count(eval(SM_C.key="RoomMonitor.Occupied")) AS occupied_count, count(eval(SM_C.key="RoomMonitor.UnOccupied")) AS unoccupied_count count(eval(SM_C.key="PresenceMonitor.highConfidenceUsage.start")) AS start_count, count(eval(SM_C.key="PresenceMonitor.highConfidenceUsage")) AS high_confidence_count
| eval A_in_use=occupied_count-unoccupied_count, B_in_use=start_count-high_confidence_count
| table novum_in_use, occupied_count, unoccupied_count&lt;/PRE&gt;

&lt;P&gt;I've added the table to view the output created. So far all of the "in_use" values and count values are reporting a count of 0, though I've verified that there are events they should be counting that match the criteria. This leads me to believe that the "eval(SM_C.key=&lt;EM&gt;X&lt;/EM&gt;)" never return true. Currently investigating.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:36:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299801#M40105</guid>
      <dc:creator>pjbuchan596</dc:creator>
      <dc:date>2020-09-29T17:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299802#M40106</link>
      <description>&lt;P&gt;Can you explain why you want to use streamstats here? I'm not clear what it is you're trying to accomplish with that specific command.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 02:03:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299802#M40106</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T02:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299803#M40107</link>
      <description>&lt;P&gt;I'm attempting to correlate 4 different events (a start and stop for each sensor set) into 2 line graphs (one for each sensor) on a single panel. As there should only ever be a difference of 1 between a sensor set's number of starts and stops, wanted to aggregate the sum of each to show when the sensors reported activity. I chose streamstats as it mentioned aggregated data and running the statistics on each new event, which I felt was what I wanted, though I'm certainly open to a different suggestion if there is a better implementation.&lt;/P&gt;

&lt;P&gt;On another note, do you have any insight as to why the eval on the SM_C.key=&lt;EM&gt;X&lt;/EM&gt; does not return a match? Thank you for all your help.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 13:15:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299803#M40107</guid>
      <dc:creator>pjbuchan596</dc:creator>
      <dc:date>2018-01-11T13:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299804#M40108</link>
      <description>&lt;P&gt;I think you just need to add single quotes around your &lt;CODE&gt;SM_C.key&lt;/CODE&gt; in your eval.  This run anywhere search shows the concept working:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| append [| makeresults | eval sensor="sensor1", _time=1000, SM_C.key="RoomMonitor.Occupied"]
| append [| makeresults | eval sensor="sensor2", _time=995, SM_C.key="RoomMonitor.Occupied"]
| append [| makeresults | eval sensor="sensor1", _time=993, SM_C.key="RoomMonitor.UnOccupied"]
| append [| makeresults | eval sensor="sensor2", _time=993, SM_C.key="RoomMonitor.Occupied"]
| streamstats count(eval('SM_C.key'="RoomMonitor.Occupied")) AS occupied_count, count(eval('SM_C.key'="RoomMonitor.UnOccupied")) AS unoccupied_count BY sensor
| eval current_occupied_diff=occupied_count-unoccupied_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But keep in mind, also, that streamstats considers events &lt;EM&gt;above&lt;/EM&gt; it (those already returned by the search), which are typically in reverse chronological order.  This needs to be considered when you run your &lt;CODE&gt;streamstats&lt;/CODE&gt;, you may need to &lt;CODE&gt;reverse&lt;/CODE&gt; things first (but that may be a bad idea if there is a lot of data.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 18:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299804#M40108</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T18:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299805#M40109</link>
      <description>&lt;P&gt;Thank you, that got the count for working for each of the different event types. Now left is the visualization.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 18:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299805#M40109</guid>
      <dc:creator>pjbuchan596</dc:creator>
      <dc:date>2018-01-12T18:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Display running difference between multiple event counts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299806#M40110</link>
      <description>&lt;P&gt;Great!&lt;/P&gt;

&lt;P&gt;If you consider the answer valid and satisfactory, please accept it so this question no longer appears open.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 19:40:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Display-running-difference-between-multiple-event-counts/m-p/299806#M40110</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-12T19:40:13Z</dc:date>
    </item>
  </channel>
</rss>

