Dashboards & Visualizations

How to pass the login username in a drilldown link to an external website?

sjlin
Explorer

Hi all,

I want to pass the login username in a drilldown link to an external website.
How can I achieve that?

Any help is appreciated.

Tags (2)
0 Karma

jeffland
SplunkTrust
SplunkTrust

You can fetch the currently logged in user in .js with

var service = mvc.createService({owner: "nobody"});
service.currentUser(function(err, user) {
    userName = user.properties().username;
});

and place userName in a token from there. You could also run a search such as

| rest /services/authentication/current-context/context | search username!="splunk-system-user" | table username

and work with the result (which should be the current user), but AFAIK you still need to do this in javascript as there is no way to directly place a search result into a token (imagine a search such as index=_internal, how is that supposed to fit into a token?).

0 Karma

sjlin
Explorer

Thanks for your advice very much.
But I don't know how to add a js to my dashboard...

0 Karma

jeffland
SplunkTrust
SplunkTrust

You place the .js file in

%SPLUNK_BASE/etc/apps/%appname%/appserver/static/

and reference it in your dashboard with

<dashboard script="your_script.js">
  ...
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...