Dashboards & Visualizations

In a dashboard's HTML code, how do I dynamically append a date to an image filename?

surekhasplunk
Communicator

Hi,

<row>
    <panel>
      <html>
        <img src="/static/app/search/image.PNG"/> 
   </html>
   </panel>
  </row>

Currently am using above patch of code in my Splunk dashboard to show the picture which is working fine.
But, as per the requirement, the file will change everyday and the filename will change to image_28102016 which includes today's date. So how to add this date field parameter to the filename so that it will pick up the latest file always?

0 Karma
1 Solution

sundareshr
Legend

Add this to the top of your dashboard.

    <search><query>| makeresults | eval dt=strftime(_time, "%d%m%Y")</query>
      <done>
        <set token="filename">image_.$result.dt$.jpg</set>
      </done>    
    </search>

And change your IMG tag to this

<img src="/static/app/search/$filename$" /> 

View solution in original post

sundareshr
Legend

Add this to the top of your dashboard.

    <search><query>| makeresults | eval dt=strftime(_time, "%d%m%Y")</query>
      <done>
        <set token="filename">image_.$result.dt$.jpg</set>
      </done>    
    </search>

And change your IMG tag to this

<img src="/static/app/search/$filename$" /> 

surekhasplunk
Communicator

Hi Sundareshr,

I used this patch of code but still the image is not coming up. Is there any other way to troubleshoot it through any log file where I can see what exact file name its taking.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...