# X-Pack Watch jobs for CPU usage

**URL:** <https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540>\
**Category:** Elasticsearch\
**Created:** [April 25, 2018, 4:55pm UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540 "2018-04-25T16:55:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mww1](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mww1](https://discuss.elastic.co/u/mww1)\
**Post date:** [April 25, 2018, 4:55pm UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540/1 "2018-04-25T16:55:59Z")

</div>

Hi, I want to make a watch job for CPU usage\>20%.  
Please help me code with http input.  
thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 26, 2018, 11:55am UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540/2 "2018-04-26T11:55:36Z")

</div>

Hey,

please be more specific what your **exact** problem is, from the business side as well as from the technical side.

- Do you want to alert if CPU is above 20% one time or all the time or for a certain period in a row?
- Do you want to alert this for only one hosts or for all hosts? How should the alert look like if a host recovers?
- How does your data look like?
- Where do you get the data from?

Without taking the time and writing up more context it will be impossible to help you. Also you need to be more specific where you have problems from the technical side. What exactly is your issue with the HTTP input? If you have an error message, then provide (no screenshots please, copy and paste everything properly).

Also, please take a look at our examples [https://github.com/elastic/examples/tree/master/Alerting](https://github.com/elastic/examples/tree/master/Alerting)

--Alex

---

<div class="post-metadata">

**Author:** ![mww1](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mww1](https://discuss.elastic.co/u/mww1)\
**Post date:** [April 27, 2018, 3:51am UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540/5 "2018-04-27T03:51:13Z")

</div>

Thanks alex.  
I could manage to make the watcher for CPU usage using one of the examples you had in one of the post.  
but the thing is I did that using search input. I search a local index and using aggregations and timestamp and node\_stats.process.cpu.percent I could acheive the name of the nodes and their value for all the higher CPU usage nodes.  
but now the thing is I have to do it in **Http input** and not search input.  
In the input I want to specify a load balancer ip of one cluster, path etc.  
so do I do that? when I replace the input from search to http and define the ip, port etc along with a body(which contains all the aggreagtion and timestamp range) I am getting an error : illegal argument, for size : no parser found. when I remove size from the body I get the same error, now for query : no parser found.  
Please tell me how do I tweak my existing code to fit in http input instead of search input. they both will be doing the same job, but now I want to access other cluster, thats why I want to use http(where I can define the ip address of that cluster).  
Please help me!

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 27, 2018, 6:40am UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540/7 "2018-04-27T06:40:36Z")

</div>

the `body` field must be a string and cannot be an object currently.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 27, 2018, 2:43pm UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540/9 "2018-04-27T14:43:01Z")

</div>

The documentation contains an example, see [https://www.elastic.co/guide/en/x-pack/6.2/input-http.html](https://www.elastic.co/guide/en/x-pack/6.2/input-http.html)

---

<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 25, 2018, 2:45pm UTC](https://discuss.elastic.co/t/x-pack-watch-jobs-for-cpu-usage/129540/11 "2018-05-25T14:45:16Z")

</div>

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