Dashboards & Visualizations

need to replace splunk dashboard tokens to * if they are undefined

kranthimutyala
Path Finder

I have two TEXT fields Object and modifier. I want to create dashboard based on either of the field. tried with "if condition", it did not work.
Javascript is also fine

Example:
field1=object
field2=modifier

| index=name event=$object$ action=$modifier$ |table content group

-->if both fields are provided no worries
-->if both are not provided then both should be "wildcard(star)"
-->if field1 is specified and field2 is not specified then field2 should be "wildcard(star)"
-->if field2 is specified and field1 is not specified then field1 should be "*"

How to achieve this?

Note:I dont want to achieve this by using * in default value

Thanks.
Kranthi M

0 Karma

gaurav_maniar
Builder
0 Karma

harshpatel
Contributor

Hi @kranthimutyala ,

I think what you can do here is have one more layer of token through javascript. Where changing the filter will cause these next layer of tokens to update which are set by your logic.

For example:

Lets say you have filter token named as $filter_token$. So what you can do is have onChange event listener on this token and inside that you can check for value of the token and according to that set another token named $search_token$ which will be used in the query. That way you can keep the text input empty and on page load you can initialize $search_token$ to be * which won't show up on the text input that you are displaying.

Hope this helps,
Harsh

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...