Hi,
I would like to get some precision and guidance on how the ctx content change/behave while working with a watch that combine transform, input (http) and action.
FYI - I'm trying to achieved a watch that will run API calls on my ES cluster using http input [note: the path/body of the calls are set up in a transform before my input] and then I want to use the results of my http chain to trigger a slack notification [for the purpose of this example - I have replace my slack action by a plain log text as it's helping me troubleshot].
I've listed below the issues that I've come to realized while working on this watch and I hope that you could bring some light on those to help me move forward :
1. The watch will stop execute a top level transform if you replace your input by a chain input
2. If you use a top level transform in combination with a http input only the content of the transform will end up in the CTX.payload while accessing it from the action section (end of watch sequence). While as soon as you remove the transform from the watch then suddenly your CTX.payload contains the results of the input(s) (as you would expect !!).
Here is the watch that I'm using - if you want to review/play with the two use cases expose above:
POST _watcher/watch/_execute { "watch":{ "metadata": { "keep_history_days": 7 }, "transform": { "script" : "return [ ParserIndexToDelete : '/.parser_metric_' + ctx.execution_time.minusDays(ctx.metadata.keep_history_days + 1).toString('yyyy.MM.dd'), WatcherIndexToDelete : '/.watch-history_' + ctx.execution_time.minusDays(ctx.metadata.keep_history_days + 1).toString('yyyy.MM.dd') ]" }, "trigger": { "schedule": { "daily": { "at" : "00:01" }} }, "input": { "chain" : { "inputs" : [ { "first" : { "http" : { "request": { "scheme" : "https", "host": "localhost", "port": 9243, "path": "{{ctx.payload.ParserIndexToDelete}}", "method": "delete", "auth" : { "basic" : { "username" : "username_here", "password" : "password_here" } } } } }, "second": { "http" : { "request": { "scheme" : "https", "host": "localhost", "port": 9243, "path": "{{ctx.payload.WatcherndexToDelete}}", "method": "delete", "auth" : { "basic" : { "username" : "username_here", "password" : "password_here" } } } } } } ] } }, "condition": { "always": {} }, "actions": { "log" : { "transform" : {}, "logging" : { "text" : "{{ctx}}" } } } } }
Note: I'm running this on an ElasticCloud 2.4 cluster (Gold).
As you might have guess my goals are to be able to 1. be able to use the ctx.payload on my transform in a input chain and 2. to have the http input(s) to record their results in ctx.payload so I can then use that in the action section of my watch.
Thanks in advance for your help!
Gregory