How to Make a Custom Date Range in a Kibana Visualization?

I am trying to have a visualization (simple bar graph with a date histogram) display data in a date range with some date math applied, but when I try to add the appropriate JSON Input to the query, the query fails with a “failed to find start object” parse error.
Here is a sample of what I am trying to do, taken from the date format page.

{
  "range" : {
    "my_time_stamp" : {
        "gt" : "now-1h"
    }
  }
}

I checked the request and this is being merged into the “aggs” section of the json request, which is the wrong section.

I have been able to get JSON input to recognize things like a custom "min_doc_count" which is correctly merged:

{
	“min_doc_count”: 1
}

I don’t know if this can be done easily with the Kibana GUI (please let me know if it can)
My hope is to have a dashboard that has visualizations that cover different date ranges. From my explorations so far, it seems that a dashboard’s visualizations all must have the same date range. (Please tell me if there is an easier way to do this! I have a feeling I am going about this the wrong way since it seems like a simple thing to do.)

I was able to use date math in a raw json query submitted on the Discover page. This restricts data to the specified date range in a visualization, but the visualization still scales with a the dashboard's time interval setting (so it will zoom way out at 5 years and way in at Today, and this will still carve my query results up and distort visualization graphs). Is there a way to "lock in" the correct visualization zoom for a visualization on a dashboard?

(And anyway to do any of these easier than a raw json query?)

You might be looking for this enhancement: https://github.com/elastic/kibana/issues/3578

1 Like

Yes, that is what I am looking for! I see it is not tagged to a milestone though, unfortunately. Is it something we might see in Kibana 4? Having a single dashboard to be able to compare data from time X to time Y would be a great addition. Even better (as the submitter of the enhancement further asked) would to be able to compare it in the same visualization.

Currently, it seems comparisons like

this month compared to this month last year (or day, year, week, etc.)

cannot be done in a single dashboard (or visualization) in Kibana. This makes the task of looking at data and seeing relevant growth patterns over time require using an alternative program to graph ES data.

We're definitely working toward something in this regard... more info to come soon, stay tuned!

Hi @tbragin
Is it possible now to construct a dashboard with multiple visualizations each for a different time range. For example: one month starting a one month ago, two months ago, or one month a year ago ?

hi yahoo,

Can you tell me how i can do the for a line chart one for today another for last week

Hi @vikalp
I was not able to make it.
Any clue from your side?

I am able to do in timelion but not in kibana.
business want both in single dashboard,
so looking for a solution either do it in kibana
or integrate timelion graph in kibana dashboard.

in kb 4.5 you can integrate timelion series inside kibana but the filterinside timelion does not use the filtering topbar of kibana right now