# How to create alert in watcher advance? for the basic metrics of CPU, MEMORY

**URL:** <https://discuss.elastic.co/t/how-to-create-alert-in-watcher-advance-for-the-basic-metrics-of-cpu-memory/257705>\
**Category:** Kibana\
**Created:** [December 4, 2020, 10:02pm UTC](https://discuss.elastic.co/t/how-to-create-alert-in-watcher-advance-for-the-basic-metrics-of-cpu-memory/257705 "2020-12-04T22:02:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aandrewsllp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aandrewsllp/32/81786_2.png) [@aandrewsllp](https://discuss.elastic.co/u/aandrewsllp)\
**Post date:** [December 4, 2020, 10:02pm UTC](https://discuss.elastic.co/t/how-to-create-alert-in-watcher-advance-for-the-basic-metrics-of-cpu-memory/257705/1 "2020-12-04T22:02:53Z")

</div>

How do I add more fields in the message of my alert by watcher

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [December 18, 2020, 9:04pm UTC](https://discuss.elastic.co/t/how-to-create-alert-in-watcher-advance-for-the-basic-metrics-of-cpu-memory/257705/2 "2020-12-18T21:04:15Z")

</div>

If you configure [an advanced watch](https://www.elastic.co/guide/en/kibana/current/watcher-ui.html#watcher-create-advanced-watch) by editing the JSON directly, you should be able to update the action to attach any fields you want from the watch execution context.

For example, if you have fields in your document source and you want to include, say, the fields from your first hit, you can do something like this in the "Actions" part of your watcher definition:

```auto
  "actions": {
    "email": {
      "body": """Stats:
{{#ctx.payload.hits.hits.0}}

CPU: {{_source.cpu}}
Memory: {{_source.memory}}

{{/ctx.payload.hits.hits.0}}""",
       ...etc,
     }
  }

```

I'd encourage you to check out the docs on [how watcher works](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/how-watcher-works.html), specifically the section on [execution context](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/how-watcher-works.html#watch-execution-context) which will give you more detail on the possibilities.

---

<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:** [January 15, 2021, 9:04pm UTC](https://discuss.elastic.co/t/how-to-create-alert-in-watcher-advance-for-the-basic-metrics-of-cpu-memory/257705/3 "2021-01-15T21:04:18Z")

</div>

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