All Apps and Add-ons

Unable to run query containing gentimes from dashboard



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

Ultra Champion
          <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>
        <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>
0 Karma


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!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...