Splunk Search

creating nested tables

smolcj
Builder

Hi , my search is like specified below,
Index=main source=file.txt xxx=*| stats values(a) values(b) values(c) by xxx
Gives the table

Xxx       values(a)        values(b)          values(c)
So       qq                sss               sss
Wqq      wewe              wewe              wew
we       wew               wew               wewe

can I change the layout of the table like this, I tried using append and appendcols, I know something I am missing please help to make the table like below

xxx    values(a)        values(b)         values(c)
So
       Qq               sss               sss
Wqq
      Wewe              wewe              ww
We
      Ss                ss                 ss
Ss
     Ass               asa                 blaabla

Please help

Tags (2)
0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

After some emails, smolcj and I discovered that the reason this solution was being pursued was just to improve the general readability of the Table. That's to say the leftmost column was a really a header for the row, and the request had come in to space things out in the table so that the header was higher than the content.

I made the suggestion of looking into the Embedding feature of the Table module, because it would be dead-simple to just embed HTML modules into the particular cells as necessary so that the 'data' cells had some padding on the top edge.

And I hear that this has worked out well as the solution.

Here's the code that smolcj used as a proof-of-concept, and if you haven't read the "Table - Custom Embedding" documentation in Sideview Utils, this will look a little odd. It basically takes all the "Connection" cells in the table and wraps each of them in a div that adds top padding so as to push down the data. If done to all of the "data" cells, it would make the leftmost cell of each row look like a header for that row. You could also use the same effect to wrap the leftmost values in <b> tags or anything you like.

<module name="Search" layoutPanel="panel_row2_col1" autoRun="True">
  <param name="search"><![CDATA[
    index=infa sourcetype=session-log source=*SUCCESS* sess_trans_type=* | stats values(sess_trans_type) as Transtype,  values(sess_connection) as Connection, values(sess_codepage) as Codepage,  values(sess_sql_query) as Query by sess_trans_name
  ]]></param>

  <module name="Pager">
    <param name="count">5</param>
    <module name="Table">
      <param name="hiddenFields">Codepage,Query</param>
      <module name="HTML" group="row.fields.Connection">
        <param name="html"><![CDATA[
          <div style="padding-top:15px;width: 500px;">
            Connection = <b>$row.fields.Connection$</b><br> Codepage = <b>$row.fields.Codepage$</b><br> 
          </div>
        ]]></param>
      </module>
    </module>
  </module>
</module>

View solution in original post

sideview
SplunkTrust
SplunkTrust

After some emails, smolcj and I discovered that the reason this solution was being pursued was just to improve the general readability of the Table. That's to say the leftmost column was a really a header for the row, and the request had come in to space things out in the table so that the header was higher than the content.

I made the suggestion of looking into the Embedding feature of the Table module, because it would be dead-simple to just embed HTML modules into the particular cells as necessary so that the 'data' cells had some padding on the top edge.

And I hear that this has worked out well as the solution.

Here's the code that smolcj used as a proof-of-concept, and if you haven't read the "Table - Custom Embedding" documentation in Sideview Utils, this will look a little odd. It basically takes all the "Connection" cells in the table and wraps each of them in a div that adds top padding so as to push down the data. If done to all of the "data" cells, it would make the leftmost cell of each row look like a header for that row. You could also use the same effect to wrap the leftmost values in <b> tags or anything you like.

<module name="Search" layoutPanel="panel_row2_col1" autoRun="True">
  <param name="search"><![CDATA[
    index=infa sourcetype=session-log source=*SUCCESS* sess_trans_type=* | stats values(sess_trans_type) as Transtype,  values(sess_connection) as Connection, values(sess_codepage) as Codepage,  values(sess_sql_query) as Query by sess_trans_name
  ]]></param>

  <module name="Pager">
    <param name="count">5</param>
    <module name="Table">
      <param name="hiddenFields">Codepage,Query</param>
      <module name="HTML" group="row.fields.Connection">
        <param name="html"><![CDATA[
          <div style="padding-top:15px;width: 500px;">
            Connection = <b>$row.fields.Connection$</b><br> Codepage = <b>$row.fields.Codepage$</b><br> 
          </div>
        ]]></param>
      </module>
    </module>
  </module>
</module>

martin_mueller
SplunkTrust
SplunkTrust

You could duplicate every event, and then blank out fields depending on whether it's an odd or even row.

martin_mueller
SplunkTrust
SplunkTrust

First, you appear to confuse your splunkbase accounts 🙂

Second, mvexpand can only duplicate events if there is a multivalued field with more than one entry. Hence you need to create a temporary field with two values, mvexpand on that, then remove it again.

0 Karma

bellaed
Path Finder

appended streamstats count and it is working... but mvexpand is confusing,,
if i do ...|Index=main source=file.txt xxx=*| stats values(a) values(b) values(c) by xxx |mvexpand values(a)|mvexpand(b)
i am getting the same events, the table entries are not duplicated..
tried something like
mvzip(a,b)|rex field..
still the same
Am i doing it wrong?

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

For duplicating events look at mvexpand, for row numbers look at streamstats.

0 Karma

smolcj
Builder

Thanks martin, but is there something that i can duplicate table entries ?? and how to check the rownumber in splunk ??
and one more issue is , what if one the table entries doesnt have a nested field?
can u suggest something?

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...