Splunk Search

How to set default value of variable in serch query

geetanjali
Path Finder

Hello,

I have a view having bar graph with timechart command. I have two drop downs in my view. Withe selecting different values from drop down, it will change the bar graph.

following is the query :

index="test" sourcetype="testalert" AlertGroup=$alertGroup$ Node=$Node$ | fields LastOccurrence, Severity, Node, Location, AlertGroup, Summary | timechart count(LastOccurrence) by Severity

$alertGroup$ and $Node$ are two drop down variables. While changing drop down values,the value of these variables changes.

Problem is, i want to display chart on page load and on page load the values of these two variables are null and my query is returning null value. I want to set the default value of these variables as "Any". By default all the results should show in graph.

Please help, if any body knows the solution.

Thanks in advance

Geetanjali

Tags (1)

hazekamp
Builder

geetanjali,

Assuming you are using Advanced XML StaticSelect or SearchSelect Lister modules with ConvertToIntention, you can add an "Any" option like so (basically the value for the "Any" options is "*"; If you still want to see events that don't have an AlertGroup field you would need to add a "| fillnull" to your search):

<module name="StaticSelect">
  <param name="settingToCreate">alertGroup_setting</param>
  <param name="label">Alert Group: </param>
  <param name="searchWhenChanged">True</param>
  <param name="staticFieldsToDisplay">
    <list>
      <param name="label">Any</param>
      <param name="value">*</param>
    </list>
    ...
  </param>
  <module name="ConvertToIntention">
    <param name="settingToConvert">alertGroup_setting</param>
    <param name="intention">
      <param name="name">stringreplace</param>
      <param name="arg">
        <param name="alertGroup">
          <param name="value">$target$</param>
        </param>
      </param>
    </param>
0 Karma

geetanjali
Path Finder

Hi,
thanks for the suggestions. I have implemented this query. But it is giving zero result.
index="tougou" sourcetype="alert" AlertGroup=$alertGroup$ Node=$Node$ | fields LastOccurrence, Severity, Node, Location, AlertGroup, Summary | timechart count(LastOccurrence) by Severity | fillnull value="Any"

Correct me where i m wrong.

thanks

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...