# Lots of filter cache evictions in Elasticsearch when used with Kibana

**URL:** <https://discuss.elastic.co/t/lots-of-filter-cache-evictions-in-elasticsearch-when-used-with-kibana/27750>\
**Category:** Elasticsearch\
**Created:** [August 20, 2015, 10:56am UTC](https://discuss.elastic.co/t/lots-of-filter-cache-evictions-in-elasticsearch-when-used-with-kibana/27750 "2015-08-20T10:56:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![widhalm\_t](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/widhalm_t/32/4290_2.png) [@widhalm\_t](https://discuss.elastic.co/u/widhalm_t)\
**Post date:** [August 20, 2015, 10:56am UTC](https://discuss.elastic.co/t/lots-of-filter-cache-evictions-in-elasticsearch-when-used-with-kibana/27750/1 "2015-08-20T10:56:47Z")

</div>

Hi there!

I'm seeing lot's of filter cache evictions in Elasticsearch 1.7.1 when I use some more complex Dashboards in Kibana 4.1.1. When I restart the whole cluster (it's a testing environment) it takes about 4 hours until the filter cache reaches the maximum I configured in `elasticsearch.yml` .

I wonder why this happens because I only use the same two dashboards (lots's of visualisations with `terms` and some line charts with `date histogram`. I only change the timeframe I want to see (from last 12 hours, to this day, to this week, to last 7 days) for testing.

I raised the percentage of filter cache and expected a positive performance impact. I did not yet measure response times because there are some other issues in the infrastructure to fix but at least I did not expect the filter cache to fill up start evicting.

In numbers, there are about 8 evictions per query!

I checked with some other ELK instances I can connect to and they keep at 0.7 evictions per query even after 14 days.

So am I just overreacting or is there something wrong?

Cheers,  
Thomas

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [August 21, 2015, 12:12pm UTC](https://discuss.elastic.co/t/lots-of-filter-cache-evictions-in-elasticsearch-when-used-with-kibana/27750/2 "2015-08-21T12:12:18Z")

</div>

I'm not super familiar with the internals of how Kibana uses filters, but I believe it is basically constructing time filters on top of buckets for your selected time window.

These windows will be relatively unique and not great for cache-reuse. If you select the last seven days, your filters will basically be `from: <some_time> to:<some_other_time>`. If you wait an hour and refresh, the filter becomes `from: <some_time + 1hr> to:<some_other_time + 1hr>`. Every ms, the old filter is essentially obsoleted, unless you are looking at the exact same time slice rather than a relative slice ("last XX period").

Elasticsearch doesn't cache filters using `now` expressions by default, to prevent exactly this kind of churn. The problem is that (I think) Kibana provides explicit start/stop times, which means the date expression is cached, never used again and churned out.

I believe this is a related ticket: [https://github.com/elastic/kibana/issues/4654](https://github.com/elastic/kibana/issues/4654)

With that said, I wouldn't worry about it toooo much, especially if you aren't seeing performance problems. It should be noted that not all evictions are equal either. An eviction on a small, newly created segment is much less expensive than an eviction on a very large segment...but they look equal in the stats.

Also, with time-based data, you tend to look at a certain "hot" window (say, the last week or month), so it's natural for older filters to churn out once they exceed that window.

---

<div class="post-metadata">

**Author:** ![widhalm\_t](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/widhalm_t/32/4290_2.png) [@widhalm\_t](https://discuss.elastic.co/u/widhalm_t)\
**Post date:** [August 25, 2015, 9:17am UTC](https://discuss.elastic.co/t/lots-of-filter-cache-evictions-in-elasticsearch-when-used-with-kibana/27750/3 "2015-08-25T09:17:40Z")

</div>

Thanks für your reply. This helps in cooling down some people always asking why "something's red in HQ plugin". 😉

I will keep an eye on the issue and keep living with these values for now. And I will try to get more dashboard builders to use more cacheable timeframes, if possible.

---

<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:** [July 5, 2017, 11:54pm UTC](https://discuss.elastic.co/t/lots-of-filter-cache-evictions-in-elasticsearch-when-used-with-kibana/27750/4 "2017-07-05T23:54:00Z")

</div>


