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!

Enterprise Security Content Update (ESCU) | New Releases

In November, the Splunk Threat Research Team had one release of new security content via the Enterprise ...

Index This | Divide 100 by half. What do you get?

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

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

❄️ Celebrate the season with our December lineup of Community Office Hours, Tech Talks, and Webinars! ...