# Conditional plotting in Timelion

**URL:** https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239
**Category:** Kibana
**Tags:** timelion
**Created:** [October 17, 2017, 12:26pm UTC](https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239 "2017-10-17T12:26:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![VeraE](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@VeraE](https://discuss.elastic.co/u/VeraE)
#### Post date: [October 17, 2017, 12:26pm UTC](https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239/1 "2017-10-17T12:26:45Z")

</div>

I want to make a Timelion chart, where only those datapoints are shown that fit a condition. For example I want to count the number of GET requests which resulted in 404 responses over time. Is it possible to do this in timelion?  
The following was my attempt:  
.es(q='method.keyword:GET').if(eq,400,.es(q='responseStatus'))

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [October 17, 2017, 12:42pm UTC](https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239/2 "2017-10-17T12:42:24Z")

</div>

> [@VeraE](#):
>
> .es(q='method.keyword:GET').if(eq,400,.es(q='responseStatus'))

this should almost work 🙂

`.es(*).if(lt, 20, 0)` will show a chart with only points where the value is above 20 ...  
you could also show a different metric that you used for the if condition ...  
`.es(*).if(lt, 20, 0, .es(metric=avg:bytes))` will show avg:bytes for the datapoints where count is more than 20

you could also do a different query as you do in your example, but that might produce weird results  
as your first query might return completely different set of points as the second one ...

---

<div class="post-metadata">

### Author: ![VeraE](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@VeraE](https://discuss.elastic.co/u/VeraE)
#### Post date: [October 17, 2017, 2:30pm UTC](https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239/3 "2017-10-17T14:30:31Z")

</div>

Thanks, but I think I did not phrase my question well, or my example was misleading.  
So I have a big chunk of data (all that is counted in .es(\*)), but first of all I only want to use a part of it (the instances where there is a call to the relevant part of the page). I want to filter these calls based on method, so I only get the PUT request for example, and then filter that once again for response (404). So my condition is not on the count of the calls, but their nature, if you can call it that.

EDIT: In the meantime I think I found the answer to my question: I wanted this: .es(q='method.keyword:GET && responseStatus:400')

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [October 17, 2017, 2:37pm UTC](https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239/4 "2017-10-17T14:37:32Z")

</div>

unfortunately i think that is not possible, .es will always return a metric (like a count, average, sum) and not the actual field values (like 404, 200, 500 ... or PUT/GET)

---

<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: [November 14, 2017, 2:41pm UTC](https://discuss.elastic.co/t/conditional-plotting-in-timelion/104239/5 "2017-11-14T14:41:20Z")

</div>

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