# Using @timestamp field for filtering

**URL:** https://discuss.elastic.co/t/using-timestamp-field-for-filtering/176534
**Category:** Kibana
**Created:** [April 12, 2019, 4:49am UTC](https://discuss.elastic.co/t/using-timestamp-field-for-filtering/176534 "2019-04-12T04:49:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![julsss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julsss/32/42044_2.png) [@julsss](https://discuss.elastic.co/u/julsss)
#### Post date: [April 12, 2019, 4:49am UTC](https://discuss.elastic.co/t/using-timestamp-field-for-filtering/176534/1 "2019-04-12T04:49:42Z")

</div>

Hello,

I am currently trying to create a monitoring visualization for API services that encounter an error for a certain a threshold and time. (I.E : API A encountered 100 errors for the last 2 minutes, API B encountered B encountered 50 errors for the last 5 minutes)

Will it be possible to use the @timestamp field of the document for the filtering query? For example : (API A : @timestamp - 2m) and for (API B : @timestamp - 5m) and then the threshold.

Added scenario:  
Let's say my visualization is monitoring all the API services for the past 1 hour. And an API has a threshold of 50 errors and 5 minutes.

---

<div class="post-metadata">

### Author: ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)
#### Post date: [April 12, 2019, 1:13pm UTC](https://discuss.elastic.co/t/using-timestamp-field-for-filtering/176534/2 "2019-04-12T13:13:24Z")

</div>

If the intervals are different for each application you'll probably want to have a different chart for each application that uses that interval.  
Then you create a Date Histogram chart with the interval as the one you want to count the errors for. Use a metric Count aggregation and a filter for the field that you're using to determine if it's an error.

If you also want a threshold line, that isn't a feature in Kibana yet, but can be emulated with a scripted field, on a field that just says "return x" where X is the threshold you want, 100 in your example for API A  
Then on the same chart as before add another metric, for Avg on the scripted field (this will always show that value of the scripted field).

---

<div class="post-metadata">

### Author: ![julsss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julsss/32/42044_2.png) [@julsss](https://discuss.elastic.co/u/julsss)
#### Post date: [April 25, 2019, 5:43am UTC](https://discuss.elastic.co/t/using-timestamp-field-for-filtering/176534/3 "2019-04-25T05:43:13Z")

</div>

Hello. Thank you for the answer.

---

<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: [May 23, 2019, 5:43am UTC](https://discuss.elastic.co/t/using-timestamp-field-for-filtering/176534/4 "2019-05-23T05:43:18Z")

</div>

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