Dashboards & Visualizations

How to add label with search query on dashboard using HTML

MeMilo09
Path Finder

Hello There,

I would like to add a label to my dashboard using HTML. The label is based out of my search query using Splunk SPL. I am able to add the label but my query shows the raw source code on my dashboard. How can I get my search query to show the actual results of the query and not the source code. Below is my code. Any help is welcome: 

<html>

<body>

<h1>Sports Report</h1>

<search>

<query>

  | rest /servicesNS/-/-/data/lookup-table-files search="*_Sports_Report.csv"

| eval updated=strptime(updated,"%FT%T%:z")

| eval desired_time=strftime(updated, "%B %d, %Y")

| rename desired_time as "Last Updated" title as Team

| table "Last Updated", Team

  </query>

</search>

</body>

</html>
Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@MeMilo09 

You can not execute Simple XML Element I HTML panel Or code. But you can execute it outside of HTML and use in html.

Please check below sample code.

<dashboard>
  <label>Value in HTML Panel</label>
  <search>
    <query>| makeresults | eval DashboardLabel="My Dashboard Label"</query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <done>
      <set token="tkn_DashboardLabel">$result.DashboardLabel$</set>
    </done>
  </search>
  <row>
    <panel>
      <html>
        <body>
          <h1>$tkn_DashboardLabel$</h1>
        </body>
      </html>
    </panel>
  </row>
</dashboard>
0 Karma

MeMilo09
Path Finder

I only see the label, but not my query

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...