All Apps and Add-ons

Unable to run query containing gentimes from dashboard

msashish
Explorer

Hi,

I am using below to generate a date information which I shall later use:

| makeresults
| eval startDate=strftime(relative_time(_time,"-4y@y"),"%m/%d/%Y")
| eval endDate=strftime(relative_time(_time,"+2w@w"),"%m/%d/%Y")
| fields startDate, endDate
| map search="| gentimes start=\"$startDate$\" end=\"$endDate$\" increment=0d
| eval AsOfDate=strftime(starttime,\"%Y-%m-%d\")
| sort AsOfDate
| fields AsOfDate"
| eval Weekday=strftime(strptime(AsOfDate, "%Y-%m-%d"), "%A")
| eval flag=case(strptime(AsOfDate,"%Y-%m-%d")>now(),"future",1==1,"past")
| fields AsOfDate, Weekday , flag

This works fine on search but does not work from within dashboard query (Within dashboard query I replaced > & < with corresponding html tags).

When run from dashboard query I keep getting "Could not create search" (appears it has not been able to resolve startDate and endDate)

Is there any way I can save above & refer in dashboard (for joining to other queries) ?

0 Karma

to4kawa
Ultra Champion
<dashboard>
  <label>AsOfDate</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults count=2
| streamstats count
| eval _time=if(count=1,relative_time(_time,"-4y@y"),relative_time(_time,"+2w@w"))
| makecontinuous span=1d _time
| eval AsOfDate=strftime(_time,"%Y-%m-%d")
| sort AsOfDate
| eval Weekday=strftime(_time, "%A")
| eval flag=case(_time > now(),"future",1==1,"past")
| table AsOfDate, Weekday , flag</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</dashboard>
0 Karma

msashish
Explorer

Looks like map command does not work with single $. I tried $$ for my variables and it worked. Testing further.

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...