# Filter in metrics

**URL:** <https://discuss.elastic.co/t/filter-in-metrics/94222>\
**Category:** Kibana\
**Created:** [July 23, 2017, 4:16am UTC](https://discuss.elastic.co/t/filter-in-metrics/94222 "2017-07-23T04:16:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Padmavathy](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Padmavathy](https://discuss.elastic.co/u/Padmavathy)\
**Post date:** [July 23, 2017, 4:16am UTC](https://discuss.elastic.co/t/filter-in-metrics/94222/1 "2017-07-23T04:16:08Z")

</div>

I need to filter out time specified in format HH:mm:ss. I need to filter out values greater than a particular time say 9 am and get the count of those in metric graph.  
How can this be achieved in kibana

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [July 24, 2017, 5:13pm UTC](https://discuss.elastic.co/t/filter-in-metrics/94222/2 "2017-07-24T17:13:37Z")

</div>

Assuming your field is mapped to a datetime in Elasticsearch, yes, this is possible. To do it, you'll need to use a [Script Query](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-dsl-script-query.html), which I believe you can do from the filter bar at the top, using a custom filter and the JSON for the script query.

---

<div class="post-metadata">

**Author:** ![Padmavathy](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Padmavathy](https://discuss.elastic.co/u/Padmavathy)\
**Post date:** [July 25, 2017, 1:58am UTC](https://discuss.elastic.co/t/filter-in-metrics/94222/3 "2017-07-25T01:58:25Z")

</div>

Thanks @Joe\_Fleming.I need to filter time for each id  
That is  
For id 1 :Filtering values greater than 5pm  
id 2:Filtering values greater than 9pm

Is this possible using the script query.I tried with inline but the records were not getting filtered

---

<div class="post-metadata">

**Author:** ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)\
**Post date:** [July 25, 2017, 3:48pm UTC](https://discuss.elastic.co/t/filter-in-metrics/94222/4 "2017-07-25T15:48:26Z")

</div>

I honestly don't know. The scripted filters use the Painless scripting, and looking at the [docs on data types](https://www.elastic.co/guide/en/elasticsearch/painless/master/types.html), there is no mention of date handling. It's possible date operations are not supported. However, the [API reference](https://www.elastic.co/guide/en/elasticsearch/painless/5.5/painless-api-reference.html) mentioned a number of date methods, so I'm not at all sure.

Bottom line is, until there is better integration, you'd have to learn and use Painless. The [getting started](https://www.elastic.co/guide/en/elasticsearch/painless/5.5/painless-getting-started.html) area is probably a good place to start. You can also try asking question about it over in the Elasticsearch section too.

---

<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:** [August 22, 2017, 3:48pm UTC](https://discuss.elastic.co/t/filter-in-metrics/94222/5 "2017-08-22T15:48:42Z")

</div>

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