<?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: Best Practices to join two child objects of a data model in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138322#M37953</link>
    <description>&lt;P&gt;Thanks Michael.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Feb 2015 15:45:25 GMT</pubDate>
    <dc:creator>sanjay_shrestha</dc:creator>
    <dc:date>2015-02-17T15:45:25Z</dc:date>
    <item>
      <title>Best Practices to join two child objects of a data model</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138320#M37951</link>
      <description>&lt;P&gt;We have a situation where we need to join two child objects of a data model.  Both child objects have separate index and host.&lt;/P&gt;

&lt;P&gt;e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ProjectInformation (Datamodel Object)
                                 _time
                                 host
                                ..........
                                 ProjectId (Extracted Field)

             FromIndexOne (Datamodel Child Object)
                                 _time
                                 host
                                 ProjectId (Inherited Field)                             
                                ............
                                CalculatedField1
                                CalculatedField2

             FromIndexTwo (Datamodel Child Object)
                                 _time
                                 host
                                 ProjectId (Inherited Field)                             
                                ............
                                CalculatedField3
                                CalculatedField4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We would like to have result with following fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    _time;  ProjectId; CalculatedFiled1; CalculatedFiled2; CalculatedFiled3; CalculatedFiled4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Feb 2015 20:02:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138320#M37951</guid>
      <dc:creator>sanjay_shrestha</dc:creator>
      <dc:date>2015-02-16T20:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices to join two child objects of a data model</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138321#M37952</link>
      <description>&lt;P&gt;Hi sanjay.shrestha,&lt;/P&gt;

&lt;P&gt;take a look at this run everywhere example to get an idea how this can be done, it uses Splunk &lt;CODE&gt;internal_server&lt;/CODE&gt; data model and two of its child objects:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values(server.licenser.quota.gb) AS gb values(server.scheduler.scheduled_reports.scheduled_time) AS scheduled_time from datamodel="internal_server" by _time 
| streamstats last(gb) AS last_gb last(scheduled_time) AS last_schedule 
| stats count by _time last_gb last_schedule 
| fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To break this down I'll explain each search pipe:&lt;/P&gt;

&lt;P&gt;Obviously we need to get something first, so we get &lt;CODE&gt;gb&lt;/CODE&gt; from the &lt;CODE&gt;server.licenser.quota&lt;/CODE&gt; child / nodename and &lt;CODE&gt;scheduled_time&lt;/CODE&gt; from the &lt;CODE&gt;server.scheduler.scheduled_reports&lt;/CODE&gt; child / nodename (makes no sense I know, but this is only to show how you can do it) :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values(server.licenser.quota.gb) AS gb values(server.scheduler.scheduled_reports.scheduled_time) AS scheduled_time from datamodel="internal_server" by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next use the result in &lt;CODE&gt;streamstats&lt;/CODE&gt; to get rid of those empty results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats last(gb) AS last_gb last(scheduled_time) AS last_schedule 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;use this result in a &lt;CODE&gt;stats&lt;/CODE&gt; remove the &lt;CODE&gt;count&lt;/CODE&gt; field and here we go:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count by _time last_gb last_schedule 
| fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is just an example, modify it to your needs to match your use case.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 09:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138321#M37952</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-02-17T09:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices to join two child objects of a data model</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138322#M37953</link>
      <description>&lt;P&gt;Thanks Michael.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 15:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138322#M37953</guid>
      <dc:creator>sanjay_shrestha</dc:creator>
      <dc:date>2015-02-17T15:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices to join two child objects of a data model</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138323#M37954</link>
      <description>&lt;P&gt;values() function gives unique values only, what if we need all the values of a child object field and do stats over that.&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2015 08:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138323#M37954</guid>
      <dc:creator>kamalm1</dc:creator>
      <dc:date>2015-05-06T08:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices to join two child objects of a data model</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138324#M37955</link>
      <description>&lt;P&gt;list() function doesnot work with tstats&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2015 08:05:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Best-Practices-to-join-two-child-objects-of-a-data-model/m-p/138324#M37955</guid>
      <dc:creator>kamalm1</dc:creator>
      <dc:date>2015-05-06T08:05:39Z</dc:date>
    </item>
  </channel>
</rss>

