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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...