Closed Anz14 closed 2 years ago
I'm not sure if its the problem but there is mismatch in parameter types. In the definition of demo_kafka_chain_meta you state it has a parameter called triggers which is of type "string".
But you are attempting in the rule to pass {{ trigger }} - but trigger is an object - not a string. If you want to pass the whole trigger then you will need to use an object type.
I always try and use orquesta rather than action-chains, so in this type of scenario I usually define the action as an orquesta workflow with a parameter of type object, and then would pass in something like {{trigger.body}}. So I'm not sure if there is a special problem with using {{trigger}} and action-chains.
@amanda11 I tried changing the action chain parameter from trigger to triggers and it worked.
---
chain:
-
name: "kafka_demo_disk_action"
ref: "demo.kafka_demo_disk_action"
parameters:
triggers: "{{ triggers }}"
on-success: "post_success_to_slack"
on-failure: "opsgenie_escalation"
-
name: "post_success_to_slack"
ref: "slack.post_message"
parameters:
channel: "#slo-sli"
message: "Current disk usage in / partition is less than 50% on <IP/Host>"
-
name: "opsgenie_escalation"
ref: "opsgenie.create_alert"
parameters:
message: "Current disk usage in / partition is more than 50% on <IP/Host>"
I have stackstorm configured in Ubuntu VM. And I'm integrating stackstorm with alert-manager for alert auto remediation. I'm getting the below error while executing the actionchain.
Error:
"error": "Failed to run task \"kafka_demo_disk_action\". Parameter rendering failed.. Failed rendering value for action parameter \"triggers\" in task \"kafka_demo_disk_action\" (template string={{trigger}}): 'trigger' is undefined",
"traceback": "Traceback (most recent call last):\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/action_chain_runner/action_chain_runner.py\", line 813, in _resolve_params\n rendered_params = jinja_utils.render_values(\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/util/jinja.py\", line 149, in render_values\n raise e\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/util/jinja.py\", line 144, in render_values\n rendered_v = env.from_string(v).render(super_context)\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/jinja2/environment.py\", line 1090, in render\n self.environment.handle_exception()\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/jinja2/environment.py\", line 832, in handle_exception\n reraise(*rewrite_traceback_stack(source=source))\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/jinja2/_compat.py\", line 28, in reraise\n raise value.with_traceback(tb)\n File \"\", line 1, in top-level template code\njinja2.exceptions.UndefinedError: 'trigger' is undefined\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/action_chain_runner/action_chain_runner.py\", line 534, in _run_chain\n liveaction = self._get_next_action(\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/action_chain_runner/action_chain_runner.py\", line 847, in _get_next_action\n resolved_params = ActionChainRunner._resolve_params(\n File \"/opt/stackstorm/st2/lib/python3.8/site-packages/action_chain_runner/action_chain_runner.py\", line 825, in _resolve_params\n raise action_exc.ParameterRenderingFailedException(msg)\nst2common.exceptions.action.ParameterRenderingFailedException: Failed rendering value for action parameter \"triggers\" in task \"kafka_demo_disk_action\" (template string={{trigger}}): 'trigger' is undefined\n"
Rule:
Action definition metadata:
Actionchain: