<?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: Finding devices that are &amp;quot;off&amp;quot; at a date, and then counting how many of them turn &amp;quot;on&amp;quot; on each subsequent day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249167#M74401</link>
    <description>&lt;P&gt;Hey, &lt;/P&gt;

&lt;P&gt;Thank you for the help, that definitely got me further. However, it appears that my output is giving me the total "On"/"Off" counts from the original population ( the 500,000 in the above example) rather than from the sample of "new_set"  (where "new_set" are those devices that were "off" on day=0 i.e. the 200,000). Any idea what I'm doing wrong? &lt;/P&gt;

&lt;P&gt;Also, in my data there appear to be duplicates of the device ID's - so I would need to remove duplicates, would I use a "dedup" command and if so, where in the query?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:44:46 GMT</pubDate>
    <dc:creator>ALevin123</dc:creator>
    <dc:date>2020-09-29T10:44:46Z</dc:date>
    <item>
      <title>Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249165#M74399</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm a first time splunk user trying to figure out how to do the following:&lt;BR /&gt;
I have data describing devices, the devices are either "on" or "off" on any given day. I want to search for the ID's of the devices that are "off" on a specific day (let's call them my "new_set") and then track those (and only those) devices over time and output a count of how many of those devices in new_set are "on" and how many are "off" on each subsequent day. &lt;/P&gt;

&lt;P&gt;Illustration, on day 0 I might find 200,000 devices that are "off" out of a total of 500,000 devices; then I want to count on each subsequent day how many of those specific 200,000 devices are "on" and how many are "off". It may look like this&lt;BR /&gt;
Day 0: 200,000 off; 300,000 on &lt;BR /&gt;
Then, I find the ID's of those 200,000 and call this new_set and then track only them ( I no longer care about the devices that are not in "new_set"):&lt;BR /&gt;
Day 0: 200,000 off; 0 on&lt;BR /&gt;
Day 1: 199,000 off: 1,000 on&lt;BR /&gt;
Day 2: 197,000 off: 3,000 on&lt;BR /&gt;
Day n: .....&lt;/P&gt;

&lt;P&gt;I have tried using a Join command (inner), which eventually works, however the search is very slow / inefficient and I think there must be a more efficient way? &lt;/P&gt;

&lt;P&gt;Does anyone have some recommendations or thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:44:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249165#M74399</guid>
      <dc:creator>ALevin123</dc:creator>
      <dc:date>2020-09-29T10:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249166#M74400</link>
      <description>&lt;P&gt;I think you have couple of option&lt;/P&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;Option 1 (preferred/more efficient)&lt;/EM&gt;&lt;/STRONG&gt;*&lt;BR /&gt;
Get a list of all devices off on Day 0 and store them in a lookup csv (&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchTutorial/Usefieldlookups"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchTutorial/Usefieldlookups&lt;/A&gt;). Your search for this will look something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xyz earliest=day0 latest=day0 state="off" | stats count by id | fields - count | outputlookup listofdevicesoffonday0.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you have this file, you can use it to filter, like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xyz earliest=day1 [| inputlookup listofdevicesoffonday0.csv ] | timechart span=1d count by state | fields - on
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;Option 2, less efficient&lt;/EM&gt;&lt;/STRONG&gt;*&lt;BR /&gt;
Use sub-search (&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchTutorial/Useasubsearch"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchTutorial/Useasubsearch&lt;/A&gt;) to get the filter list. So your search will look like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xyz earliest=day1 [search  index=xyz earliest=day0 latest=day0 state="off" | stats count by id | table id ] | timechart span=1d count by state | fields - on
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Aug 2016 13:19:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249166#M74400</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-28T13:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249167#M74401</link>
      <description>&lt;P&gt;Hey, &lt;/P&gt;

&lt;P&gt;Thank you for the help, that definitely got me further. However, it appears that my output is giving me the total "On"/"Off" counts from the original population ( the 500,000 in the above example) rather than from the sample of "new_set"  (where "new_set" are those devices that were "off" on day=0 i.e. the 200,000). Any idea what I'm doing wrong? &lt;/P&gt;

&lt;P&gt;Also, in my data there appear to be duplicates of the device ID's - so I would need to remove duplicates, would I use a "dedup" command and if so, where in the query?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:44:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249167#M74401</guid>
      <dc:creator>ALevin123</dc:creator>
      <dc:date>2020-09-29T10:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249168#M74402</link>
      <description>&lt;P&gt;Can you share your query&lt;/P&gt;</description>
      <pubDate>Sun, 28 Aug 2016 17:11:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249168#M74402</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-28T17:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249169#M74403</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;

&lt;P&gt;index=xyz source=abc mac!=pqr&lt;BR /&gt;
 [search index=xyz source=abc mac!=pqr timeStamp="day0" state= “off” &lt;BR /&gt;
  [ search source=uvw product=lmn timeStamp="day0" &lt;BR /&gt;
  | dedup Id&lt;BR /&gt;
  | table Id]&lt;BR /&gt;
 | stats count by Id&lt;BR /&gt;
 | dedup time,mac&lt;BR /&gt;
 | table Id]&lt;BR /&gt;
| bin_time span=1d&lt;BR /&gt;
| dedup_time,mac&lt;BR /&gt;
| stats count by _time,operStatus&lt;BR /&gt;
| sort_time&lt;/P&gt;

&lt;P&gt;I changed some of your recommendations; for example, timechart was giving me "0" for weekend days, so I used the bin and sort instead. And "fields - on" wasn't giving me the comparison I needed of seeing "off" and "on" together for a day. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249169#M74403</guid>
      <dc:creator>ALevin123</dc:creator>
      <dc:date>2020-09-29T10:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249170#M74404</link>
      <description>&lt;P&gt;To limit your search, you need at add 'earliest=' in your base search. So in your example you should add day1 as the earliest OR &lt;CODE&gt;timestamp&amp;gt;day0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Also, I notice you have two subsearches, not sure you need both. Combine them for faster searches&lt;/P&gt;

&lt;P&gt;To eliminate duplicates, you can do dedup, or &lt;CODE&gt;stats dc(id) as distinc_ids&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Aug 2016 17:48:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249170#M74404</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-28T17:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249171#M74405</link>
      <description>&lt;P&gt;Thank you, appreciate your help.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Aug 2016 21:40:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249171#M74405</guid>
      <dc:creator>ALevin123</dc:creator>
      <dc:date>2016-08-28T21:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249172#M74406</link>
      <description>&lt;P&gt;Can I ask why you recommended field lookup.csv rather than a KV store in this scenario?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 00:11:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249172#M74406</guid>
      <dc:creator>ALevin123</dc:creator>
      <dc:date>2016-08-29T00:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249173#M74407</link>
      <description>&lt;P&gt;KV store will work as well. .csv is the first thing that came to mind.&lt;/P&gt;

&lt;P&gt;If this helped you with your query, please mark it as answered to close it out. &lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 01:54:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249173#M74407</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-29T01:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Finding devices that are "off" at a date, and then counting how many of them turn "on" on each subsequent day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249174#M74408</link>
      <description>&lt;P&gt;Thank you. &lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 03:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-devices-that-are-quot-off-quot-at-a-date-and-then/m-p/249174#M74408</guid>
      <dc:creator>ALevin123</dc:creator>
      <dc:date>2016-08-29T03:30:29Z</dc:date>
    </item>
  </channel>
</rss>

