# X-Pack Watcher -- adding additional fields

**URL:** <https://discuss.elastic.co/t/x-pack-watcher-adding-additional-fields/135068>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [June 8, 2018, 12:25am UTC](https://discuss.elastic.co/t/x-pack-watcher-adding-additional-fields/135068 "2018-06-08T00:25:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anhlon](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@anhlon](https://discuss.elastic.co/u/anhlon)\
**Post date:** [June 8, 2018, 12:25am UTC](https://discuss.elastic.co/t/x-pack-watcher-adding-additional-fields/135068/1 "2018-06-08T00:25:24Z")

</div>

Hi,

I am trying to setup a Watcher to send alerts to Slack when a service is down for the last minute. What I currently have is heartbeat collecting http ping data and sending it to Elasticsearch and all is well.

I have setup an alert that is being sent to slack, some with data. It is currently sending;

// foo@[http://foo:1234/healthz](http://foo:1234/healthz)  
// Total failure in the last minute: 5

which is a little uninformative. I would like to add "resolve.ip" and "error.message" to it.

// foo@[http://foo:1234/healthz](http://foo:1234/healthz) on host   
// Error:

question is, do i add more a sub-aggregate?

> ```
> "aggs": {
> "bucketAgg": {
> "terms": {
> "field": "monitor.id",
> "size": 50,
> "order": {
> "metricAgg": "desc"
> }
> },
> "aggs": {
> "metricAgg": {
> "terms": {
> "field": "error.message"
> }
> }
> }
> }
> }
> 
> ```

are there any docs or example that i can refer to?

Thanks,

---

<div class="post-metadata">

**Author:** ![baz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/baz/32/5183_2.png) [@baz](https://discuss.elastic.co/u/baz)\
**Post date:** [June 20, 2018, 5:07pm UTC](https://discuss.elastic.co/t/x-pack-watcher-adding-additional-fields/135068/2 "2018-06-20T17:07:35Z")

</div>

Hi, terribly sorry for the late response.

The short answer is there are a few ways you could do this.

1. you could use more terms aggregations in like you mentioned.

2. you could nest a [top\_hits](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html) aggregation as well, and pick the values you want.

3. you could use a watcher [transform](https://www.elastic.co/guide/en/elastic-stack-overview/current/transform-search.html) which is a step executed right before any actions are taken, and this will allow you to modify your search to include the values from another search.

Thanks,  
Baz.

---

<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 18, 2018, 5:07pm UTC](https://discuss.elastic.co/t/x-pack-watcher-adding-additional-fields/135068/3 "2018-07-18T17:07:45Z")

</div>

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