Hi,
I would like to put the current username in the app navigation menu. New on Splunk and I don't understand everything.
I guess one way is to use a parameter in the default.xml file. For example:
<param name="search">search | rest /services/authentication/current-context | table username</param>
Found on this post:
https://answers.splunk.com/answers/338919/how-do-i-get-the-current-logged-in-username-in-spl.html
But I don't know how to set a view name dynamically.
I think it could be possible to use JavaScript, but I'm not very comfortable with it.
If someone can help me, it will be pretty cool (even with a JS solution if there's great explications ^^)
Cheers
Finally, dealing with JS I find a solution:
I get the last 'a' tag, get the parent (li), duplicate and change children attribute I want. Then I append it to the last
var $str = $( ".nav-item.shared-appbar-navitem.nav-item-" ).find($('a[title="DECONNEXION"]'));
var $li=$str.parent();
$topList=$li.clone()
$topList.children().attr('href',"");
$topList.children().attr('title',"USERNAME"); $topList.children().text(nameShow);
$ul=$li.parent();
$topList.appendTo($ul);
</li>
Finally, dealing with JS I find a solution:
I get the last 'a' tag, get the parent (li), duplicate and change children attribute I want. Then I append it to the last
var $str = $( ".nav-item.shared-appbar-navitem.nav-item-" ).find($('a[title="DECONNEXION"]'));
var $li=$str.parent();
$topList=$li.clone()
$topList.children().attr('href',"");
$topList.children().attr('title',"USERNAME"); $topList.children().text(nameShow);
$ul=$li.parent();
$topList.appendTo($ul);
</li>
I Could not paste this script in the dashboard and it gives an error, can someone give me steps on how to include this in the dashboard
What kind of builder are you using for your dashboards?
If it's dashboard studio, I believe it is not possible to render any dynamic JS content.
With the classic dashboard panel I think it would be possible to do so.
In this url you can check differences between both of them.
Finally, you got the option with SPLUNK UI, where you can customize everything and in a dynamic way, but it requieres a huge effort for developing the whole solution.
Hi MaryvonneMB,
For use this, the command must be like this only:
| rest /services/authentication/current-context | table username
Then, you put this inside your XML.
Just like this, not in any specific tag?
I believe The requirement is to display it in a custom dashboard and fetch similar data related to the username
I work for a customer that want this in the nav menu =s (For me it's useless...)