<?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: Why can't I see stats values from a subsearch? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248014#M73999</link>
    <description>&lt;P&gt;This might hold some answers; it seems like you want to know the time difference between two events not the time difference between the start and end of an event/action. If you just want to get something like the start and end of something you could use &lt;CODE&gt;| stats range(_time) by connectionID&lt;/CODE&gt; or the transaction command creates a new field call duration (more expensive search). Otherwise I think you are likely going to need to use streamstats&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/129084/calculate-the-time-between-a-transaction-events-starttime-and-the-endtime-of-the-previous-event.html"&gt;https://answers.splunk.com/answers/129084/calculate-the-time-between-a-transaction-events-starttime-and-the-endtime-of-the-previous-event.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Nov 2015 20:22:18 GMT</pubDate>
    <dc:creator>Runals</dc:creator>
    <dc:date>2015-11-20T20:22:18Z</dc:date>
    <item>
      <title>Why can't I see stats values from a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248011#M73996</link>
      <description>&lt;P&gt;Hello.  I want to extract timestamp data using stats list() and display that data as part of a larger search, so I run it inside of a subsearch.&lt;BR /&gt;
If I run the search as the main search, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Connected" | stats list(date_hour) as myHour | eval myTime=mvindex(myHour, 5) | eval myDiff=myTime - 2 | table myDiff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it works fine, and displays a number.&lt;BR /&gt;
When I run it as part of a subsearch, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;("This" OR "That") AND NOT ("Other" OR "Those") | join connectionId [ search "Connected" | stats list(date_hour) as myHour | eval myTime=mvindex(myHour, 5) | eval myDiff=myTime - 2 | fields myDiff] | table myDiff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Nothing is displayed.&lt;BR /&gt;&lt;BR /&gt;
The outer search works fine by itself, and the inner search works fine by itself.  &lt;/P&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 18:22:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248011#M73996</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2015-11-20T18:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I see stats values from a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248012#M73997</link>
      <description>&lt;P&gt;You end your subsearch with &lt;CODE&gt;| fields myDiff&lt;/CODE&gt; which is the only field that is passed to your main search. In your join though you are saying you want to link the data based on the field &lt;CODE&gt;connectionID&lt;/CODE&gt;. At a minimum that field would need to be in the results of your subsearch. &lt;/P&gt;

&lt;P&gt;One cool little trick Splunk has provided is adding the command &lt;CODE&gt;| format&lt;/CODE&gt; to the end of a search. This will display results as if they were the results of a subsearch. Can make troubleshooting subsearches a bit easier. &lt;/P&gt;

&lt;P&gt;Edit: Not quite sure what your use case is but based on the fields I'm wondering if you wanting to compare something to an average or something similar. I'm wondering if a command like eventstats or even just stats might be a better solution. Even a stats might work if you have a common field like connectionID across 2 different sourcetypes.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 19:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248012#M73997</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-11-20T19:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I see stats values from a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248013#M73998</link>
      <description>&lt;P&gt;Thanks!  My use case is calculating the difference in times to renew/renegotiate a wireless connection, and in doing so I'm trying to find the time of the most recent connection and the time of the connection before that.  Initially I thought &lt;CODE&gt;Delta&lt;/CODE&gt; could provide the capability to determine those times, but it doesn't seem suitable for my purposes, so I'm using &lt;CODE&gt;stats list()&lt;/CODE&gt; of the connection times to access the time stamps and find the differences.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 20:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248013#M73998</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2015-11-20T20:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I see stats values from a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248014#M73999</link>
      <description>&lt;P&gt;This might hold some answers; it seems like you want to know the time difference between two events not the time difference between the start and end of an event/action. If you just want to get something like the start and end of something you could use &lt;CODE&gt;| stats range(_time) by connectionID&lt;/CODE&gt; or the transaction command creates a new field call duration (more expensive search). Otherwise I think you are likely going to need to use streamstats&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/129084/calculate-the-time-between-a-transaction-events-starttime-and-the-endtime-of-the-previous-event.html"&gt;https://answers.splunk.com/answers/129084/calculate-the-time-between-a-transaction-events-starttime-and-the-endtime-of-the-previous-event.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2015 20:22:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-can-t-I-see-stats-values-from-a-subsearch/m-p/248014#M73999</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-11-20T20:22:18Z</dc:date>
    </item>
  </channel>
</rss>

