<?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 Query to loop through data in splunk in Security</title>
    <link>https://community.splunk.com/t5/Security/Query-to-loop-through-data-in-splunk/m-p/81617#M2722</link>
    <description>&lt;P&gt;I've below lines in my log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...useremail=abc@fdsf.com id=1234 ....
...useremail=pqr@fdsf.com id=4565 ....
...useremail=xyz@fdsf.com id=5773 ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;OL&gt;
&lt;LI&gt;  Capture all those ids for the period from -1d@d to @d&lt;/LI&gt;
&lt;LI&gt;  For each id, search from beginning of index until -1d@d &amp;amp; see if the id is already present by comparing actual id field&lt;/LI&gt;
&lt;LI&gt;  If it is not present, then add it into the counter&lt;/LI&gt;
&lt;LI&gt;  Display this final count.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I just need the final count in one query.&lt;/P&gt;

&lt;P&gt;Can I achieve this in Splunk?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2011 16:02:50 GMT</pubDate>
    <dc:creator>freephoneid</dc:creator>
    <dc:date>2011-09-26T16:02:50Z</dc:date>
    <item>
      <title>Query to loop through data in splunk</title>
      <link>https://community.splunk.com/t5/Security/Query-to-loop-through-data-in-splunk/m-p/81617#M2722</link>
      <description>&lt;P&gt;I've below lines in my log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...useremail=abc@fdsf.com id=1234 ....
...useremail=pqr@fdsf.com id=4565 ....
...useremail=xyz@fdsf.com id=5773 ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;OL&gt;
&lt;LI&gt;  Capture all those ids for the period from -1d@d to @d&lt;/LI&gt;
&lt;LI&gt;  For each id, search from beginning of index until -1d@d &amp;amp; see if the id is already present by comparing actual id field&lt;/LI&gt;
&lt;LI&gt;  If it is not present, then add it into the counter&lt;/LI&gt;
&lt;LI&gt;  Display this final count.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I just need the final count in one query.&lt;/P&gt;

&lt;P&gt;Can I achieve this in Splunk?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2011 16:02:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-to-loop-through-data-in-splunk/m-p/81617#M2722</guid>
      <dc:creator>freephoneid</dc:creator>
      <dc:date>2011-09-26T16:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Query to loop through data in splunk</title>
      <link>https://community.splunk.com/t5/Security/Query-to-loop-through-data-in-splunk/m-p/81618#M2723</link>
      <description>&lt;P&gt;It's much better to state your problem, rather than presume an algorithm for it. Would it be accurate to say that you want to know "how many people logged in for the first time yesterday"?&lt;/P&gt;

&lt;P&gt;If that's the case, then I would ask you further: Are you running this query once? Or every day? Or how often, approximately? And I would ask, how many days are in your index before yesterday, approximately? Do you plan to keep this history around forever, or just a limited amount of time?&lt;/P&gt;

&lt;P&gt;A simple, one shot answer is below. It is extremely inefficient if you are going to be running this query regularly, and/or if you have a large amount of history. But maybe your data set isn't that large in total, so it doesn't matter.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... latest=@d 
    | stats min(_time) as firsttime by id 
    | where (relative_time(now(),"-1d@d") &amp;lt;= firsttime) AND (firsttime &amp;lt; relative_time(now(),"@d"))
    | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2011 22:37:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-to-loop-through-data-in-splunk/m-p/81618#M2723</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-09-26T22:37:11Z</dc:date>
    </item>
  </channel>
</rss>

