Dashboards & Visualizations

Variables/constants for roles

splunked38
Communicator

Hi All,

Is there any way to assign a 'variable' to a role?

We're creating a dashboard for many sites (15+) which will show their local information.

The idea is that they would log in and get their local dashboard based on role.

Notes:

  • The dashboard is written in Advanced XML with macros to centralise the queries.
  • We're avoiding using variables in the URL to avoid the site looking up other sites' details.
  • We'd like to package it up as an app to allow for change control, deployment, etc (we can decentralise the queries quite easily)

Thanks in advance.

0 Karma

somesoni2
Revered Legend

If you're looking for getting current logged in user's role and having that in a variable inside the dashboard, you can use following query (works for user role as well) to get the same and can use ResultValueSetter module to have that stored into a variable in dashboard.

| rest /services/authentication/users splunk_server=local | search [| rest /services/authentication/current-context | rename username as title | fields title] | table title, roles

And this can be used in dashboard like this:

<module name="Search">
            <param name="search">
                <![CDATA[
    | rest /services/authentication/users splunk_server=local 
    | search [| rest /services/authentication/current-context 
    | rename username as title | fields title] | table title, roles
                    ]]>

            </param>
            <module name="ResultsValueSetter">
                <param name="fields">title, roles</param>
                ....
                ....

splunked38
Communicator

Thanks for the response.

I just thought about this again and have a few caveats which I'll probably post as separate questions.

Ideally, we're trying to avoid using Sideview utils for the time being (I suspect this cannot be avoided, don't have anything against Sideview utils, just wondering if it's possible).

Your search solution works fine but the role needs to be set as a $variable$ which I can then use:
*as output eg: Dashboard 1 ($variable$)
*as part of another search/macro eg: macro(site=$variable$)

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...