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!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...