<?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: Looping in Splunk Query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/504097#M140729</link>
    <description>&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Communicator lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/165605"&gt;@ktugwell_splunk&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Communicator lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Thanks for your response, In this case the count 5 is dynamic, They may 100's of rows with the parent child relationship. in such a use case how would I build the relationship.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Communicator lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Thanks,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jun 2020 09:13:49 GMT</pubDate>
    <dc:creator>gowtham08091</dc:creator>
    <dc:date>2020-06-12T09:13:49Z</dc:date>
    <item>
      <title>Looping in Splunk Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/481360#M134893</link>
      <description>&lt;P&gt;Hello Everyone.&lt;/P&gt;

&lt;P&gt;I have a traceability report as below&lt;BR /&gt;
Parent  Child&lt;BR /&gt;
A   B&lt;BR /&gt;
A   C&lt;BR /&gt;
B   D&lt;BR /&gt;
C   E&lt;BR /&gt;
C   F&lt;/P&gt;

&lt;P&gt;Where as I have create the link traceability  as &lt;BR /&gt;
Parent  Son Grandson&lt;BR /&gt;
A   B   D&lt;BR /&gt;
A   C   E&lt;BR /&gt;
A   C   F&lt;/P&gt;

&lt;P&gt;I am struggling to identify the base query for this use case, can anyone suggest ?&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8747iE4B9B78F9682D375/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 15:45:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/481360#M134893</guid>
      <dc:creator>Gowthamdevaraj</dc:creator>
      <dc:date>2020-04-21T15:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Looping in Splunk Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/481361#M134894</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;

&lt;P&gt;This had be puzzled for a bit! And I do hope I haven't over-engineered it.&lt;/P&gt;

&lt;P&gt;I think the best way for you to achieve this is to potentially use a lookup. This will work on small to moderate datasets, if your dataset larger, you may want to consider the KV Store.&lt;/P&gt;

&lt;P&gt;First, I reproduced your dataset like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=5 
| streamstats count 
| eval Parent=CASE(count=1,"A",count=2,"A",count=3,"B",count=4,"C",count=5,"C",1==1,0) 
| eval Child=CASE(count=1,"B",count=2,"C",count=3,"D",count=4,"E",count=5,"F",1==1,0)
| fields - _time
| fields Parent Child
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then i output the results to a CSV &lt;CODE&gt;| outputlookup family.csv&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I then used that output to link the family members together.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=5 
| streamstats count 
| eval Parent=CASE(count=1,"A",count=2,"A",count=3,"B",count=4,"C",count=5,"C",1==1,0) 
| eval Child=CASE(count=1,"B",count=2,"C",count=3,"D",count=4,"E",count=5,"F",1==1,0) 
| fields - _time 
| fields Parent Child 
| lookup family.csv Parent AS Child OUTPUT Child AS Grandchild 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally, you'll see, because &lt;CODE&gt;C&lt;/CODE&gt; is both the parent of &lt;CODE&gt;E&lt;/CODE&gt; and &lt;CODE&gt;F&lt;/CODE&gt;. Splunk will give you a multivalued field for &lt;CODE&gt;Grandchild&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You can then use this &lt;CODE&gt;| mvexpand Grandchild&lt;/CODE&gt; which should give you the result you're looking for.&lt;/P&gt;

&lt;P&gt;I hope this works for you and demonstrates how a lookup can be used to match data like this. Remember, you can always schedule the &lt;CODE&gt;outputlookup&lt;/CODE&gt; to keep the &lt;CODE&gt;family.csv&lt;/CODE&gt; up to date.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 15:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/481361#M134894</guid>
      <dc:creator>ktugwell_splunk</dc:creator>
      <dc:date>2020-04-22T15:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Looping in Splunk Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/504097#M140729</link>
      <description>&lt;P data-unlink="true"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Communicator lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/165605"&gt;@ktugwell_splunk&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Communicator lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Thanks for your response, In this case the count 5 is dynamic, They may 100's of rows with the parent child relationship. in such a use case how would I build the relationship.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Communicator lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;Thanks,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 09:13:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/504097#M140729</guid>
      <dc:creator>gowtham08091</dc:creator>
      <dc:date>2020-06-12T09:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Looping in Splunk Query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/504130#M140736</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults count=200
| eval Parent=mvindex(split("ABCDEFGHIJKLMNOPQRSTUVWXYZ",""),random()%26)
| eval Son=mvindex(split("ABCDEFGHIJKLMNOPQRSTUVWXYZ",""),random()%26)
| table Parent Son
| dedup Parent Son
| rename COMMENT as "from here, the logic"
| eval tmp=Parent.Son
| eventstats values(tmp) as listed
| mvexpand listed
| rex field=listed max_match=0 "(?&amp;lt;GroundSon1&amp;gt;\w)(?&amp;lt;GroundSon2&amp;gt;\w)"
| where Son==GroundSon1
| table Parent Son GroundSon2
| rename GroundSon2 as Groundson
| dedup Parent Son Groundson
| sort Parent Son Groundson&lt;/LI-CODE&gt;&lt;P&gt;For three category , It can forced to do .&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 11:56:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Looping-in-Splunk-Query/m-p/504130#M140736</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-06-12T11:56:59Z</dc:date>
    </item>
  </channel>
</rss>

