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!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...