Archive

Can i change the name in the Splunk Tabs to use a token like "Host" not "Splunk 7.2.6"(This information is no good to me).

Motivator

Hi

Can i change the name in the Splunk Tabs to use a token like "Host" not "Splunk 7.2.6"(This information is no good to me).

Cheers in Advance
Rob
alt text

Tags (1)
0 Karma

SplunkTrust
SplunkTrust

@robertlynch2020 assuming that you want to change title when users are viewing your Dashboard, you can use Simple XML JS extension to override the default Browser title.

Following is a run anywhere example which sets a dynamic hostname each time search in table is refreshed and sets the same to tokHost which in turn changes the Browser's title using Simple XML JS Extension.

alt text

Following is the Simple XML Dashboard code which uses JS script to override Browser Title:

<dashboard script="title_change.js">
  <label>Dynamic Dashboard Title</label>
  <row>
    <panel>
      <table>
        <search>
          <query>
            |makeresults
            | fields - _time
            | eval data=random()
            | eval host="host".substr(data,1,2)
            | fields - data
          </query>
          <done>
            <set token="tokHost">$result.host$</set>
          </done>
        </search>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <html>
        <div>tokHost: $tokHost$</div>
      </html>
    </panel>
  </row>
</dashboard>

Following is the required JS file title_change.js

require(["jquery",
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function ($, mvc) {
    console.log("Inside Title Change JS");
    var submittedTokenModel = mvc.Components.get("submitted");
    var defaultTokenModel = mvc.Components.get("default");
    defaultTokenModel.on("change:tokHost", function (tokHost,tokHostNew,options) {
        console.log("Inside Host Token Change");
        var strTokHost=defaultTokenModel.get("tokHost");
        var varDashboardTitle = document.querySelector("title");
        if(varDashboardTitle!==undefined){
            varDashboardTitle.innerHTML = "My Dynamic ("+strTokHost+")";
        }
    });
});
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Builder

@niketnilay : this is helpful. In your example host is getting updated dynamically. but in default functionality it also shows dashboard name. but in above example it has static string in begnning "My Dynamic". Is there any change to keep default functionality to include dashboard name ?
Like : "Dynamic Dashboard | host 34" .

0 Karma

Builder

Hi @robertlynch2020 ,
The answers link that @vnravikumar posted can help you achieve what you want to do. You would have to know a little bit about javascript to do it. However, as per the answers response, you cannot remove "Splunk 7.2.6" without violating the Splunk license.
You might (you're assuming the risk of violating Splunk license terms) be able to add to the title tab by modifying the common.js to include a new variable for the host value (pulled from the URL):
Change (from $SPLUNK_HOME/share/splunk/search_mrsparkle/exposed/build/pages/enterprise/common.js):

setPageTitle:function(title){this.deferreds.serverInfo.done(function(){var version=this.model.serverInfo.getVersion()||("N/A").t(),isLite=this.model.serverInfo.isLite();var hn=location.host;document.title=splunkUtils.sprintf(("%s | host: %s | Splunk %s %s").t(),title,hn,isLite?"Light":"",version)}.bind(this))}

To:
setPageTitle:function(title){this.deferreds.serverInfo.done(function(){var version=this.model.serverInfo.getVersion()||("N/A").t(),isLite=this.model.serverInfo.isLite();var hostvalue=location.host;document.title=splunkUtils.sprintf(("%s | %s | Splunk %s %s").t(),title,hostvalue,isLite?"Light":"",version)}.bind(this))}

You would need to restart Splunk after this, and also clear your browser cache (better to test in incognito mode instead).

After this your tab would look like:
TPS_VIEW | mxwiki.murex.com | Splunk 7.2.6

0 Karma

Champion
0 Karma

Motivator

HI

Thanks, but i need it to be dynamic (as host will change) and i think that is a static solution.

Rob

0 Karma