Dashboards & Visualizations

Landing Page with All Apps and Dashboards based on the user role

SathyaNarayanan
Path Finder

Hi Splunkers,

I Need a Landing page will show all my customized apps and the respective dashboards in it based on the user login. (role based user).

I created a Prebuild panel, which was showing all the apps and dashboard. but it doesn't show based on the role.

For eg: when a user have role for 2 apps. he should only see those 2 app in the landing page and his repective dashboards in it.

Note : Role was created each apps. few users will have 2 roles to see 2 apps.

Thanks in advance.

Tags (1)
0 Karma
1 Solution

niketn
Legend

@SathyaNarayanan you will have to play around with Splunk REST API to pull Dashboard label based on logged in user role and have pre-built panel use the same. Refer to one of my older answers: https://answers.splunk.com/answers/639475/how-to-pass-a-dashboard-as-value-in-dropdown-of-an-1.html

You can also refer to one of other answers of mine where based on Logged in User's role inputs can be enabled/disabled. You can use the same approach to set and unset token which would Show or Hide Panels based on Logged in user. This would not required JS as SPL query through REST API will give you logged in user role and through the search results you can set tokens to show/hide panel/s using depends and/or rejects. https://answers.splunk.com/answers/499936/restrict-specific-users-to-view-only-certain-panel.html

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@SathyaNarayanan you will have to play around with Splunk REST API to pull Dashboard label based on logged in user role and have pre-built panel use the same. Refer to one of my older answers: https://answers.splunk.com/answers/639475/how-to-pass-a-dashboard-as-value-in-dropdown-of-an-1.html

You can also refer to one of other answers of mine where based on Logged in User's role inputs can be enabled/disabled. You can use the same approach to set and unset token which would Show or Hide Panels based on Logged in user. This would not required JS as SPL query through REST API will give you logged in user role and through the search results you can set tokens to show/hide panel/s using depends and/or rejects. https://answers.splunk.com/answers/499936/restrict-specific-users-to-view-only-certain-panel.html

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

SathyaNarayanan
Path Finder

Hi @niketn

I have got the list of dashboard with the below query.

| rest splunk_server=local /servicesNS/-/-/data/ui/views
| search (isVisible=1 isDashboard=1 "eai:type"="html" OR "eai:type"="views" ) ("eai:acl.perms.read"="" OR "eai:acl.perms.read"="$tokRoles$") ("eai:appName"="" OR "eai:appName"="$env:app$")
| eval label= label." (".'eai:appName'.")"
| search "eai:appName"=Test_Sathya OR "eai:appName"="twitter"
| table "eai:appName" "eai:acl.perms.read" title

But now the landing page is not only show the list of dashboard, it should also link the dashboards.

Like your previous answer in the below link .

https://answers.splunk.com/answers/711988/customized-landing-page-for-splunk-applications.html?utm_s...

(It helped in showing the static apps and dashboard, i too created a pre build panel showing all my app and dashboards. now i need to show the apps and dashboards based on the user who login to this page)

as i mentioned earlier eg;, when a user have access to 2 apps. he should only see those 2 app in the landing page and his respective dashboards links below it .

Thanks

0 Karma

niketn
Legend

But now the landing page is not only show the list of dashboard, it should also link the dashboards.

Refer to <drilldown> <link> code below. The Splunk Dashboard Examples app has examples for such kind of drilldown.

when a user have access to 2 apps. he should only see those 2 app in the landing page and his respective dashboards links below it .

This condition is partially true and you would need to create your dashboard accordingly. Splunk's REST API call will allow you to filter results as per restrictions. In some cases Dashboards in some common App/s can be made Global. Which means Dashboards from such apps can be accessed inside other apps as well. Please try the following example and adjust restrictions as per your needs. I have taken out system and search apps from the list.

<form>
  <label>Custom Landing Page</label>
  <!-- Independent search to get logged in User's role -->
 <search>
   <query>| rest splunk_server=local /services/authentication/current-context 
| table roles
| stats values(roles) as roles
| eval roles=mvjoin(roles,",")</query>
   <earliest>-1s@s</earliest>
   <latest>now</latest>
   <done>
     <condition match="$job.resultCount$!=0">
       <set token="tokLoggedInUserRoles">$result.roles$</set>
     </condition>
     <condition>
       <unset token="tokLoggedInUserRoles"></unset>
     </condition>
   </done>
 </search>
  <fieldset submitButton="false">
    <input type="dropdown" token="tokApp">
      <label>Available Apps</label>
      <fieldForLabel>label</fieldForLabel>
      <fieldForValue>title</fieldForValue>
      <selectFirstChoice>true</selectFirstChoice>
      <search>
        <query>| rest /services/apps/local splunk_server=local
| search  eai:acl.app!="system" eai:acl.app!="search" (eai:acl.perms.read="*" OR eai:acl.perms.read IN ($tokLoggedInUserRoles$))
| fields label title</query>
        <earliest>-1s@s</earliest>
        <latest>now</latest>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| rest /servicesNS/-/$tokApp$/data/ui/views splunk_server=local
| search eai:acl.app!=system eai:acl.app!=search (eai:acl.perms.read="*" OR eai:acl.perms.read IN ($tokLoggedInUserRoles$))
| fields eai:acl.app title label
| eval url="/app/".'eai:acl.app'."/".title</query>
          <earliest>-1s@s</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <fields>["label"]</fields>
        <drilldown>
          <link target="_blank">$row.url|n$</link>
        </drilldown>
      </table>
    </panel>
  </row>
</form>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

SathyaNarayanan
Path Finder

@niketnilay

Thanks for your comments, am trying out . will get back to you once am done

0 Karma

SathyaNarayanan
Path Finder

I modified as per my requirements and it worked for me.

thanks @niketnilay

niketn
Legend

Awesome! you got this working 🙂

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...