# Using Bucket Fields in Watcher

**URL:** <https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [August 16, 2019, 7:39pm UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558 "2019-08-16T19:39:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [August 16, 2019, 7:39pm UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558/1 "2019-08-16T19:39:21Z")

</div>

Hi,

My goal: To create an alert that tells me when a customer has not received a log.

My problem: The name of the customer is within an aggregated field.

My question: How do I retrieve the customer name and how can I incorporate this changing field into in the action?

// Below is my watcher thus far

> <https://gist.github.com/nhtrn/df2ccf1d0e81136e3daf964e8ecfccaa>

// Below is the aggregated query. Is it possible to retrieve the "key" field and have it appear in my action?

> <https://gist.github.com/nhtrn/0af1ca7e359b2a40a2ecc84ddf44d435>

Any advice is greatly appreciated! 🙂  
Thank you in advance

---

<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:** [August 19, 2019, 6:57am UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558/2 "2019-08-19T06:57:40Z")

</div>

please share the output of the [Execute Watch API](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/watcher-api-execute-watch.html), which makes it a lot easier to follow your steps.

---

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [August 19, 2019, 8:23am UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558/3 "2019-08-19T08:23:16Z")

</div>

Hi @spinscale,

I have yet to do my "action" section, which is where I am struggling.  
For the time being, I have put in a "text" action.

//Watcher Executed output

> <https://gist.github.com/nhtrn/df5bdabc0384d47792756decdf2c41ff>

Thank you,  
Nhung

---

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [August 19, 2019, 8:39am UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558/4 "2019-08-19T08:39:14Z")

</div>

I don't know if this is correct, but am I on somewhat on the right track?

// Watcher action

> <https://gist.github.com/nhtrn/4500e15b30cee54ff14711596c26263f>

---

<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:** [August 19, 2019, 9:31am UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558/5 "2019-08-19T09:31:23Z")

</div>

I just realized we are talking across two threads here. I will stop replying to this one. Please keep it to a single thread. Thanks!

---

<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:** [September 16, 2019, 9:37am UTC](https://discuss.elastic.co/t/using-bucket-fields-in-watcher/195558/7 "2019-09-16T09:37:15Z")

</div>

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