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.
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 \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 '
})
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.