alerting-kibana-plugin icon indicating copy to clipboard operation
alerting-kibana-plugin copied to clipboard

Document the fields available in ctx for trigger actions

Open Jon-AtAWS opened this issue 5 years ago • 8 comments

In the documentation: https://opendistro.github.io/for-elasticsearch-docs/docs/alerting/monitors/#add-actions

How do I know which fields I have available in ctx? I gather I have some or all of the monitor, trigger, and period. What other fields are there?

The UI includes an "info" button which is not helpful: image

Jon-AtAWS avatar Apr 01 '19 23:04 Jon-AtAWS

Hi @Jon-AtAWS , it's actually in the area you linked.

You can add variables to your messages using Mustache templates. You have access to ctx.action.name, the name of the current action, as well as all trigger variables.

aetter avatar Apr 02 '19 18:04 aetter

I failed at manual-reading in middle school. It's been a burden ever since ;-)

Jon-AtAWS avatar Apr 02 '19 18:04 Jon-AtAWS

Will move this to kibana-alerting repository since we can still make the UI info popout more informative :)

dbbaughe avatar Apr 02 '19 19:04 dbbaughe

@dbbaughe are you think we could support some kind of typeahead functionality to make the info pop out more or something else?

elfisher avatar Apr 03 '19 20:04 elfisher

@elfisher That would be nice :), but was just suggesting we add the documentation that Andrew mentioned into the UI in that popout window.

dbbaughe avatar Apr 04 '19 17:04 dbbaughe

@dbbaughe got it. That makes sense. A pop out with those docs would be nice :)

elfisher avatar Apr 05 '19 00:04 elfisher

There's a popout now, so let's close this issue.

celesteking avatar Apr 14 '20 11:04 celesteking

How can i access a variable defined in Trigger and later use in Actions. This variable is a custom variable defined in trigger. for example trigger condition is int ok = 20; int cr = 57; String state = 'TEMP'; if(cr > ctx.results[0].hits.total.value && ctx.results[0].hits.total.value > ok) {state='WARNING'; return true} if( ctx.results[0].hits.total.value > cr) {state='CRITICAL'; return true} if( ctx.results[0].hits.total.value < ok) {return false}

and now i would like to use the state in my actions, how can i use this? {{state}} Alert in message does not work, any ideas on how to make this work?

bchhabra avatar Jul 15 '21 08:07 bchhabra