<?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: How do I make a inputlookup recursive? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77156#M1091</link>
    <description>&lt;P&gt;this isn't working;  it's limited to a first level lookup; whereas I'm looking to grab a full tree from the root partid and find all parts under that root partid for inclusion in my output.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Sep 2013 21:48:56 GMT</pubDate>
    <dc:creator>cmeinco</dc:creator>
    <dc:date>2013-09-30T21:48:56Z</dc:date>
    <item>
      <title>How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77152#M1087</link>
      <description>&lt;P&gt;I have an lookup file: (parts.csv)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;partid, parentpartid
part01,
part02,part01
part03,part01
part04,part02
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to join this data with this data: (mysearch)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;day, partid, partevent, count
9/30/2013,part02,creation,23
9/30/2013,part04,update,30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Selfjoin does not appear to work as described (what little description exists).  Here is my first hack attempt:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(my search) | join type=left parentpartid overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl1|rename partid as parentpartid] 
| join type=left parentpartid_lvl1 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl2|rename partid as parentpartid_lvl1] 
| join type=left parentpartid_lvl2 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl3|rename partid as parentpartid_lvl2] 
| join type=left parentpartid_lvl3 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl4|rename partid as parentpartid_lvl3]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can then filter the results by using this statement:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where parentpartid=tmp_partid OR parentpartid_lvl1=tmp_partid OR parentpartid_lvl2=tmp_partid OR parentpartid_lvl3=tmp_partid OR parentpartid_lvl4=tmp_partid 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;Note: I put my initial part id into my search by doing this as part of (mysearch): "| eval tmp_partid=part02"&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;I need to be able to do this up to around 40 times (maybe more), but I'm happy to put a cap on it.   Any guidance or recommendation on creating a custom join or inputlookup.    &lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 17:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77152#M1087</guid>
      <dc:creator>cmeinco</dc:creator>
      <dc:date>2013-09-30T17:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77153#M1088</link>
      <description>&lt;P&gt;Not sure I understand.  You want to add the parentpartid field to your output table?&lt;BR /&gt;
day, partid, parentpartid, partevent, count&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 18:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77153#M1088</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-09-30T18:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77154#M1089</link>
      <description>&lt;P&gt;How do you feel about trying transaction instead?  Something like...&lt;/P&gt;

&lt;P&gt;search | inputlookup parts.csv | transaction partid parentpartid | search parentpartid=tmp_partid&lt;/P&gt;

&lt;P&gt;I think this will get you all the lists that contain the parentpartid you search for.  I don't have any way to test this at the moment. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 18:14:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77154#M1089</guid>
      <dc:creator>jspears</dc:creator>
      <dc:date>2013-09-30T18:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77155#M1090</link>
      <description>&lt;P&gt;You can do this without transaction.  This will pull the parentpartid that matches the partid and create the parentpartid field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search | inputlookup parts.csv partid AS partid OUTPUT parentpartid AS parentpartid | stats count by day, parentpartid, partid, partevent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Sep 2013 19:17:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77155#M1090</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-09-30T19:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77156#M1091</link>
      <description>&lt;P&gt;this isn't working;  it's limited to a first level lookup; whereas I'm looking to grab a full tree from the root partid and find all parts under that root partid for inclusion in my output.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 21:48:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77156#M1091</guid>
      <dc:creator>cmeinco</dc:creator>
      <dc:date>2013-09-30T21:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77157#M1092</link>
      <description>&lt;P&gt;I think you mean lookup, not inputlookup.  This does not appear to be working; as with the other comment; this is not recursively including all children of the tmp_partid (root search element).&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 21:49:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77157#M1092</guid>
      <dc:creator>cmeinco</dc:creator>
      <dc:date>2013-09-30T21:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77158#M1093</link>
      <description>&lt;P&gt;Lookup works if it is defined.  If it is not defined then you can specify a file in the lookup folder with inputlookup.&lt;BR /&gt;
Sorry for misunderstanding your question.  This answer does not do it for you, but I'm still not really sure what you're trying to do.&lt;BR /&gt;
Instead of posting code for your output, how about an example of what you want the output to look like based on the inputs you've already provided.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 22:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77158#M1093</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-09-30T22:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77159#M1094</link>
      <description>&lt;P&gt;answers appears to be broken, can't add edit right now;  Here is more about my search:&lt;/P&gt;

&lt;P&gt;(my search)=    sourcetype=part_events | eval tmp_partid="part02" &lt;/P&gt;

&lt;P&gt;(output)=    | stats sum(count) as hits by partid | sort - hits&lt;/P&gt;

&lt;P&gt;I want all the events where partid is a child of part2; no matter how deep into the hierarchy.   So if I passed in part01 as tmp_partid, I would expect to get everything.  &lt;/P&gt;

&lt;P&gt;Should I be looking at macros to do this recursion for me?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:52:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77159#M1094</guid>
      <dc:creator>cmeinco</dc:creator>
      <dc:date>2020-09-28T14:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77160#M1095</link>
      <description>&lt;P&gt;Example of output:  (tmp_partid="part01")&lt;BR /&gt;
part02,23&lt;BR /&gt;
part04,30&lt;/P&gt;

&lt;P&gt;If there were multiple part02 entries, these would be sum'd with stats.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 22:57:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77160#M1095</guid>
      <dc:creator>cmeinco</dc:creator>
      <dc:date>2013-09-30T22:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77161#M1096</link>
      <description>&lt;P&gt;I'd have to test this, but you might be looking at it backwards.&lt;BR /&gt;
Rename partid as parentid, call the lookup for parentids and output partids for that parent.  In the lookup definitions, you can specify the maximum number of matches.&lt;BR /&gt;
To make it less confusing, change the header names in the csv file.&lt;BR /&gt;
Like I said, I need to test this.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2013 23:05:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77161#M1096</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-09-30T23:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make a inputlookup recursive?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77162#M1097</link>
      <description>&lt;P&gt;I decided this wouldn't recurse more than 99 times, so I wrote a quick shell script to generate a macro (parent_part_lookup):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;join partid [|inputlookup parts.csv | join type=left parentpartid overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl1|rename partid as parentpartid] | join type=left parentpartid_lvl1 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl2|rename partid as parentpartid_lvl1] | join type=left parentpartid_lvl2 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl3|rename partid as parentpartid_lvl2] | join type=left parentpartid_lvl3 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl4|rename partid as parentpartid_lvl3] ... | join type=left parentpartid_lvl98 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl99|rename partid as parentpartid_lvl98] | join type=left parentpartid_lvl99 overwrite=f [|inputlookup parts.csv|rename parentpartid as parentpartid_lvl100|rename partid as parentpartid_lvl99] ] | where parentpartid=tmp_partid OR parentpartid_lvl1=tmp_partid OR parentpartid_lvl2=tmp_partid OR parentpartid_lvl3=tmp_partid OR ... OR parentpartid_lvl98=tmp_partid OR parentpartid_lvl99=tmp_partid 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There has to be a better way; likely starting with some macro cleanup and parameterization.  Note: I first had everything formatted and easy to read, but the macro had an error and I had to remove the line breaks (bug?)&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2013 01:22:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-make-a-inputlookup-recursive/m-p/77162#M1097</guid>
      <dc:creator>cmeinco</dc:creator>
      <dc:date>2013-10-10T01:22:39Z</dc:date>
    </item>
  </channel>
</rss>

