Watcher add field to payload

Hi, I have a watcher that takes people's data as input. If someone is below 21 yo it triggers the watcher and fires an index action. However I now need to add an additional field to the payload, which is "watchername" and just assign some value to it. All watchers will send data to the same index and I need it to differenciate the watchers later in the index, that's why I need the watchers name. I tried some things in the transform: ctx.payload.hits.hits.put("watchername", "name"),
and also

return [ctx.payload.hits.hits, "watchername": "name"]

but nothing works. It just could be a hardcoded value that we will set up, it doesn't have to really take the watchers name.
Any ideas? Thanks in advance

I assume that you are using the index action of Watcher, with a transform script. That link has an example transform script that is able to modify every document that the watcher is indexing. In the example watcher script from those docs, you could do "watcherName": "name" into the _doc instead of changing severity.

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