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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...