# Cant understand watcher keywords

**URL:** https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [July 22, 2018, 4:22pm UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040 "2018-07-22T16:22:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rijinmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rijinmp/32/24634_2.png) [@rijinmp](https://discuss.elastic.co/u/rijinmp)
#### Post date: [July 22, 2018, 4:22pm UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/1 "2018-07-22T16:22:31Z")

</div>

When I am started to study watcher , i see lots of keywords in watcher examples . Samples are showing below

1)ctx.payload.hits.total  
2)ctx.payload.first.path  
3)ctx.metadata.color  
4)ctx.payload.aggregations.bucket\_results.top\_bucket\_hits.hits.hits.0.fields.timestamp\_iso8601.0

But these keywords are I never found in watcher documentation .

From where I can study these terms meaning and its usage ?

For example I want to know what is ctx, payload and how to make this queries combinations ?

Basic intention is i want to create custom watcher for my ML jobs

Now I am using GUI for creating watcher for my ML jobs

---

<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: [July 23, 2018, 6:57am UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/2 "2018-07-23T06:57:02Z")

</div>

Hey,

the payload is what is returned from the input - this makes it dynamic. If you have a simple input like this

```auto
"input" : {
  "simple" : {
    "foo" : "bar"
  }
}

```

then your payload will be a map like this `ctx.payload.foo`, which has the value `bar`.

If your input was a search, then the whole JSON search response will be put into the payload, so that things like `ctx.payload.hits.total` are accessible or aggregations like in your last example.

Hope that explains it!

--Alex

---

<div class="post-metadata">

### Author: ![rijinmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rijinmp/32/24634_2.png) [@rijinmp](https://discuss.elastic.co/u/rijinmp)
#### Post date: [July 23, 2018, 7:00am UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/3 "2018-07-23T07:00:33Z")

</div>

Hi @spinscale thanks for you reply .

From where I can study these whole terms meaning ?

Is there any documentations are available ?

---

<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: [July 23, 2018, 7:08am UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/4 "2018-07-23T07:08:56Z")

</div>

Hey,

Because of the dynamic nature of this there is no reference which fields are available. The data will differ with every input. If you use an HTTP input it is super different than if you use a search input because the data returned looks completely different. That is the reason why we cannot provide and reference to this.

If you need to know, how the data looks like, execute a search without a watch and study the response, same for . the HTTP input.

Does this make sense?

--Alex

---

<div class="post-metadata">

### Author: ![rijinmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rijinmp/32/24634_2.png) [@rijinmp](https://discuss.elastic.co/u/rijinmp)
#### Post date: [July 23, 2018, 10:39am UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/5 "2018-07-23T10:39:22Z")

</div>

What is the meaning of ctx ?

---

<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: [July 23, 2018, 11:45am UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/6 "2018-07-23T11:45:38Z")

</div>

ctx is the so called watch execution context.

> When execution starts, Watcher creates a watch execution context for the watch. The execution context provides scripts and templates with access to the watch metadata, payload, watch ID, execution time, and trigger information. For more information, see Watch Execution Context.

See [How Watcher works | Elasticsearch Guide [6.3] | Elastic](https://www.elastic.co/guide/en/elastic-stack-overview/6.3/how-watcher-works.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: [August 20, 2018, 11:45am UTC](https://discuss.elastic.co/t/cant-understand-watcher-keywords/141040/7 "2018-08-20T11:45:39Z")

</div>

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