# Dynamic Watcher for Memory Metrics

**URL:** <https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045>\
**Category:** Kibana\
**Created:** [November 11, 2020, 10:58am UTC](https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045 "2020-11-11T10:58:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdamera](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@mdamera](https://discuss.elastic.co/u/mdamera)\
**Post date:** [November 11, 2020, 10:58am UTC](https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045/1 "2020-11-11T10:58:43Z")

</div>

Team,

I need to create a Dynamic watcher for below two metrics

| # jolokia.jvm.memory.heap.max | | 8,589,934,592 |
| --- | --- | --- |
| # jolokia.jvm.memory.heap.used | | 1,090,388,992 |

I need an watcher alert when jolokia.jvm.memory.heap.used reaches 85% of jolokia.jvm.memory.heap.max ( which will be dynamic)

I tried with " Create Threshold Alert" option, however I do not see an option to choose jolokia.jvm.memory.heap.max as Matching Condition (see attached screenshot)

I believe we can do this by Advanced Watcher, need your help on creating that

 ![Dynamic Watcher](https://us1.discourse-cdn.com/elastic/original/3X/2/0/2056ccbc7eb2c1bca8f65aa21eea669b4ab34b31.jpeg)

## Matching the following condition

WHEN average()

OF jolokia.jvm.memory.heap.used

OVER all documents

IS ABOVE 1825361100

FOR THE LAST 15 minutes

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 11, 2020, 7:29pm UTC](https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045/2 "2020-11-11T19:29:48Z")

</div>

Yes, this can be done with an advanced watcher. My suggestion is to take the JSON version of the watcher query and then modify it by adding a second metric, not just `average`. Then you can change the `condition` to divide the two metrics instead of using a static parameter.

---

<div class="post-metadata">

**Author:** ![mdamera](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@mdamera](https://discuss.elastic.co/u/mdamera)\
**Post date:** [November 12, 2020, 5:38pm UTC](https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045/3 "2020-11-12T17:38:27Z")

</div>

Do you have any readily available JSON file for any of Dynamic metrics ? It would be a great help if share it with me

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 12, 2020, 5:52pm UTC](https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045/4 "2020-11-12T17:52:12Z")

</div>

I don't, but I can help you debug the advanced watcher after you try the technique I mentioned above of copy+pasting the existing query

---

<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:** [December 10, 2020, 5:52pm UTC](https://discuss.elastic.co/t/dynamic-watcher-for-memory-metrics/255045/5 "2020-12-10T17:52:14Z")

</div>

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