Cant understand watcher keywords

alerting

(Rijin) #1

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


(Alexander Reelsen) #2

Hey,

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

"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


(Rijin) #3

Hi @spinscale thanks for you reply .

From where I can study these whole terms meaning ?

Is there any documentations are available ?


(Alexander Reelsen) #4

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


(Rijin) #5

What is the meaning of ctx ?


(Alexander Reelsen) #6

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 https://www.elastic.co/guide/en/elastic-stack-overview/6.3/how-watcher-works.html


(system) closed #7

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