{
"name": "reaction_name",
"event": "event_name",
"script": "console.log('this script will run before any action and decides what to do based on event data'); if (event['key'] == 42) {nextAction = 'first_action'} result = event;",
"actions": {
"first_action": {
"script": "console.log('this script will run *after* the action exec and decides what to exec next'); if (actionData['key'] == 'value') {nextAction = 'second_action'}",
"action": "dummy_action",
"module": "dummy"
},
"second_action": {
"script": "",
"action": "dummy_action",
"module": "dummy"
}
}
}
A reaction is composed of:
name
is the name of the reaction (be creative !)event
is the name of the event the reaction respond to (a GET request tohttp://$CSF_ADDR:8888/v1/events
will give you everything you need)script
is the JS script that will run first before any action. Use it to decide what to do based on the event dataactions
is the different actions that can be executed or not
An action is composed of:
module
: the name of the module containing the actionaction
: the name of the action (a GET tohttp://$CSF_ADDR:8888/v1/actions
will help you)script
: script that choose to continue the pipeline or not. Executed after the action.
Some variables you'll need:
event
is the data sent by the eventnextAction
: set this to choose which action to run next, leave empty to stop the pipelineerr
: set this to any non-empty string and the pipeline will stop with your error messageresult
: set this to pass data to an actionactionData
: the output data of the action
Every variable can be used in any script exec except actionData
which is not available in the first script
exec.