<?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: Join with calculated earliest in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559784#M159049</link>
    <description>&lt;P&gt;Rather than using a join you could try append and stats by id - you may end up with some mutlivalue fields though depending on your data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="..." sourcetype="..." someField=someValue [search index="..." sourcetype="..." myField=abc
| sort -_time
| head 1
| eval earliest=(collectionTimeEpoch-maxDurationInSeconds)
| stats min(earliest) as earliest]
| append [search index="..." sourcetype="..." myField=abc
  | sort -_time
  | head 1
  | eval itemList=split(items,",")
  | mvexpand itemList
  | rex field=itemList "(?&amp;lt;id&amp;gt;[-\w\d]+)#content=(?&amp;lt;content&amp;gt;[-\w\d]+)"
  | eval start=(collectionTimeEpoch-maxDurationInSeconds)]
| stats values(*) as * by id&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 16 Jul 2021 09:52:00 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-07-16T09:52:00Z</dc:date>
    <item>
      <title>Join with calculated earliest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559771#M159042</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I don't know if it is possible, but I would like to specify the time range of a join subsearch from a calculated value.&lt;/P&gt;&lt;P&gt;I have a similar log record and query:&lt;BR /&gt;Log record:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;myField=abc, collectionTimeEpoch=1626358999, maxDurationInSeconds=10, items=[id=00000000-00000000-00000000-00000000#content=123,id=myId2#content=456]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query is similar to the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="..." sourcetype="..." myField=abc
| sort -_time
| head 1
| eval itemList=split(items,",")
| mvexpand itemList
| rex field=itemList "(?&amp;lt;id&amp;gt;[-\w\d]+)#content=(?&amp;lt;content&amp;gt;[-\w\d]+)"
| eval start=(collectionTimeEpoch-maxDurationInSeconds)
| join type=left id [search earliest=-2d@d index="..." sourcetype="..." someField=someValue ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to replace&amp;nbsp;earliest=-2d@d&amp;nbsp; to something like earliest=start, but that is not working. I have also tried&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| join type=left id [search earliest=[stats count | eval earliest=(collectionTimeEpoch-maxDurationInSeconds) |fields earliest ]  index="..." sourcetype="..." someField=someValue ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help me with this?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 07:08:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559771#M159042</guid>
      <dc:creator>szabolcs</dc:creator>
      <dc:date>2021-07-16T07:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Join with calculated earliest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559775#M159046</link>
      <description>&lt;P&gt;The reason it isn't working is that the subsearch is executed independently from the first search and nothing from the first search is passed in or available to the subsearch e.g.&amp;nbsp;collectionTimeEpoch and maxDurationInSeconds.&lt;/P&gt;&lt;P&gt;You might be able to invert your search (and to be honest I am not sure if this will work) such that you construct a search to return the earliest earliest time from all the events and return that as an argument to the search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="..." sourcetype="..." someField=someValue [search index="..." sourcetype="..." myField=abc
| sort -_time
| head 1
| eval itemList=split(items,",")
| mvexpand itemList
| rex field=itemList "(?&amp;lt;id&amp;gt;[-\w\d]+)#content=(?&amp;lt;content&amp;gt;[-\w\d]+)"
| eval earliest=(collectionTimeEpoch-maxDurationInSeconds)
| stats min(earlliest) as earliest]&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Jul 2021 07:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559775#M159046</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-07-16T07:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Join with calculated earliest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559776#M159047</link>
      <description>&lt;P&gt;Thanks, that is a great idea! The following seems to be mostly working.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="..." sourcetype="..." someField=someValue [search index="..." sourcetype="..." myField=abc
| sort -_time
| head 1
| eval earliest=(collectionTimeEpoch-maxDurationInSeconds)
| stats min(earlliest) as earliest]
| join id [search index="..." sourcetype="..." myField=abc
  | sort -_time
  | head 1
  | eval itemList=split(items,",")
  | mvexpand itemList
  | rex field=itemList "(?&amp;lt;id&amp;gt;[-\w\d]+)#content=(?&amp;lt;content&amp;gt;[-\w\d]+)"
  | eval earliest=(collectionTimeEpoch-maxDurationInSeconds)]&lt;/LI-CODE&gt;&lt;P&gt;The only problem is that Splunk does not support right(or full outer) join so if the main search does not find the value, I won't see the result of the subsearch either.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 08:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559776#M159047</guid>
      <dc:creator>szabolcs</dc:creator>
      <dc:date>2021-07-16T08:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Join with calculated earliest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559784#M159049</link>
      <description>&lt;P&gt;Rather than using a join you could try append and stats by id - you may end up with some mutlivalue fields though depending on your data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="..." sourcetype="..." someField=someValue [search index="..." sourcetype="..." myField=abc
| sort -_time
| head 1
| eval earliest=(collectionTimeEpoch-maxDurationInSeconds)
| stats min(earliest) as earliest]
| append [search index="..." sourcetype="..." myField=abc
  | sort -_time
  | head 1
  | eval itemList=split(items,",")
  | mvexpand itemList
  | rex field=itemList "(?&amp;lt;id&amp;gt;[-\w\d]+)#content=(?&amp;lt;content&amp;gt;[-\w\d]+)"
  | eval start=(collectionTimeEpoch-maxDurationInSeconds)]
| stats values(*) as * by id&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Jul 2021 09:52:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/559784#M159049</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-07-16T09:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Join with calculated earliest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/560026#M159135</link>
      <description>&lt;P&gt;This became a bit more complex than I had expected, but it works after taking care of the multivalue fields. Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 11:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-with-calculated-earliest/m-p/560026#M159135</guid>
      <dc:creator>szabolcs</dc:creator>
      <dc:date>2021-07-19T11:26:54Z</dc:date>
    </item>
  </channel>
</rss>

