Splunk: How to hide “Create New Dashboard” button

A colleague just came to me and asked me for a solution to hide “Create New Dashboard” button. The reason behind this is that we have some splunk dashboard, we just want the user to read it, we don’t want them to do any search on our Search Head, we have some roles to hide all search function, but the “Create New Dashboard” is like a backdoor – we want to avoid this.

Splunk - hide create new dashboard

After digging through the source code, we found that this button is generated from this file:

/opt/splunk/share/splunk/search_mrsparkle/exposed/build/pages/enterprise/dashboards/dashboards.js

The location of this file might be different depending on your Splunk version , my trick was to search for “Create New Dashboard”

grep -r "Create New Dashboard" /opt/splunk/share/splunk/search_mrsparkle

After you locate the file, just edit that file and change the text from “Create New Dashboard” to something else such as “Create New Dashboard -Test”. After you made the change, you need to restart splunk : /opt/splunk/bin/splunk restart ,
then clear your browser (this is very important as the browser cache js) , then login and see if you see the change. If you see the change then you have the right file to edit.

Since this file (dashboards.js) is compressed in one line , you can decompress it to see it better by using this tool: https://unminify.com/

Copy it back to your favorite editor and search for New Dashboard again, and this is my fix:

template: '\t            <% if (!hideCreateLink) { if (this.model.user.id=="/services/authentication/users/admin")  { %>\t                <div class="add-dashboard-controls pull-right">\t                    <button class="btn btn-primary add-dashboard"><%- _("Create New Dashboard").t() %></button>\t                </div>\t            <% }   console.log(this.model.user.id); }  %>\t            <h2 class="section-title"><%- _("Dashboards").t() %></h2>\t            <p class="section-description">\t            <%- _("Dashboards include searches, visualizations, and input controls that capture and present available data.").t() %>\t            </p>\t        '
            })

I hi-light the change here here:

template: '\t            <% if (!hideCreateLink) { if (this.model.user.id=="/services/authentication/users/admin")  { %>\t                
\t                    <%- ("Create New Dashboard").t() %>
\t                
\t            <% }   console.log(this.model.user.id); }  %>\t            <%- ("Dashboards").t() %>
\t            \t            <%- _("Dashboards include searches, visualizations, and input controls that capture and present available data.").t() %>\t            
\t        '
             })

Hope it helps.

Leave a Reply

Your email address will not be published. Required fields are marked *