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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...