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 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 ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...