Dashboards & Visualizations

How to display indexed HTML content in Dashboard?

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi

I want to know how we can display indexed HTML content in Dashboard.

My sample dashboard xml is below. (Here I have used SAMPLE search which will return HTML content)

<dashboard>
  <search>
    <query>| stats count | eval A="<h1>My Test HTML</h1>" </query>
      <preview>
        <set token="A">$result.A$</set>
      </preview>
  </search>
  <label>Test Html</label>
  <row>
    <panel>
      <html> $A$ </html>
    </panel>
  </row>
</dashboard>

My Expected result is:

My Test HTML

So is it possible without using Javascript? I have tried with javascript and it's working. But we don't want to use Javascript.

Thanks in advance.

Kamlesh

Tags (1)
0 Karma

woodcock
Esteemed Legend

You can (1-way trip) convert your whole panel to html or you can add some html child elements in the XML but only in some nodes. For example, this is allowed in the panel node:

<panel>
  <!--title>Foo Bar</title-->
  <html>
    <div style="text-align: left;">
      <h2>Foo Bar</h2>
    </div>
  </html>

But this results in Invalid child="html" is not allowed in node="dashboard":

<dashboard>
      <html>
        <div style="text-align: left;">
          <h2>Foo Bar</h2>
        </div>
      </html>
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

HI woodcock,

I just given a sample xml.
Can you please see my comment on @cmerriman's comment??

Thanks
Kamlesh

0 Karma

cmerriman
Super Champion

does this get you what you need:

<dashboard>
   <search>
     <query>| stats count | eval A="My Test HTML" </query>
       <preview>
         <set token="A">$result.A$</set>
       </preview>
   </search>
   <label>Test Html</label>
   <row>
     <panel>
       <html> <h1>$A$</h1> </html>
     </panel>
   </row>
 </dashboard>

put the html formatting in the html panels? unless I'm missing something, which is completely possible

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @cmerriman,

Thanks for your reply.
Yes we can do this but my index contains the html pages.
My all html page get index in main index and HTMLContent filed has html tags. It Could be table , div or any tag.

Can you please guide me in this scenario.??

Thanks
Kamlesh

0 Karma

cmerriman
Super Champion

Just as a quick thought without testing anything, you could encase the query in CDATA. I'll try to test it out in a bit, bu let you might beat me to it.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @cmerriman,
I have tried with CDATA but no luck. It's showing HTML Decoded value.. like & gt;h1& lt;........

Thanks
Kamlesh

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...