<?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: What is the most efficient approach to identify the earliest event for each field-value pair? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-most-efficient-approach-to-identify-the-earliest/m-p/131556#M35902</link>
    <description>&lt;P&gt;&lt;CODE&gt;map&lt;/CODE&gt; rarely is the most efficient approach. Consider something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=msexchange [search that produces the user ids or email addresses of the users you want to investigate | fields user] | stats earliest(_time) as _time by user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will only go through the events for the users you're interested in, going through every bucket once. With &lt;CODE&gt;map&lt;/CODE&gt; you will inevitably go through all the data once per user, making that much less efficient.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Nov 2014 19:45:01 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-11-25T19:45:01Z</dc:date>
    <item>
      <title>What is the most efficient approach to identify the earliest event for each field-value pair?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-most-efficient-approach-to-identify-the-earliest/m-p/131555#M35901</link>
      <description>&lt;P&gt;I am looking to identify the earliest event for each field-value pair.  For example, given a list of usernames from AD, I want to locate the very first email they sent without having to search all emails from all users throughout all time.  My thinking is perhaps to do a search on AD for the username, email, and account creation date (whenCreated), and then feed the emails and whenCreated into a map function onto a search of index=msexchange .. Like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... my AD search for username, email and whenCreated | eval time_b4=relative_time(time_anchor, "-1h")  | eval time_l8r=relative_time(time_anchor, "+1h") | map search="search index=index1 sourcetype=sourcetype1 field1=$field$ earliest=$time_b4$ latest=$time_l8r$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this the most efficient approach?  Will map join events found to the original events populating the $field$ and $time_b4$/$time_l8r$?  Or will it simply add events to the results?  Or will it filter the existing events based on the events found?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:14:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-most-efficient-approach-to-identify-the-earliest/m-p/131555#M35901</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2020-09-28T18:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: What is the most efficient approach to identify the earliest event for each field-value pair?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-most-efficient-approach-to-identify-the-earliest/m-p/131556#M35902</link>
      <description>&lt;P&gt;&lt;CODE&gt;map&lt;/CODE&gt; rarely is the most efficient approach. Consider something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=msexchange [search that produces the user ids or email addresses of the users you want to investigate | fields user] | stats earliest(_time) as _time by user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will only go through the events for the users you're interested in, going through every bucket once. With &lt;CODE&gt;map&lt;/CODE&gt; you will inevitably go through all the data once per user, making that much less efficient.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2014 19:45:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-most-efficient-approach-to-identify-the-earliest/m-p/131556#M35902</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-25T19:45:01Z</dc:date>
    </item>
  </channel>
</rss>

