Dashboards & Visualizations

Display website in iFrame with URL coming from variable?

viggor
Path Finder

I have a dashboard which contains a variable $url$
and I would like to display the website who's address is stored in $url$ inside an iFrame.

I am failing to do something like:

<html>
  <iframe src="$url$" height="200" width="1000" style="border:none;"/>
 </html>

Any ideas?

Labels (1)
0 Karma

woodcock
Esteemed Legend

The problem that you are having is that recently Splunk has added some settings to control this type of content and defaulted dashboard_html_allow_embeddable_content to false. In order to get it to work, try enabling these settings in web.conf:

dashboard_html_allow_inline_styles = <boolean>
* Whether or not to allow style attributes from inline HTML elements in dashboards.
* If "false", style attributes from inline HTML elements in dashboards will be removed 
  to prevent potential attacks.
* Default: true

dashboard_html_allow_embeddable_content = <boolean>
* Whether or not to allow <embed> and <iframe> HTML elements in dashboards.
* If set to "true", <embed> and <iframe> HTML elements in dashboards will not be removed 
  and can lead to a potential security risk.
* If set to the default value of "false", <embed> and <iframe> HTML elements will be stripped
  from the dashboard HTML.
* Default: false

dashboard_html_wrap_embed = <boolean>
* Whether or not to wrap <embed> HTML elements in dashboards with an <iframe>.
* If set to "false", <embed> HTML elements in dashboards will not be wrapped, leading to
  a potential security risk.
* If set to "true", <embed> HTML elements will be wrapped by an <iframe sandbox> element to help
  mitigate potential security risks.
* Default: true

dashboard_html_allow_iframes = <boolean>
* Whether or not to allow iframes from HTML elements in dashboards.
* If "false", iframes from HTML elements in dashboards will be removed to prevent
  potential attacks.
* Default: true

niketn
Legend

Yes it should. If it is not working press F12 and test Console for any page level errors with iFrame options like I had mentioned in my previous comment.

Following is an extension of above example with a single value panel displaying URL and clicking on the same iFrame should be opened.

alt text

  <row>
    <panel>
      <single>
        <search>
          <query>| makeresults
| eval URL="http://docs.splunk.com/Documentation"
| table URL
          </query>
        </search>
        <option name="colorMode">block</option>
        <option name="drilldown">all</option>
        <option name="useColors">1</option>
        <drilldown>
          <set token="tokURL">$click.value$</set>
        </drilldown>
      </single>
    </panel>
  </row>
  <row>
    <panel depends="$tokURL$">
      <html>
        <iframe src="$tokURL$" height="600" width="100%" style="border:2;">
          <p>Your browser does not support iframes.</p>
        </iframe>
      </html>
    </panel>
  </row>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

niketn
Legend

@viggor, were you able to try out the example? Please let us know if something is not working for you.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

noy72
New Member

I know this is old, but I am trying to make this work. My URL opens up a webpage that verifies the status of ditribution points.
http://sccm/sms_mp/.ss_aut?mplist

When Ireplace my URL with the URL in the example, the dashboard diplays a large black bar with my UL in white text and an empty, bordered panel.
Any assistance would be apreciated.
Ron Jones

0 Karma

niketn
Legend

What are some of the URL values? Can you put some samples?
If they are external URLs, then you should test opening them in regular HTML files first as some websites do not allow their pages to be opened inside iFrames using following x-frame-options: x-frame-options' to 'sameorigin'. Refer to the following link: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

Following is run anywhere search to open http://docs.splunk.com which supports opening in iFrames but does not work with https://answers.splunk.com which does not. You can open your HTML debugger(F12) to investigate this issue as there should be a Console error logged for the same if iFrame is not loading.

  <row>
    <panel>
      <html>
        <iframe src="http://docs.splunk.com/Documentation" height="600" width="100%" style="border:2;">
          <p>Your browser does not support iframes.</p>
        </iframe>
      </html>
    </panel>
  </row>

PS: I changed border to 2 just to ensure that iFrame is supported and showing up in Splunk whether the webpage opens inside iFrame or not.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

viggor
Path Finder

Thanks for your answer. What you posted works perfectly fine for static, constant urls, but what if the url is stored in a variable $url$?

0 Karma
Get Updates on the Splunk Community!

New Case Study Shows the Value of Partnering with Splunk Academic Alliance

The University of Nevada, Las Vegas (UNLV) is another premier research institution helping to shape the next ...

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...