<?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: Format result table as tree or make indentations (parent-child relation) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266781#M80225</link>
    <description>&lt;P&gt;Hi ptrstpp950, I deleted the duplicate question and hope you don't mind &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2015 08:48:27 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2015-10-08T08:48:27Z</dc:date>
    <item>
      <title>Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266780#M80224</link>
      <description>&lt;P&gt;I have following data in data in columns:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id  parent  step_name
1            Step_1
2   1       Step_1_1
3   2       Step_1_1_1
4   2       Step_1_1_2
5   1       Step_1_2
6   1       Step_1_3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to format results to show parent-child relationship. It can be even graphically with spaces or &lt;CODE&gt;-&lt;/CODE&gt; like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id  parent  step_name
1            Step_1
2   1       -&amp;gt;Step_1_1
3   2       ---&amp;gt;Step_1_1_1
4   2       ---&amp;gt;Step_1_1_2
5   1       -&amp;gt;Step_1_2
6   1       -&amp;gt;Step_1_3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was trying to use eval, but without success&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 08:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266780#M80224</guid>
      <dc:creator>ptrstpp950</dc:creator>
      <dc:date>2015-10-08T08:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266781#M80225</link>
      <description>&lt;P&gt;Hi ptrstpp950, I deleted the duplicate question and hope you don't mind &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 08:48:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266781#M80225</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-08T08:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266782#M80226</link>
      <description>&lt;P&gt;@Mus Of course &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 08:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266782#M80226</guid>
      <dc:creator>ptrstpp950</dc:creator>
      <dc:date>2015-10-08T08:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266783#M80227</link>
      <description>&lt;P&gt;I'm sure there's a better answer, but...&lt;/P&gt;

&lt;P&gt;If there are all reasonably consistent, a couple of brute-force ways I thought of were to do something like &lt;CODE&gt;eval indents_to_add=len(step_name)/4 |...&lt;/CODE&gt; Oh, I apologize: this really &lt;STRONG&gt;will&lt;/STRONG&gt; be brute force.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval ita=len(step_name)/4 | 
eval step_name=case(ita==3,"-----&amp;gt;".step_name, ita==2,"---&amp;gt;".step_name, ita==1,"-&amp;gt;".step_name,1==1,step_name)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so, we first divide the length of step_name by 4.  You'll have to adjust that parameter, it may end up somewhat more complex.  &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/CommonEvalFunctions" target="_blank"&gt;You could use "like" or "match" too&lt;/A&gt; - all sorts of things are possible.  Once you have "indents_to_add" (ita because it was getting lengthy), then just run an eval case statement to prepend various things to step_name.  You'll see the last case portion (1==1) is always true - at least in this universe - so it acts as a default, which says to just make it step_name without anything prepended.&lt;/P&gt;

&lt;P&gt;I did look for a way to, say, run a rex mode=sed using a variable amount, but that doesn't seem possible. (Something like, in the case above, using " ... | rex field=step_name mode=sed "s/(.*)/-{$ita]\1/g" but again, that shouldn't work.).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:29:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266783#M80227</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-09-29T07:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266784#M80228</link>
      <description>&lt;P&gt;Your brute force method won't work at all (I tried few before asking this question). Just look at point 5 and 6 they don't need one indentation. Morover my step name are not so, easy to parse with length, I just change them to make example easy to read I will add an update&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 06:19:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266784#M80228</guid>
      <dc:creator>ptrstpp950</dc:creator>
      <dc:date>2015-10-09T06:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266785#M80229</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt; The real step names are something like: BeforeCall, AfterCall, EvaluatingXXX, Calling method ABC, etc. &lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 06:24:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266785#M80229</guid>
      <dc:creator>ptrstpp950</dc:creator>
      <dc:date>2015-10-09T06:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266786#M80230</link>
      <description>&lt;P&gt;Well, shucks.  &lt;/P&gt;

&lt;P&gt;The technique still may work if we make some changes.  Your examples - "BeforeCall" and stuff like that could be possibly used with "match", but first - can you tell me that &lt;EM&gt;each&lt;/EM&gt; event defines its own level and is consistent?  Like, will all "BeforeCall" events be indented Y, and all "Evaluating" calls will be indented by amount X, regardless of what comes before them or after them?  If that's the case (regardless of the specifics of how far each is), then we can get this done fairly easily still.&lt;/P&gt;

&lt;P&gt;If it is not the case, and instead how far something gets indented is dependent upon both itself AND some other events (so an Evaluating that comes after a BeforeCall gets indented 4, but an Evaluating that comes after a CallingMethodC gets indented 6?)  If that's the case, this is probably still possible, but might be a bit more work.&lt;/P&gt;

&lt;P&gt;Or is it totally just a nesting problem?&lt;/P&gt;

&lt;P&gt;Alternatively, how many different distinct things are we talking about here? 5? 50? more?  Because I have ideas for those, too.&lt;/P&gt;

&lt;P&gt;Could you post some actual data with the formatting you want? It would help immensely.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 11:58:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266786#M80230</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2015-10-09T11:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Format result table as tree or make indentations (parent-child relation)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266787#M80231</link>
      <description>&lt;P&gt;I have a lot of steps (usually up to 20-30, but maximum is 3000). They can have same names on different level, because every remote call can have BeforeCall and AfterCall logged. &lt;BR /&gt;
The real data and real problem is described on &lt;A href="https://kzhendev.wordpress.com/2015/05/18/measuring-application-performance-with-mini-profiler-and-splunk/"&gt;https://kzhendev.wordpress.com/2015/05/18/measuring-application-performance-with-mini-profiler-and-splunk/&lt;/A&gt; &lt;BR /&gt;
My only change is to use tab separated columns instead of JSON&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 12:15:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-result-table-as-tree-or-make-indentations-parent-child/m-p/266787#M80231</guid>
      <dc:creator>ptrstpp950</dc:creator>
      <dc:date>2015-10-09T12:15:30Z</dc:date>
    </item>
  </channel>
</rss>

