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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...