<?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 Subsearch help? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93420#M24062</link>
    <description>&lt;P&gt;Hey everyone, simple question.&lt;BR /&gt;
Is it possible to append or use a subsearch to return a count?&lt;BR /&gt;
Here is how I'm currently trying to do it, but its blanking all of the other fields as soon as I add the stats command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="AS-CDR" OR sourcetype="XS-CDR" Type!=Interim
|rex field=Local_Call_ID "(?P&amp;lt;Local_Call_ID_Trimmed&amp;gt;\d+)(?=:)"
|rex field=Related_Call_ID "(?P&amp;lt;Related_Call_ID_Trimmed&amp;gt;\d+)(?=:)"
|stats count by Local_Call_ID_Trimmed
|rename count as Related_Calls
|table Start_Time Answer_Time Answer_Indicator Release_Time Termination_Cause_Description Local_Call_ID_Trimmed Related_Call_ID_Trimmed Service_Provider Type User_Number Calling_Number Called_Number Direction User_Time_Zone host Related_Calls
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 02 May 2011 20:10:04 GMT</pubDate>
    <dc:creator>msarro</dc:creator>
    <dc:date>2011-05-02T20:10:04Z</dc:date>
    <item>
      <title>Subsearch help?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93420#M24062</link>
      <description>&lt;P&gt;Hey everyone, simple question.&lt;BR /&gt;
Is it possible to append or use a subsearch to return a count?&lt;BR /&gt;
Here is how I'm currently trying to do it, but its blanking all of the other fields as soon as I add the stats command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="AS-CDR" OR sourcetype="XS-CDR" Type!=Interim
|rex field=Local_Call_ID "(?P&amp;lt;Local_Call_ID_Trimmed&amp;gt;\d+)(?=:)"
|rex field=Related_Call_ID "(?P&amp;lt;Related_Call_ID_Trimmed&amp;gt;\d+)(?=:)"
|stats count by Local_Call_ID_Trimmed
|rename count as Related_Calls
|table Start_Time Answer_Time Answer_Indicator Release_Time Termination_Cause_Description Local_Call_ID_Trimmed Related_Call_ID_Trimmed Service_Provider Type User_Number Calling_Number Called_Number Direction User_Time_Zone host Related_Calls
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2011 20:10:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93420#M24062</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2011-05-02T20:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch help?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93421#M24063</link>
      <description>&lt;P&gt;There are two ways to do it. Either use &lt;CODE&gt;eventstats&lt;/CODE&gt;, or use stats as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count as Related_Calls
            first(Start_Time) as Start_Time
            first(Answer_Time) as Answer_Time
            first(Answer_Indicator) as Answer_Indicator
            ...
      by Local_Call_ID_Trimmed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this assumes that you want to collapse all the other fields by the &lt;CODE&gt;Local_Call_ID_Trimmed&lt;/CODE&gt; field. It's not clear to me which way is correct for your data.&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2011 05:26:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93421#M24063</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-05-03T05:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch help?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93422#M24064</link>
      <description>&lt;P&gt;Basically this is for a search which will run through all calls/events from the past 5 minutes. As each one gets looked at by splunk, I want it to print a table with the details for that individual event. I also want it to show the number of other events where the Local_Call_ID_Trimmed number appears, and place that into a field in the table results. I don't need any of the fields from the related records, just the number of related records.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:31:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93422#M24064</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2020-09-28T09:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch help?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93423#M24065</link>
      <description>&lt;P&gt;Just tried it using eventstats, works like a bell. Thank you! I'll have to play with this a bit more.&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2011 14:15:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-help/m-p/93423#M24065</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2011-05-03T14:15:16Z</dc:date>
    </item>
  </channel>
</rss>

