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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...