# How to create time range conditions on Timelion?

**URL:** https://discuss.elastic.co/t/how-to-create-time-range-conditions-on-timelion/119404
**Category:** Kibana
**Tags:** timelion
**Created:** [February 11, 2018, 11:56pm UTC](https://discuss.elastic.co/t/how-to-create-time-range-conditions-on-timelion/119404 "2018-02-11T23:56:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![keeshqs](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@keeshqs](https://discuss.elastic.co/u/keeshqs)
#### Post date: [February 11, 2018, 11:56pm UTC](https://discuss.elastic.co/t/how-to-create-time-range-conditions-on-timelion/119404/1 "2018-02-11T23:56:00Z")

</div>

Hi all,

I'm not sure if it's possible on timelion, but on elasticsearch we are receiving document every 1 minute. These documents contain SQL database related metric (such as Object Locks and Database Locks), and each has a field called **insert\_date** (field extracted from SQL database). We want to display all these documents on a time series and at the same time set a threshold for Object or Database Locks documents where insert\_date is older than 30 minutes from now  
**insert\_date \< DATEADD (MINUTE, -30, GETDATE());**

Is this type of condition possible on timelion?

Appreciate your input.

Thanks,  
Keeshia

---

<div class="post-metadata">

### Author: ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)
#### Post date: [February 12, 2018, 4:28pm UTC](https://discuss.elastic.co/t/how-to-create-time-range-conditions-on-timelion/119404/2 "2018-02-12T16:28:51Z")

</div>

@keeshqs if you change the `timelion:es.timefield` Kibana advanced setting (Management -\> Advanced Settings) to `insert_date` you can then use the timefilter in the upper right hand corner to control the date-range. If you don't want to change this for all timelion queries, you can specify it using the `timefield` parameter like so: `.es(timefield="insert_date")`

Unfortunately, you can't use the `q` parameter to do the datemath as this uses the lucene query syntax which doesn't support relative dates, you can use range queries to do absolute filters like so: `.es(q="@timestamp:[2017-01-01 TO 2018-02-11]")` but you can't do `.es(q="@timestamp:[* TO now-30m]")` as Lucene doesn't support this.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 12, 2018, 4:28pm UTC](https://discuss.elastic.co/t/how-to-create-time-range-conditions-on-timelion/119404/3 "2018-03-12T16:28:52Z")

</div>

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