Hi, I’m learning stacktorm. I’m having trouble passing data from Sensor - Trigger -Rule to Action.
I have a sensor that checks for new rows in a MYSQL table.
The problem appears when I put the parameters in the Rule (commented in the example below “My Rule”).
Action execution does not occur.
If I comment the parameters, the rule successfully matches and the action executes successfully.
What will be the mistake?
The second question, how pass payload data from Rule to Action? Can you give an example explained?
My Sensor:
#hardcoded for debug
payload = {'key':"test", 'count': int(count) + 1}
self.sensor_service.dispatch(trigger='monitor.sensor', payload=payload)
The payload matches the Rule criteria (checked in enforcement):
My Rule:
---
name: rule_a
pack: monitor
description: Rule Dummy Data.
enabled: true
trigger:
type: monitor.sensor
parameters: {}
criteria:
trigger.key:
pattern: "test"
type: "equals"
action:
ref: monitor.action_a
#parameters:
#key: "{{trigger.key}}"
Payload in the trigger:
{ "count": 47, "key": "test" }
My Action def YAML
version: 1.0
description: Dummy action
tasks:
main_from_database:
action: monitor.action_def
next:
- when: <% succeeded() %>
publish: >
method=<% result().result.method %>
.....(more data)
do:
- api
- when: <% failed() %>
publish: stderr=<% result().stderr %>
do: notify_on_error