Kibana and fixed time spans

jaspernygaard picture jaspernygaard · Feb 25, 2015 · Viewed 15.3k times · Source

Is it possible to set a fixed timespan for a saved visualization or a saved search in Kibana 4?

Scenario: I want to create one dashboard with 2 visualizations with different time spans.

  1. A metric counting unique users within 10 min (last 10 minutes)
  2. A metric counting todays unique users (from 00.00am until now)

Note that changing the time span on the dashboard does not affect the visualizations. Possible?

Answer

Henry S picture Henry S · Feb 25, 2015

You could add a date range query to the saved search you base each visualisation on. Eg, if your timestamp field is called timestamp:

timestamp:[now-6M/M TO now]

where the time range is from 'now' to '6 months ago, rounding to the start of the month.

Because Kibana also now supports JSON-based query DSL, you could also achieve the same thing by entering this into the search box instead:

{
    "range" : {
         "timestamp" : {
             "gte": "now-6M/M",
             "lte": "now" 
         }
     }
 }

For more on date range queries see http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_ranges.html#_ranges_on_dates

However changing the dashboard timescale will override this if it's a subset. So if you use the above 6 month range in the saved search, but a 3 month range in the dashboard, you'll filter to 3 months of data.