Dashboards & Visualizations

how to define variables on the app level, so that it can be accessed from dashboards

imrago
Contributor

My plan is to make certain chart variables configurable on app level, so that the end user would not have to change each dashboard manually. For example the height of the charts.

What would be the optimal solution? To put it in a lookup file, get it from there on the dashboard in a search and add it as a token? Is there a nicer method?

Tags (1)
0 Karma
1 Solution

vnravikumar
Champion

Hi @imrago

I had used lookup for parameters, check whether it suits your requirement.

<dashboard>
  <label>config</label>
  <row depends="$hide$">
    <panel>
      <table>
        <search>
          <query>| inputlookup config.csv | transpose header_field=param</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <done>
            <condition>
              <set token="charting.chart_value">$result.charting.chart$</set>
              <set token="charting.chart.nullValueMode_value">$result.charting.chart.nullValueMode$</set>
              <set token="charting.legend.placement_value">$result.charting.legend.placement$</set>
              <set token="charting.chart.stackMode_value">$result.charting.chart.stackMode$</set>
              <set token="show">true</set>
            </condition>
          </done>
        </search>
      </table>
    </panel>
  </row>
  <row depends="$show$">
    <panel>
      <chart>
        <search>
          <query>index="_internal" |stats count by source</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.chart">$charting.chart_value$</option>
        <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode_value$</option>
        <option name="charting.legend.placement">$charting.legend.placement_value$</option>
        <option name="charting.chart.stackMode">$charting.chart.stackMode_value$</option>
      </chart>
    </panel>
  </row>
</dashboard>

Lookup: config.csv

param,value
charting.chart,area
charting.chart.nullValueMode,zero
charting.legend.placement,right
charting.chart.stackMode,200

View solution in original post

0 Karma

vnravikumar
Champion

Hi @imrago

I had used lookup for parameters, check whether it suits your requirement.

<dashboard>
  <label>config</label>
  <row depends="$hide$">
    <panel>
      <table>
        <search>
          <query>| inputlookup config.csv | transpose header_field=param</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <done>
            <condition>
              <set token="charting.chart_value">$result.charting.chart$</set>
              <set token="charting.chart.nullValueMode_value">$result.charting.chart.nullValueMode$</set>
              <set token="charting.legend.placement_value">$result.charting.legend.placement$</set>
              <set token="charting.chart.stackMode_value">$result.charting.chart.stackMode$</set>
              <set token="show">true</set>
            </condition>
          </done>
        </search>
      </table>
    </panel>
  </row>
  <row depends="$show$">
    <panel>
      <chart>
        <search>
          <query>index="_internal" |stats count by source</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.chart">$charting.chart_value$</option>
        <option name="charting.chart.nullValueMode">$charting.chart.nullValueMode_value$</option>
        <option name="charting.legend.placement">$charting.legend.placement_value$</option>
        <option name="charting.chart.stackMode">$charting.chart.stackMode_value$</option>
      </chart>
    </panel>
  </row>
</dashboard>

Lookup: config.csv

param,value
charting.chart,area
charting.chart.nullValueMode,zero
charting.legend.placement,right
charting.chart.stackMode,200
0 Karma

Vijeta
Influencer

@imrago you can upload the css style to your app ($SPLUNK_HOME/etc/apps/appname/appserver/static) or can do from UI if you have option to save(Manage apps->appname->actions(Edit Properties) ->upload asset) and access it in any dashboard using <form style="stylesheetname.css">

0 Karma

imrago
Contributor

Good point, that is ideal to change the hight, but I would like to control other parameters also, like

            <option name="charting.chart">area</option>
            <option name="charting.chart.nullValueMode">zero</option>
            <option name="charting.legend.placement">right</option>
            <option name="charting.chart.stackMode">stacked</option>
            <option name="height">200</option>

in a chart.

0 Karma
Get Updates on the Splunk Community!

Best Strategies to Optimize Observability Costs

 Join us on Tuesday, May 6, 2025, at 11 AM PDT / 2 PM EDT for an insightful session on optimizing ...

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...