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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...