All Apps and Add-ons

Include html view in another view

khd
Explorer

Hi,

I created a view using URLLoader module with one parameter.
This module displays a div "valueDisplay" after a search.

I created another view with another search.

Is it possible to call the first view, with a parameter, from the second view ?

first view
----------
    <view template="dashboard.html">
    <module name="SideviewUtils" layoutPanel="appHeader" />
    <module name="URLLoader" layoutPanel="panel_row1_col1" autoRun="True">
        <module name="Search">
            <param name="search">...</param>
            <param name="earliest">-30d</param>
            <module name="HTML">
                <param name="html">
                    <![CDATA[
                    <div class="valueDisplay">
                    <div class="$results[0].range$">
                    <b>$results[0].fieldLabel$</b>
                    </div>
                    </div>
                    ]]>
                </param>
            </module>
        </module><!-- Search -->
    </module><!-- URLLoader -->
</view>

Second view
-----------

    <module name="Search" layoutPanel="panel_row1_col1" autoRun="True">
        <param name="search">tkn | dedup hostname</param>
        <module name="HTML" layoutPanel="panel_row2_col1">
                <module name="Redirector">
                    <param name="url">ViewButton</param>
                    <param name="arg.host">$results[0].hostname$</param>
            </module>

        </module>
    </module>

Thanks

khd
Explorer

Thank you for these explanations.
I chose the solution with Iframe.

0 Karma

sideview
SplunkTrust
SplunkTrust

Filling in the blanks a little, I think what you want, is for the second view to have a button or a link, which when clicked sends the user to the first view, with ?host=foo on the URL, where the host value is the hostname field value of the first row of "tkn | dedup hostname".

First though, the first hostname value from the search tkn | dedup hostname is a little random. That "tkn" part has to really match only a single hostname, in which case the dedup clause is redundant. And if it doesn't match a single hostname, the dedup clause will result in a somewhat arbitrary hostname value being in the first row.

That said, and assuming that my filling-in-of-the-blanks is more or less right, the following XML for your second view will be a lot closer.

<module name="Search" layoutPanel="panel_row1_col1" autoRun="True">
  <param name="search">tkn | dedup hostname</param>

  <module name="Button">
    <param name="label">Go</param>

    <module name="ResultsValueSetter">
      <param name="fields">hostname</param>

      <module name="Redirector">
        <param name="url">the_first_view</param>
        <param name="arg.host">$hostname$</param>
      </module>
    </module>
  </module>
</module>

You're using the $results[0].fieldName$ syntax, but that syntax is something specific to just the HTML module. So what you want instead is the ResultsValueSetter module. ResultsValueSetter goes and gets the given field value(s), from the first row of the search results, and sends them downstream as simple $foo$ tokens. So in this case it's configured to get the "hostname" field from the first row, and it sends that value downstream as $hostname$.

There's a page in the Sideview Utils documentation (contained within the Sideview Utils app itself), at "Key Techniques > Other > Overview of all the $foo$ tokens", that provides a useful overview of various $foo$ keys.

As far as the ResultsValueSetter module, it has a whole page of documentation and examples dedicated to it, but unfortunately a link to the page doesn't appear anywhere in the navigation. You can navigate to it yourself by going to your Splunk instance go to a Sideview Utils page, and then replace the last segment of the URL with results_value_setter1_intro, such that the total URL looks like:

/en-US/app/sideview_utils/results_value_setter1_intro

and I'll fix it in the next release so that it appears in the proper section of the docs navigation.

Another quite different possibility, is that you want to embed and display the contents of the first view, within a panel in the second view. This is fairly easy to do but it's quite different. The way you go is to simply use an HTML module to create an Iframe element, and have the "src" attribute of that iframe element be the URL. You may need to use a ValueSetter module and the ValueSetter's urlEncodeKeys param to URL-encode your hostname argument. But aside from that it's pretty straightforward. If this is more what you're trying to do, let me know and I'll update this answer with an example of that.

khd
Explorer

Thank you for these explanations.
I chose the solution with Iframe.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...