All Apps and Add-ons

How to assign global time for the filter in a dashboard

SG
Path Finder

Hi,

I have a dashboard where I have a time range and a filter for the CI branch.

SG_0-1629779511877.png

In the time_range what timings I am taking same timings I wanted to apply for CI branch filter also. As of now, it is taking the last 24hr and I don't see any option to assign the time_range for the CiBranch filter.

These are the options under CiBranch

SG_1-1629783657847.png

 

Thanks,

SG

Labels (1)
Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@SG 

Try this.

<form>
	<label>Lighthouse</label>
	<fieldset submitButton="false" autoRun="false">
		<input type="time" token="Lighthouse_Timerange" searchWhenChanged="true">
			<label>time_range</label>
			<default>
				<earliest>-15m</earliest>
				<latest>now</latest>
			</default>
		</input>
		<input type="dropdown" token="CiBranch">
			<label>CiBranch</label>
			<fieldForLabel>CiBranch</fieldForLabel>
			<fieldForValue>CiBranch</fieldForValue>
			<search>
				<query>index=nextgen sourcetype=lighthouse_json datasource=LH | stats count by CiBranch | table CiBranch</query>
				<earliest>$Lighthouse_Timerange.earliest$</earliest>
				<latest>$Lighthouse_Timerange.latest$</latest>
			</search>
		</input>
		</fieldset>
	</form>

 

KV 

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@SG 

Try by updating dashboard XML and add earliest and latest manually. Like this.

<earliest>$time_range.earliest$</earliest>
<latest>$time_range.latest$</latest>

  

Sample Code:

<fieldset submitButton="true">
    <input type="time" token="time_range">
      <label></label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="field2">
      <label>CIBranch</label>
      <fieldForLabel>log_level</fieldForLabel>
      <fieldForValue>log_level</fieldForValue>
      <search>
        <query>index=_internal log_level=* |stats count by log_level</query>
        <earliest>$time_range.earliest$</earliest>
        <latest>$time_range.latest$</latest>
      </search>
    </input>
  </fieldset>

 

KV

0 Karma

SG
Path Finder

Hi KV, 

After updating the XML as suggested my CiBranch dropdown is blocked with a message Could not create search

SG_0-1629800825724.png

My dashboard XML after updating the timings

<form>
  <label>Lighthouse</label>
  <fieldset submitButton="false" autoRun="false">
    <input type="time" token="Lighthouse_Timerange" searchWhenChanged="true">
      <label>time_range</label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="CiBranch">
      <label>CiBranch</label>
      <fieldForLabel>CiBranch</fieldForLabel>
      <fieldForValue>CiBranch</fieldForValue>
      <search>
        <query>index=nextgen sourcetype=lighthouse_json datasource=LH 
| stats count by CiBranch 
|  table CiBranch</query>
        <earliest>$time_range.earliest$</earliest>
        <latest>$time_range.latest$</latest>
      </search>
    </input>

 

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@SG 

Try this.

<form>
	<label>Lighthouse</label>
	<fieldset submitButton="false" autoRun="false">
		<input type="time" token="Lighthouse_Timerange" searchWhenChanged="true">
			<label>time_range</label>
			<default>
				<earliest>-15m</earliest>
				<latest>now</latest>
			</default>
		</input>
		<input type="dropdown" token="CiBranch">
			<label>CiBranch</label>
			<fieldForLabel>CiBranch</fieldForLabel>
			<fieldForValue>CiBranch</fieldForValue>
			<search>
				<query>index=nextgen sourcetype=lighthouse_json datasource=LH | stats count by CiBranch | table CiBranch</query>
				<earliest>$Lighthouse_Timerange.earliest$</earliest>
				<latest>$Lighthouse_Timerange.latest$</latest>
			</search>
		</input>
		</fieldset>
	</form>

 

KV 

0 Karma

RicardoSchiavo
New Member

I'm using the global time in a dashboard search as suggested above:

                "queryParameters": {
                    "earliest": "$global_time.earliest$",
                    "latest": "$global_time.latest$"
                }

It works fine if the user selects presets or relative time. But if the user picks a date range, I get an error like this:

RicardoSchiavo_0-1715182080031.png

Any ideas on how to avoid this date format issue?

 

0 Karma

SG
Path Finder

Hi KV,

This worked perfectly fine. Thanks for the help 🙂

0 Karma
Get Updates on the Splunk Community!

Now Available: Cisco Talos Threat Intelligence Integrations for Splunk Security Cloud ...

At .conf24, we shared that we were in the process of integrating Cisco Talos threat intelligence into Splunk ...

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Easily Improve Agent Saturation with the Splunk Add-on for OpenTelemetry Collector

Agent Saturation What and Whys In application performance monitoring, saturation is defined as the total load ...