Dashboards & Visualizations

How to embed a Twitter widget in a Splunk dashboard?

jonlaw
New Member

Hello!
As a newbie i'm looking to create my first dashboard. I have created all the preset panels I need but i'm looking to embed a Twitter 'widget' on the dashboard too.
Twitter provided the url but i'm unsure of how I add this - I have tried using an iframe to display but when saved it just gives a blank frame..

The widget looks like this

        <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/search?q=Example Topic” data-widget-id=“*WIDGET-ID*”>Tweets about Example Topic</a>
        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

but I've tried a generic iframe and it just appears blank..

<panel>
  <title>Testing HTML</title>
    <html>
      <iframe src="https://www.google.com"/>
    </html>
</panel>

Many thanks
Jon

0 Karma
1 Solution

msivill_splunk
Splunk Employee
Splunk Employee

So I'm going to answer the question about how to embed third party javascript widgets into Splunk.

The first thing you will need to do is convert your dashboard to HTML, http://dev.splunk.com/view/webframework-developapps/SP-CAAAEM2

There are trade offs between using Simple XML and HTML that is covered in the link that you should consider.

Once this is done edit it and then slip in the javascript widget code in the div class dashboard-body section of the HTML document.

For example

<div class="dashboard-body container-fluid main-section-body" data-role="main">
    <div class="dashboard-header clearfix">
        <h2>Twitter Widget HTML</h2>
    </div>

    <a class="twitter-timeline"  href="https://twitter.com/hashtag/corgi" data-widget-id="*WIDGET-ID*">#corgi Tweets</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

</div>

All being well you will end up with something like this.

alt text

For your particular use case you might also want to consider pulling the raw twitter events into Splunk first so they can be analysed to your specific needs and then presented on a dashboard.

View solution in original post

chandrasekharko
Path Finder

The widget won't work any more as the widget functionality has been deprecated by twitter. Please use twitter publish going forward.

https://publish.twitter.com

0 Karma

msivill_splunk
Splunk Employee
Splunk Employee

So I'm going to answer the question about how to embed third party javascript widgets into Splunk.

The first thing you will need to do is convert your dashboard to HTML, http://dev.splunk.com/view/webframework-developapps/SP-CAAAEM2

There are trade offs between using Simple XML and HTML that is covered in the link that you should consider.

Once this is done edit it and then slip in the javascript widget code in the div class dashboard-body section of the HTML document.

For example

<div class="dashboard-body container-fluid main-section-body" data-role="main">
    <div class="dashboard-header clearfix">
        <h2>Twitter Widget HTML</h2>
    </div>

    <a class="twitter-timeline"  href="https://twitter.com/hashtag/corgi" data-widget-id="*WIDGET-ID*">#corgi Tweets</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

</div>

All being well you will end up with something like this.

alt text

For your particular use case you might also want to consider pulling the raw twitter events into Splunk first so they can be analysed to your specific needs and then presented on a dashboard.

jonlaw
New Member

Works perfectly thanks. I'm already pulling the raw data in but having a visual widget is really helpful at quick glance... Thanks again.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...