# Unable to regex on aggregation filter input box

**URL:** <https://discuss.elastic.co/t/unable-to-regex-on-aggregation-filter-input-box/230059>\
**Category:** Kibana\
**Created:** [April 28, 2020, 1:39am UTC](https://discuss.elastic.co/t/unable-to-regex-on-aggregation-filter-input-box/230059 "2020-04-28T01:39:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yishagerew](https://avatars.discourse-cdn.com/v4/letter/y/96bed5/32.png) [@yishagerew](https://discuss.elastic.co/u/yishagerew)\
**Post date:** [April 28, 2020, 1:39am UTC](https://discuss.elastic.co/t/unable-to-regex-on-aggregation-filter-input-box/230059/1 "2020-04-28T01:39:09Z")

</div>

I have the following metrics from a aws service: api-name-404, api-name-406, api-name-501,api-name-500.  
I wrote the aggregation filter query using regex. But since I want to show 5xx and 4xx errors in same graph, I have used a sum bucket aggregation.  
In order to filter out all 5xx errors under same bucket and used in a filter, I tried using this in the box like this: metric.name:api-name-5 but this doesn't work as it expect a full text match, and doesn't filter all 5xx errors.  
I tried several options to use a regex but looks impossible in the filter box for filters aggregation.

 ![Screen Shot 2020-04-27 at 8.34.49 PM](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2e14faf8c09f7ff1a405e2f4c72d87823bc46e4c.png)

I have wrote a query filter to retrieve all the 5xx errors as follows and this works.

 ![Screen Shot 2020-04-27 at 8.36.52 PM](https://us1.discourse-cdn.com/elastic/original/3X/f/0/f01cee888729617a0c8b53690eb9e6841317f81b.png)

But as I showed in the first figure, I can't use a regex to filter all class of 5xx errors under same filter. I can only show either 500 or 501 or so.

Any idea how to achieve the same?

---

<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:** [May 3, 2020, 9:56pm UTC](https://discuss.elastic.co/t/unable-to-regex-on-aggregation-filter-input-box/230059/2 "2020-05-03T21:56:50Z")

</div>

This is because what you're using in the top filter that you edited is Query DSL while the Filters in aggregation uses KQL. 5\* should work if the field is set to keyword afaik. Since you only have those 4 values I highly recommend just using AND/ OR in order to make the queries faster.

---

<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 31, 2020, 9:56pm UTC](https://discuss.elastic.co/t/unable-to-regex-on-aggregation-filter-input-box/230059/3 "2020-05-31T21:56:57Z")

</div>

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