Kibana Canvas - Time Filter for previous month

Is there a way to use the time filter in canvas to filter a month regardless of the current date/time.

Just now, the only thing close is to create a relative time filter for 1 Months ago however this only really works when you're nearing the end of the current month.

I'd like to be able to choose the full previous month for reporting. Is there any way to achieve this?

Cheers,
Kev

One option would be to construct a custom date and use timefilter:

timefilter 
  column="@timestamp" 
  from={
    date 
    | formatdate format="M" 
    | if {compare eq to="12"} 
      then={string {date | formatdate format="YYYY" | math "subtract(value, 1)" } "-12-01"}
      else={string {date | formatdate format="YYYY"} "-" {math "subtract(value, 1)" } "-01" }
    }
  to={string { date | formatdate format="YYYY-M"} "-01" }
| render as="debug"

The trouble is you have to go from 1st to 1st, because you won't know for certain how many days are in the month you're using... but you could make that work, as well, with some pretty hairy logic.

Other approaches may work, as well, but this was an easy way to accomplish what you're asking for...?

If there are enhancements we can make (e.g. I saw your previous post about date math), please feel free to log a request on our Github. Cheers!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.